### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: ParallelQueueh ...  (Read 3929 times)

#### aminer

• Hero Member
• Posts: 956
##### ParallelQueueh ...
« on: March 11, 2010, 09:39:24 pm »

Hello,

Description:

Parallel algorithm to handle unbounded queue FIFO that
use a parallel hash table (look at inthashlist inside the zip) with
O(1) (best case) and O(n)(worst case) access.

It's for educational purpose.

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

Operating Systems: Win , Linux and Mac (x86).
For ParallelQueue benchmarks on an Intel Core 2 Quad Q6600 look
at:

http://pages.videotron.com/aminer/parallelqueue/parallelqueueh.htm

Note:

I have modified the Hashlist (by Barry Kelly, search for it in
goolge) , now the Add(), Has(), Find() etc.does use integer
as a key instead of string argument. And also i have modified
the FindNode() method(look inside inthashlist.pas) to support
integer argument, now hashlist's FindNode() look like this :

-----------------------------------------------
[...]
if s < ppn^^.Str then r:=-1
else if s > ppn^^.Str then r:=1
else r:=0;
{ left, then right, then match }
if r < 0 then
ppn := @ppn^^.Left
else if r > 0 then
ppn := @ppn^^.Right
else
Break;
----------------------------------------------------

And i have added the parallel part in inthashlist...

etc.

ParallelQueueh is an unbounded FIFO (for educational purpose),

But ParallelQueue and lockfree_mpmc look in:
http://pages.videotron.com/aminer/parallelqueue/parallelqueue.htm
are very fast and very good lockfree bounded queue algorithms.

Note also that the Freepascal memory manager does scale linearly

But the Delphi memory manager does not scale linearly, so,. i have
used the TBB memory manager in delphi (look into cmem.pas inside the
ParallelHashList.zip).

Sincereley
Amine Moulay Ramdane.

#### aminer

• Hero Member
• Posts: 956
##### Re: ParallelQueueh ...
« Reply #1 on: March 11, 2010, 09:40:55 pm »

Hello again,

And don't forget to compile with -Sd (delphi mode) when
using FPC or Lazarus...

Sincerely,
Amine Moulay Ramdane.