Recent

Author Topic: Threadpool with priorities version 1.5 (stable version) has been ported to Delph  (Read 3727 times)

aminer

  • Hero Member
  • *****
  • Posts: 956

Hello,

Threadpool with priorities version 1.5 (stable version) has been ported to Delphi XE-XE4, i have included the 32 bit and 64 bit memory managers , that scale on multicores , inside the zip file.


Author: Amine Moulay Ramdane


Language: FPC Pascal v2.2.0+ / Delphi 5+: http://www.freepascal.org/

Operating Systems: Win , Linux and Mac (x86).


Description:

Thread Pool Engine.

The following have been added:

- You can give the following priorities to jobs:

LOW_PRIORITY
NORMAL_PRIORITY
HIGH_PRIORITY

- A lock-free queue for each worker thread and it uses work-stealing - for more efficiency -

- Enters in a wait state when there is no job in the queue - for more efficiency -

- You can distribute your jobs to the workers threads and call any method with the threadpool's execute() method.

- Uses O(1) complexity on enqueue and O(3) worst case complexity  on dequeue.

Look into defines.inc there is many options:

CPU32: for 32 bits architecture
CPU64: for 64 bits architecture

Please read an article that i wrote about my Threadpool engine: article.

Look at test1.pas example inside the zip file, to show you how to use PThreadpool engine as a scalable priority MPMC FIFO queue, with this same method  you can implement a  scalable priority MPMC FIFO queue (note: the exec() method is scalable, but execute() method is not scalable as the exec() method).

Required FPC switches: -O3 -Sd -dFPC -dWin32 -dFreePascal

-Sd for delphi mode....

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi 5,6,7 use -DDelphi

For Delphi 2005,2006,2007,2009,2010+ use the switch -DDELPHI2005+


Please look at the examples test.pas,testpool.pas and test_thread.pas...

Note: testpool.pas is a parallel program of a Matrix multiply by a vector that uses SSE+ and it requires Delphi 5+. test.pas and test_thread.pas works with both FreePascal and Delphi.


You can dowload Threadpool 1.5 from:

http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.



aminer

  • Hero Member
  • *****
  • Posts: 956

Hello,

I want to explain something about my scalable and relaxed MPMC priority Queue, i have overloaded the push() method, there is one Push() method
that is scalable and you must initialize it with high(pqueue.long),
and there is another Push() method that uses round robin method,
and i have benchmarked the Push() method that uses the Round Robin method (that makes the Push() none scalable) and i have noticed on my 2.4 Ghz computer that it can push() 100000 items in 10 milliseconds and that's fast and enough for many parallel applications.


You can dowload my scalable and relaxed MPMC priority Queue version 1.02
from:

http://pages.videotron.com/aminer/



Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956

Hello,

PThreadpool was updated to version 1.51 and  the scalable and relaxed MPMC priority Queue was updated to version 1.03, you can download them from:

http://pages.videotron.com/aminer/


Thank you,
Amine Moulay Ramdane.

 

TinyPortal © 2005-2018