Recent

Author Topic: Parallel Sort Library 2.01  (Read 6648 times)

aminer

  • Hero Member
  • *****
  • Posts: 956
Parallel Sort Library 2.01
« on: May 02, 2010, 08:47:13 am »

Hello,


Parallel Sort Library 2.01


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:=student;


   end;


myobj.sort(tab,@comp);


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


j:=0;


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


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.



 

TinyPortal © 2005-2018