<?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 Threadpool version 1.1 is here... in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Threadpool-version-1-1-is-here/m-p/863575#M2568</link>
    <description>&lt;DIV class="fontsize2 cb mb" id="body"&gt;
&lt;DIV id="inbdy"&gt;&lt;A name="msg_165e269b11a54cbf"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR /&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Description:&lt;/P&gt;
&lt;P&gt;Lock-free threadpool.&lt;/P&gt;
&lt;P&gt;The following have been added:&lt;/P&gt;
&lt;P&gt;-- Lockfree ParallelQueue for less contention and more efficiency or &lt;BR /&gt;it can use lockfree_mpmc - flqueue that i have modified, enhanced and &lt;BR /&gt;improved... -&lt;/P&gt;
&lt;P&gt;- Work-stealing - for more efficiency -&lt;/P&gt;
&lt;P&gt;- Enters in a wait state when there no job in the queue, hence, it's &lt;BR /&gt;very efficient&lt;/P&gt;
&lt;P&gt;Look into define.inc there is many options:&lt;/P&gt;
&lt;P&gt;CPU32: for 32 bits architecture &lt;BR /&gt;MUTIPLE_PRODUCER: mutiple producer (threads) &lt;BR /&gt;ParallelQueue: does use ParallelQueue - very efficient - &lt;BR /&gt;Lockfree_MPMC: does use Lockfree_SPMC &lt;BR /&gt;ParallelQueueh: does use ParallelQueueh - ParallelQueueh is for &lt;BR /&gt;educational purpose - &lt;BR /&gt;SINGLE_PRODUCER: for a single producer (thread)&lt;/P&gt;
&lt;P&gt;Required switches: -Sd (Delphi mode) for FPC&lt;/P&gt;
&lt;P&gt;Please look at the examples test.pas and testpool.pas inside the &lt;BR /&gt;zip...&lt;/P&gt;
&lt;P&gt;Note: testpool.pas does require Delphi 5+, test.pas works with both &lt;BR /&gt;FreePascal and Delphi&lt;/P&gt;
&lt;P&gt;You can download Threadpool 1.1 from:&lt;/P&gt;
&lt;P&gt;&lt;A target="_blank" rel="nofollow" href="http://www.google.com/url?sa=D&amp;amp;q=http://pages.videotron.com/aminer/&amp;amp;usg=AFQjCNEc4XUK97itZ-yH6hly_HwgwpbUjg"&gt;http://pages.videotron.com/aminer/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Language: FPC Pascal v2.2.0+ / Delphi 5+: &lt;A target="_blank" rel="nofollow" href="http://www.google.com/url?sa=D&amp;amp;q=http://www.freepascal.org/&amp;amp;usg=AFQjCNHOcnTp_XQ7n1ilPCMCbPNzoqhDEQ"&gt;http://www.freepascal.org/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Operating Systems: Win , Linux and Mac (x86).&lt;/P&gt;
&lt;P&gt;Threadpool is *VERY* easy to use, here is an example:&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;program test;&lt;/P&gt;
&lt;P&gt;uses &lt;BR /&gt;{$IFDEF Delphi} &lt;BR /&gt;cmem, &lt;BR /&gt;{$ENDIF} &lt;BR /&gt;ThreadPool,sysutils,syncobjs;&lt;/P&gt;
&lt;P&gt;{$I defines.inc}&lt;/P&gt;
&lt;P&gt;type &lt;BR /&gt; TMyThread = class (TThreadPoolThread) &lt;BR /&gt; //procedure ProcessRequest(obj: Pointer); override;&lt;/P&gt;
&lt;P&gt; procedure MyProc1(obj: Pointer); &lt;BR /&gt; procedure MyProc2(obj: Pointer);&lt;/P&gt;
&lt;P&gt;  end;&lt;/P&gt;
&lt;P&gt;var &lt;BR /&gt; myobj:TMyThread; &lt;BR /&gt; TP: TThreadPool; &lt;BR /&gt; obj:pointer; &lt;BR /&gt; cs:TCriticalSection;&lt;/P&gt;
&lt;P&gt;procedure TMyThread.MyProc1(obj: Pointer); &lt;BR /&gt;begin&lt;/P&gt;
&lt;P&gt;cs.enter; &lt;BR /&gt;writeln('This is MyProc1 with parameter: ',integer(obj)); &lt;BR /&gt;cs.leave;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;procedure TMyThread.MyProc2(obj: Pointer); &lt;BR /&gt;begin&lt;/P&gt;
&lt;P&gt;cs.enter; &lt;BR /&gt;writeln('This is MyProc2 with parameter: ',integer(obj)); &lt;BR /&gt;cs.leave;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;begin&lt;/P&gt;
&lt;P&gt;myobj:=TMyThread.create;&lt;/P&gt;
&lt;P&gt;cs:=TCriticalSection.create;&lt;/P&gt;
&lt;P&gt;TP := TThreadPool.Create(4, 20, TMyThread); // 4 workers threads and &lt;BR /&gt;2^20 items for each queue.&lt;/P&gt;
&lt;P&gt;obj:=pointer(1); &lt;BR /&gt;TP.execute(myobj.myproc1,pointer(obj));&lt;/P&gt;
&lt;P&gt;obj:=pointer(2); &lt;BR /&gt;TP.execute(myobj.myproc2,pointer(obj));&lt;/P&gt;
&lt;P&gt;readln;&lt;/P&gt;
&lt;P&gt;TP.Terminate; &lt;BR /&gt;TP.Free;&lt;/P&gt;
&lt;P&gt;end.&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Sincerely, &lt;BR /&gt;Amine Moulay Ramdane.&lt;/P&gt;
&lt;/DIV&gt;
&lt;BR clear="all" /&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 24 Mar 2010 03:17:53 GMT</pubDate>
    <dc:creator>aminer10</dc:creator>
    <dc:date>2010-03-24T03:17:53Z</dc:date>
    <item>
      <title>Threadpool version 1.1 is here...</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Threadpool-version-1-1-is-here/m-p/863575#M2568</link>
      <description>&lt;DIV class="fontsize2 cb mb" id="body"&gt;
&lt;DIV id="inbdy"&gt;&lt;A name="msg_165e269b11a54cbf"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR /&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Description:&lt;/P&gt;
&lt;P&gt;Lock-free threadpool.&lt;/P&gt;
&lt;P&gt;The following have been added:&lt;/P&gt;
&lt;P&gt;-- Lockfree ParallelQueue for less contention and more efficiency or &lt;BR /&gt;it can use lockfree_mpmc - flqueue that i have modified, enhanced and &lt;BR /&gt;improved... -&lt;/P&gt;
&lt;P&gt;- Work-stealing - for more efficiency -&lt;/P&gt;
&lt;P&gt;- Enters in a wait state when there no job in the queue, hence, it's &lt;BR /&gt;very efficient&lt;/P&gt;
&lt;P&gt;Look into define.inc there is many options:&lt;/P&gt;
&lt;P&gt;CPU32: for 32 bits architecture &lt;BR /&gt;MUTIPLE_PRODUCER: mutiple producer (threads) &lt;BR /&gt;ParallelQueue: does use ParallelQueue - very efficient - &lt;BR /&gt;Lockfree_MPMC: does use Lockfree_SPMC &lt;BR /&gt;ParallelQueueh: does use ParallelQueueh - ParallelQueueh is for &lt;BR /&gt;educational purpose - &lt;BR /&gt;SINGLE_PRODUCER: for a single producer (thread)&lt;/P&gt;
&lt;P&gt;Required switches: -Sd (Delphi mode) for FPC&lt;/P&gt;
&lt;P&gt;Please look at the examples test.pas and testpool.pas inside the &lt;BR /&gt;zip...&lt;/P&gt;
&lt;P&gt;Note: testpool.pas does require Delphi 5+, test.pas works with both &lt;BR /&gt;FreePascal and Delphi&lt;/P&gt;
&lt;P&gt;You can download Threadpool 1.1 from:&lt;/P&gt;
&lt;P&gt;&lt;A target="_blank" rel="nofollow" href="http://www.google.com/url?sa=D&amp;amp;q=http://pages.videotron.com/aminer/&amp;amp;usg=AFQjCNEc4XUK97itZ-yH6hly_HwgwpbUjg"&gt;http://pages.videotron.com/aminer/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Language: FPC Pascal v2.2.0+ / Delphi 5+: &lt;A target="_blank" rel="nofollow" href="http://www.google.com/url?sa=D&amp;amp;q=http://www.freepascal.org/&amp;amp;usg=AFQjCNHOcnTp_XQ7n1ilPCMCbPNzoqhDEQ"&gt;http://www.freepascal.org/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Operating Systems: Win , Linux and Mac (x86).&lt;/P&gt;
&lt;P&gt;Threadpool is *VERY* easy to use, here is an example:&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;program test;&lt;/P&gt;
&lt;P&gt;uses &lt;BR /&gt;{$IFDEF Delphi} &lt;BR /&gt;cmem, &lt;BR /&gt;{$ENDIF} &lt;BR /&gt;ThreadPool,sysutils,syncobjs;&lt;/P&gt;
&lt;P&gt;{$I defines.inc}&lt;/P&gt;
&lt;P&gt;type &lt;BR /&gt; TMyThread = class (TThreadPoolThread) &lt;BR /&gt; //procedure ProcessRequest(obj: Pointer); override;&lt;/P&gt;
&lt;P&gt; procedure MyProc1(obj: Pointer); &lt;BR /&gt; procedure MyProc2(obj: Pointer);&lt;/P&gt;
&lt;P&gt;  end;&lt;/P&gt;
&lt;P&gt;var &lt;BR /&gt; myobj:TMyThread; &lt;BR /&gt; TP: TThreadPool; &lt;BR /&gt; obj:pointer; &lt;BR /&gt; cs:TCriticalSection;&lt;/P&gt;
&lt;P&gt;procedure TMyThread.MyProc1(obj: Pointer); &lt;BR /&gt;begin&lt;/P&gt;
&lt;P&gt;cs.enter; &lt;BR /&gt;writeln('This is MyProc1 with parameter: ',integer(obj)); &lt;BR /&gt;cs.leave;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;procedure TMyThread.MyProc2(obj: Pointer); &lt;BR /&gt;begin&lt;/P&gt;
&lt;P&gt;cs.enter; &lt;BR /&gt;writeln('This is MyProc2 with parameter: ',integer(obj)); &lt;BR /&gt;cs.leave;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;begin&lt;/P&gt;
&lt;P&gt;myobj:=TMyThread.create;&lt;/P&gt;
&lt;P&gt;cs:=TCriticalSection.create;&lt;/P&gt;
&lt;P&gt;TP := TThreadPool.Create(4, 20, TMyThread); // 4 workers threads and &lt;BR /&gt;2^20 items for each queue.&lt;/P&gt;
&lt;P&gt;obj:=pointer(1); &lt;BR /&gt;TP.execute(myobj.myproc1,pointer(obj));&lt;/P&gt;
&lt;P&gt;obj:=pointer(2); &lt;BR /&gt;TP.execute(myobj.myproc2,pointer(obj));&lt;/P&gt;
&lt;P&gt;readln;&lt;/P&gt;
&lt;P&gt;TP.Terminate; &lt;BR /&gt;TP.Free;&lt;/P&gt;
&lt;P&gt;end.&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Sincerely, &lt;BR /&gt;Amine Moulay Ramdane.&lt;/P&gt;
&lt;/DIV&gt;
&lt;BR clear="all" /&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 Mar 2010 03:17:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Threadpool-version-1-1-is-here/m-p/863575#M2568</guid>
      <dc:creator>aminer10</dc:creator>
      <dc:date>2010-03-24T03:17:53Z</dc:date>
    </item>
  </channel>
</rss>

