From: aminer on

Hello,


Parallel Sort Library 2.0


Author: Amine Moulay Ramdane


Description:

Parallel Sort Library that supports Parallel Quicksort, Parallel
HeapSort
and Parallel MergeSort on Multicores systems.

Parallel Sort Library 2.0 uses my Thread Pool Engine and quicksort
many array parts - of your array - in parallel using Quicksort or
HeapSort
or MergeSort and after that it finally merge them - with the merge()
procedure -


Note: Parallel Quicksort gave me ~3x speed on four cores.

And please look at test.pas inside the zip file, it's a parallel
quicksort example
- compile and execute it...


You can download Parallel Sort Library from:

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


Parallel Sort Library is very easy to use , and
here is an example in Object Pascal:

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

program test;


uses
{$IFDEF Delphi}cmem,{$ENDIF}
{$IFDEF DELPHI2005+}cmem,{$ENDIF}
ParallelSort,sysutils,classes;

type

TStudent = Class
public
Name: string;
end;

var tab:Ttabpointer;
myobj:TParallelSort;
student:TStudent;
i,j:integer;
c_ok:boolean;

function comp(Item1, Item2: Pointer): Integer;

begin
if TStudent(Item1).name < TStudent(Item2).name then result:=-1;
if TStudent(Item1).name > TStudent(Item2).name then result:=1;
if TStudent(Item1).name = TStudent(Item2).name then result:=0;
end;


begin

randomize;

myobj:=TParallelSort.create(4,ctQuickSort);
// number of cores and the sort's type
// ctQuickSort or ctHeapSort or ctMergeSort ..

setlength(tab,100000);

for i := LOW(tab) to HIGH(Tab)
do
begin
student:=TStudent.create;
student.name:= 'Amine'+inttostr(random(2000000));
// student.name:=random(10000000);
tab[i]:=student;

end;


myobj.sort(tab,@comp);


for i := LOW(tab) to HIGH(Tab)
do
begin
writeln(TStudent(tab[i]).name,' ');
end;

j:=0;

for i := j to HIGH(Tab) do freeandnil(TStudent(tab[i]));

setlength(tab,0);
myobj.free;
writeln('ok');
end.

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



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

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

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+



Sincerely,
Amine Moulay Ramdane.

From: aminer on

Hello again,


I have updated my Parallel Sort Library to version 2.01 ,
now Parallel HeapSort is working properly.


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


Sincerely,
Amine Moulay Ramdane.



On May 2, 3:14 am, aminer <ami...(a)videotron.ca> wrote:
> Hello,
>
> Parallel Sort Library 2.0
>
> Author: Amine Moulay Ramdane
>
> Description:
>
> Parallel Sort Library that supports Parallel Quicksort, Parallel
> HeapSort
> and Parallel MergeSort on Multicores systems.
>
> Parallel Sort Library 2.0 uses my Thread Pool Engine and quicksort
> many array parts - of your array -  in parallel using Quicksort or
> HeapSort
> or MergeSort and after that it finally merge them - with the merge()
> procedure -
>
> Note: Parallel Quicksort gave me ~3x speed on four cores.
>
> And please look at test.pas inside the zip file, it's a parallel
> quicksort example
> - compile and execute it...
>
> You can download Parallel Sort Library from:
>
> http://pages.videotron.com/aminer/
>
> Parallel Sort Library is very easy to use , and
> here is an example in Object Pascal:
>
> ----------------------------------------
>
> program test;
>
> uses
> {$IFDEF Delphi}cmem,{$ENDIF}
> {$IFDEF DELPHI2005+}cmem,{$ENDIF}
> ParallelSort,sysutils,classes;
>
> type
>
> TStudent = Class
> public
>  Name: string;
>    end;
>
> var tab:Ttabpointer;
>     myobj:TParallelSort;
>     student:TStudent;
>      i,j:integer;
>    c_ok:boolean;
>
> function comp(Item1, Item2: Pointer): Integer;
>
> begin
>  if TStudent(Item1).name < TStudent(Item2).name then result:=-1;
>  if TStudent(Item1).name > TStudent(Item2).name  then result:=1;
>  if TStudent(Item1).name = TStudent(Item2).name then result:=0;
> end;
>
> begin
>
> randomize;
>
> myobj:=TParallelSort.create(4,ctQuickSort);
>                         // number of cores and the sort's type
>                         // ctQuickSort or ctHeapSort or ctMergeSort ..
>
> setlength(tab,100000);
>
> for i := LOW(tab) to HIGH(Tab)
>   do
>    begin
>     student:=TStudent.create;
>     student.name:= 'Amine'+inttostr(random(2000000));
>    // student.name:=random(10000000);
>    tab[i]:=student;
>
>    end;
>
> myobj.sort(tab,@comp);
>
> for i := LOW(tab) to HIGH(Tab)
>  do
>  begin
>    writeln(TStudent(tab[i]).name,' ');
>  end;
>
> j:=0;
>
> for i := j to HIGH(Tab) do freeandnil(TStudent(tab[i]));
>
> setlength(tab,0);
> myobj.free;
> writeln('ok');
> end.
>
> --------------------------------
>
> Language: FPC Pascal v2.2.0+ / Delphi 7+:http://www.freepascal.org/
>
> Operating Systems: Win , Linux and Mac (x86).
>
> 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+
>
> Sincerely,
> Amine Moulay Ramdane.