<?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 Re: IDS Thread Synchronization Article in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918718#M4865</link>
    <description>From a quick scan of the article, I'm guessing they're trying to figure out the most efficient way to implement the barrier synchronization object on windows if the APC stuff is a clue.&lt;BR /&gt;&lt;BR /&gt;APC has one minor problem in that it uses callbacks which means you want to use a language that supports closures if you want the parallel sections to appear inline in the code.&lt;BR /&gt;&lt;BR /&gt;In general, if you have code that is going to signal individual threads, you are going to have the problem of synchronizing a collective data structure with a lock, and of serial signaling.  Both are bottlenecks.&lt;BR /&gt;&lt;BR /&gt;Since this is windows, I'd go with a barrier implemented with 2 windows Event objects.  You can implment it lock-free.  It's fairly simple.  I can post the pseudocode if anyone's interested.&lt;BR /&gt;&lt;BR /&gt;Joe Seigh</description>
    <pubDate>Wed, 19 Jan 2005 21:42:03 GMT</pubDate>
    <dc:creator>jseigh</dc:creator>
    <dc:date>2005-01-19T21:42:03Z</dc:date>
    <item>
      <title>IDS Thread Synchronization Article</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918717#M4864</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Found a new threading article on the Intel Developer Services Home page:&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/183321.htm" target="_blank"&gt;"Multithreading for Experts: Inside a Parallel Application." &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The title is misleading since the article deals with methods of waking threads on demand with and without standard synchronization objects. There is some analysis of timing and comparison between methods.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;Any comments or discussion?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;--clay&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jan 2005 01:32:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918717#M4864</guid>
      <dc:creator>ClayB</dc:creator>
      <dc:date>2005-01-19T01:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: IDS Thread Synchronization Article</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918718#M4865</link>
      <description>From a quick scan of the article, I'm guessing they're trying to figure out the most efficient way to implement the barrier synchronization object on windows if the APC stuff is a clue.&lt;BR /&gt;&lt;BR /&gt;APC has one minor problem in that it uses callbacks which means you want to use a language that supports closures if you want the parallel sections to appear inline in the code.&lt;BR /&gt;&lt;BR /&gt;In general, if you have code that is going to signal individual threads, you are going to have the problem of synchronizing a collective data structure with a lock, and of serial signaling.  Both are bottlenecks.&lt;BR /&gt;&lt;BR /&gt;Since this is windows, I'd go with a barrier implemented with 2 windows Event objects.  You can implment it lock-free.  It's fairly simple.  I can post the pseudocode if anyone's interested.&lt;BR /&gt;&lt;BR /&gt;Joe Seigh</description>
      <pubDate>Wed, 19 Jan 2005 21:42:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918718#M4865</guid>
      <dc:creator>jseigh</dc:creator>
      <dc:date>2005-01-19T21:42:03Z</dc:date>
    </item>
    <item>
      <title>win32 barrier</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918719#M4866</link>
      <description>Here's some code of the top of my head. It compiles but hasn't been tested.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#define _WIN32_WINNT 0x0500&lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;typedef struct {&lt;BR /&gt;LONG waitCount;&lt;BR /&gt;LONG initCount;&lt;BR /&gt;int ndx; // index of active Event&lt;BR /&gt;HANDLE hEvent[2];&lt;BR /&gt;} barrier_t;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;// BarrierInit -- initialize barrier synchronization object&lt;BR /&gt;// count is the number of waiters using barrier&lt;BR /&gt;//&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;DWORD BarrierInit(barrier_t *barrier, LONG count) {&lt;BR /&gt;&lt;BR /&gt;if (count = 0)&lt;BR /&gt;return 1; // error&lt;BR /&gt;&lt;BR /&gt;barrier-&amp;gt;initCount = count;&lt;BR /&gt;barrier-&amp;gt;waitCount = count;&lt;BR /&gt;barrier-&amp;gt;ndx = 0;&lt;BR /&gt;// create 2 manually resettable events in non-signaled state&lt;BR /&gt;barrier-&amp;gt;hEvent[0] = CreateEvent(NULL, TRUE, FALSE, NULL);&lt;BR /&gt;barrier-&amp;gt;hEvent[1] = CreateEvent(NULL, TRUE, FALSE, NULL);&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;// BarrierDestroy --&lt;BR /&gt;//&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;DWORD BarrierDestroy(barrier_t *barrier) {&lt;BR /&gt;CloseHandle(barrier-&amp;gt;hEvent[0]);&lt;BR /&gt;CloseHandle(barrier-&amp;gt;hEvent[1]);&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;// BarrierWait -- wait on barrier w/ autoreset of barrier&lt;BR /&gt;//&lt;BR /&gt;//---------------------------------------------------------------&lt;BR /&gt;DWORD BarrierWait(barrier_t *barrier) {&lt;BR /&gt;int ndx;&lt;BR /&gt;&lt;BR /&gt;ndx = barrier-&amp;gt;ndx; // do this *before* decrement of waitcount!!&lt;BR /&gt;&lt;BR /&gt;if (InterlockedDecrement(&amp;amp;(barrier-&amp;gt;waitCount)) == 0) {&lt;BR /&gt;barrier-&amp;gt;waitCount = barrier-&amp;gt;initCount; // reset wait count&lt;BR /&gt;barrier-&amp;gt;ndx = 1 - ndx; // toggle index to next event&lt;BR /&gt;ResetEvent(barrier-&amp;gt;hEvent[barrier-&amp;gt;ndx]); // reset next Event&lt;BR /&gt;SetEvent(barrier-&amp;gt;hEvent[ndx]); // set (signal) current Event&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;else&lt;BR /&gt;WaitForSingleObject(barrier-&amp;gt;hEvent[ndx], INFINITE);&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/*-*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Of course it looks much better if the leading whitespace is preserved and the code is not wrapped.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Joe Seigh&lt;BR /&gt;&lt;BR /&gt;(the stuff I'm really working on)&lt;BR /&gt;&lt;A target="_blank" href="http://atomic-ptr-plus.sourceforge.net/"&gt;Atomic Ptr Plus&lt;/A&gt;</description>
      <pubDate>Wed, 19 Jan 2005 22:40:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918719#M4866</guid>
      <dc:creator>jseigh</dc:creator>
      <dc:date>2005-01-19T22:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: IDS Thread Synchronization Article</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918720#M4867</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Joe -&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks for the code.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I'm going to have to reread the article, but I thought the object was to devise a means to set up a "conditional wait" synchronization for Win32 threads like that found in Pthreads. I didn't think it was to have a barrier, except to allow multiple threads to be released on signal. More like a semaphore than a barrier.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;As I said, I was concentrating on other things and will need to go back over the article to see exactly what the authors were attempting.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;--clay&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Feb 2005 03:00:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/IDS-Thread-Synchronization-Article/m-p/918720#M4867</guid>
      <dc:creator>ClayB</dc:creator>
      <dc:date>2005-02-01T03:00:52Z</dc:date>
    </item>
  </channel>
</rss>

