Community
cancel
Showing results for 
Search instead for 
Did you mean: 
aminer10
Beginner
41 Views

Parallel Hashlist ...

Hello,

Description

A parallel HashList with O(1) (best case) and O(log(n))(worst case)
access that use a hash based method with an array of MREWs. This
will allow to parallelize the writes and reads in separate chains ,
and also to parallelize the reads in the same chain.

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

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

For benchmarks and a capacity planning example look here:

http://pages.videotron.com/aminer/parallelhashlist/queue.htm

You will find the zipfile in:

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

And here is a small example on how to use ParallelHashlist:
(I have included it inside the zipfile)

--------------------------------------------------------------------------------------

program test;

uses {$IFDEF Delphi}cmem,{$ENDIF}
Parallelhashlist,windows,syncobjs,sysutils,classes;

var
hndlArr : Array[0..19] of THandle;
AId:DWORD;
event:TSimpleEvent;
hash1:TParallelHashList;
j:integer;
trait:TCaseinsensitiveTraits;
obj:pointer;

function StartFunc1(InVal:pointer):longword;

var i,j:integer;
obj:pointer;
begin
event.waitfor(INFINITE);
for i:=0 to 1000000 //800000
do
begin
hash1.find('amine moulay
ramdane'+inttostr(random(5000000)),pointer(obj));
end;
end;

function StartFunc2(InVal:pointer):longword;
var i:integer;
a:integer;
obj:pointer;
begin
event.waitfor(INFINITE);
for i:=0 to 1000000
do
begin
hash1.find('amine moulay
ramdane'+inttostr(random(5000000)),pointer(obj));
end;
end;

function StartFunc3(InVal:pointer):longword;
var i:integer;
obj:pointer;
begin
event.waitfor(INFINITE);
for i:=0 to 1000000
do
begin
hash1.find('amine moulay
ramdane'+inttostr(random(5000000)),pointer(obj));
end;
end;

function StartFunc4(InVal:pointer):longword;
var i:integer;
obj:pointer;
begin
event.waitfor(INFINITE);
for i:=0 to 1000000
do
begin
hash1.find('amine moulay
ramdane'+inttostr(random(5000000)),pointer(obj));
end;
end;

begin
randomize;
trait:=TCaseinsensitiveTraits.create;;
hash1:=TParallelHashList.create(trait,6000000);
for j:=0 to 5000000
do
begin
obj:=pointer(j);
hash1.Add('amine moulay ramdane'+inttostr(j),obj);
end;

event:=TSimpleEvent.create;
hndlArr[0]:=BeginThread(nil,0,@StartFunc1,pointer(1),0,AId);
hndlArr[1]:=BeginThread(nil,0,@StartFunc2,pointer(1),0,AId);
hndlArr[2]:=BeginThread(nil,0,@StartFunc3,pointer(1),0,AId);
hndlArr[3]:=BeginThread(nil,0,@StartFunc4,pointer(1),0,AId);

event.setevent;
WaitForMultipleObjects(4, @hndlArr, True, INFINITE);

event.free;
hash1.free;

end.

-------------------------------------------------------------------------------------------

Regards,
Amine Moulay Ramdane.

0 Kudos
1 Reply
aminer10
Beginner
41 Views

Hello,

I haveupdated the graph for ParallelHashList benchmarks:

http://pages.videotron.com/aminer/parallelhashlist/queue.htm

Regards,
Amine Moulay Ramdane.

Reply