<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic boost::thread and Amplifier in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/boost-thread-and-Amplifier/m-p/745002#M1813</link>
    <description>I've searched this forum and found some older posts about support in Parallel Studio for profiling boost::threads. We currently have a thread pool implementation built on top of boost::thread (boost version 1.39). When I run the Hot Spot version of Amplifier, it doesn't even show the worker threads in the thread filter, nor does it show any of the code that was run in the worker threads.&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The earlier posts indicated that Parallel Studio possibly doesn't support the primitives on which boost::threads are built. Can someone clarify that for me and let me know whether that support will be coming soon, possibly even in Parallel Studio 2011? I would like to be able to profile this code and would rather not have to port it to another threading library right now.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;</description>
    <pubDate>Wed, 08 Sep 2010 14:57:13 GMT</pubDate>
    <dc:creator>Brian_Hart</dc:creator>
    <dc:date>2010-09-08T14:57:13Z</dc:date>
    <item>
      <title>boost::thread and Amplifier</title>
      <link>https://community.intel.com/t5/Software-Archive/boost-thread-and-Amplifier/m-p/745002#M1813</link>
      <description>I've searched this forum and found some older posts about support in Parallel Studio for profiling boost::threads. We currently have a thread pool implementation built on top of boost::thread (boost version 1.39). When I run the Hot Spot version of Amplifier, it doesn't even show the worker threads in the thread filter, nor does it show any of the code that was run in the worker threads.&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The earlier posts indicated that Parallel Studio possibly doesn't support the primitives on which boost::threads are built. Can someone clarify that for me and let me know whether that support will be coming soon, possibly even in Parallel Studio 2011? I would like to be able to profile this code and would rather not have to port it to another threading library right now.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 Sep 2010 14:57:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/boost-thread-and-Amplifier/m-p/745002#M1813</guid>
      <dc:creator>Brian_Hart</dc:creator>
      <dc:date>2010-09-08T14:57:13Z</dc:date>
    </item>
    <item>
      <title>boost::thread and Amplifier</title>
      <link>https://community.intel.com/t5/Software-Archive/boost-thread-and-Amplifier/m-p/745003#M1814</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Asa simple answer - &lt;STRONG&gt;not supported yet&lt;/STRONG&gt;!&lt;BR /&gt;&lt;BR /&gt;VTune Amplifier XE Beta supports (detects) APIs from &lt;SPAN style="text-decoration: underline;"&gt;traditional threading APIs, Intel TBB, OpenMP* and Intel Cilk&lt;/SPAN&gt; - Boost is not included!&lt;BR /&gt;However some of the boost thread apis map back to standard posix thread apis. VTune Amplifier XE should capture thread creation and concurrency correctly.&lt;BR /&gt;&lt;BR /&gt;I ever used Boost v1.37 on Linux* to build a small program, which createdtwo new threadsto do writing into buffer and reading from buffer.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;#include &lt;IOSTREAM&gt;&lt;BR /&gt;#include &lt;BOOST&gt;&lt;BR /&gt;#include &lt;BOOST&gt;&lt;BR /&gt;#include &lt;BOOST&gt;&lt;/BOOST&gt;&lt;/BOOST&gt;&lt;/BOOST&gt;&lt;/IOSTREAM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;const int BUF_SIZE = 100;&lt;BR /&gt;const int ITERS = 10000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;boost::mutex io_mutex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;class buffer&lt;BR /&gt;{&lt;BR /&gt;public:&lt;BR /&gt; typedef boost::mutex::scoped_lock scoped_lock;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; buffer() : p(0), c(0), full(0) { }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; void put(int m)&lt;BR /&gt; {&lt;BR /&gt; scoped_lock lock(mutex);&lt;BR /&gt; if (full == BUF_SIZE)&lt;BR /&gt; {&lt;BR /&gt; {&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; boost::mutex::scoped_lock lock(io_mutex);&lt;BR /&gt; std::cout &amp;lt;&amp;lt; "Buffer is full. Waiting..." &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; }&lt;BR /&gt; while (full == BUF_SIZE)&lt;BR /&gt; cond.wait(lock);&lt;BR /&gt; }&lt;BR /&gt; buf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; = m;&lt;BR /&gt; p = (p+1) % BUF_SIZE;&lt;BR /&gt; ++full;&lt;BR /&gt; cond.notify_one();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; int get()&lt;BR /&gt; {&lt;BR /&gt; scoped_lock lk(mutex);&lt;BR /&gt; if (full == 0)&lt;BR /&gt; {&lt;BR /&gt; {&lt;BR /&gt; boost::mutex::scoped_lock lock(io_mutex);&lt;BR /&gt; std::cout &amp;lt;&amp;lt; "Buffer is empty. Waiting..." &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; }&lt;BR /&gt; while (full == 0)&lt;BR /&gt; cond.wait(lk);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; }&lt;BR /&gt; int i = buf&lt;C&gt;;&lt;BR /&gt; c = (c+1) % BUF_SIZE;&lt;BR /&gt; --full;&lt;BR /&gt; cond.notify_one();&lt;BR /&gt; return i;&lt;BR /&gt; }&lt;/C&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;private:&lt;BR /&gt; boost::mutex mutex;&lt;BR /&gt; boost::condition cond;&lt;BR /&gt; unsigned int p, c, full;&lt;BR /&gt; int buf[BUF_SIZE];&lt;BR /&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;buffer buf;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;void writer()&lt;BR /&gt;{&lt;BR /&gt; for (int n = 0; n &amp;lt; ITERS; ++n)&lt;BR /&gt; {&lt;BR /&gt; {&lt;BR /&gt; boost::mutex::scoped_lock lock(io_mutex);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt; std::cout &amp;lt;&amp;lt; "sending: " &amp;lt;&amp;lt; n &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; }&lt;BR /&gt; buf.put(n);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;void reader()&lt;BR /&gt;{&lt;BR /&gt; for (int x = 0; x &amp;lt; ITERS; ++x)&lt;BR /&gt; {&lt;BR /&gt; int n = buf.get();&lt;BR /&gt; {&lt;BR /&gt; boost::mutex::scoped_lock lock(io_mutex);&lt;BR /&gt; std::cout &amp;lt;&amp;lt; "received: " &amp;lt;&amp;lt; n &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;int main(int argc, char* argv[])&lt;BR /&gt;{&lt;BR /&gt; boost::thread thrd1(&amp;amp;reader);&lt;BR /&gt; boost::thread thrd2(&amp;amp;writer);&lt;BR /&gt; thrd1.join();&lt;BR /&gt;&lt;SPAN style="font-family: Courier New;"&gt; thrd2.join();&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;1) Hotspots - sometime result didn't show helpful info(Function name will be displayed as "[Unkown]") - if you run program shortly. That is why I put "ITERS" value to"10000"&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.intel.com/skins/images/7B13F55A7CE623EF42E69096FA81A3A1/2021_redesign/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;2) Concurrency - result showthree threads in timeline report and function name can be displayed. Also all thread's activities can be captured, including thread creation, thread termination, thread transitions, Concurrency, CPU usage, etc.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.intel.com/skins/images/7B13F55A7CE623EF42E69096FA81A3A1/2021_redesign/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;3) Locks and Waits - result should show all sync-objects. We don't expect to get all the locks and waits done correctly, butsomemutexof BOOST still can bedetected!&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.intel.com/skins/images/7B13F55A7CE623EF42E69096FA81A3A1/2021_redesign/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Regards, Peter&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2010 07:32:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/boost-thread-and-Amplifier/m-p/745003#M1814</guid>
      <dc:creator>Peter_W_Intel</dc:creator>
      <dc:date>2010-09-09T07:32:19Z</dc:date>
    </item>
  </channel>
</rss>

