Last update January 25, 2012

 

 

Welcome !

Hope you will enjoy the modules. Your comments, suggestions and feedback are welcome.

Sincerely,
Amine Moulay Ramdane
aminer@videotron.ca

 Modules/Authors

 

Files



A page that i wrote about a Jackson Network problem: Jackson Network.

And take a look at my article on how to analyze parallel applications with Petri Nets:
Petri Nets.

An webpage that i wrote about availability and efficiency, click here:
Availability and Efficiency


 
Linear programming modeling examples in Object Pascal

Click here to download the zip file: Zip


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

Operating Systems: Win , (x86).

Description:

Linear programming modeling examples in Object Pascal. Please look inside the zip at the example SP.pas (shortest-path problem) in Object Pascal, i have provided you with the LPSolve library, but the examples that i have included do generate and MPS file , so you can use a faster software than LPSolve , example SCIP or CLP from COIN-OR , and just pass them the MPS ouput file that the LPSolve library does generate and they will execute them without any problem...

Please look more information here: Linear Programming.


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

-Sd for delphi mode....

Required Delphi switches: -DMSWINDOWS -$H+ -DDelphi

Zip
Lockfree MPMC and SPMC fifo queues version 1.12


Click here to download the zip file: Zip


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

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

Description:

Lock-free SPMC algorithm to handle queue FIFO proposed by Amine Moulay Ramdane, use only single CAS on pop and no CAS on push. You can use it in a work-stealing manner with a local queue for each server thread to optimize for more throuput and minimize contention.

and

Lock-free MPMC algorithm to handle queue FIFO proposed by Dariusz Mazur (and modified by Amine Moulay Ramdane), use only single CAS on pop and single CAS on push.

Please look more information here: Lock-free MPMC.


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

-Sd for delphi mode....

Required Delphi switches: -DMSWINDOWS -$H+ -DDelphi

Zip
FIFO MPMC Queue


Click here to download the zip file: Zip


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

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

Description:

Parallel FIFO MPMC queue algorithm that uses a spinlock and an exponential backoff.

Please look at the benchmarks against lockfree fifo queues: FIFO MPMC queue.


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+


Zip

An M/M/n queuing model simulation with Object Pascal and my Thread Pool Engine - version 1.02


Author:
Amine Moulay Ramdane


Click here to download the zip file: Zip


Description:

It's harder and sometimes impossible to get analytical results about waiting times and queue length for general interarrival and service distributions; so, it's important to be able to estimate these quantities by observing the results of simulation.

It's very easy in Object Pascal to simulate a sequence of arrival times with a given interarrival distribution.

Look at the examples MM1.pas( M/M/1 queuing model) and MMn.pas(M/M/n - n: number of servers -) inside the zip file:

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

InterArrivals:=TExponentialDistribution.Create(420623,1.0/3.0);

ServiceTimes:=TExponentialDistribution.Create(220623,1.0/4.0);

currtime:=0.0;

for i:=1 to simnumber

do

begin

obj:=TJob.create;

obj.simnumber:=simnumber;

obj.number:=i;

currtime:=currtime+InterArrivals.Sample;

obj.ArrivalTime:=currtime;

obj.Servicetime:= ServiceTimes.sample;

TP.execute(myobj.myproc1,pointer(obj),NORMAL_PRIORITY);

end;

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

Here we have the InterArrivals object and ServiceTimes object and we are calling InterArrivals.Sample to get our samples from the Exponential Distribution.

After that we are calling myobj.myproc1 to simulate our M/M/1 queuing model...

If you look at MMn.pas , you will see that the arrival rate is: 3 and the service rate is 4 , so, this will give us a theoretical value of 1/(4-3) = 1 for one server, and the Object Pascal simulation gave me 1.02 for one server.

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+

Zip

Parallel Hashlist 1.2


Authors: Amine Moulay Ramdane(Parallel parts) and Barry Kelly (HashList).


Click here to download the zip file: Zip


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

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

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.

Please take a look at the benchmarks here: benchmarks.

Note: When i have done those benchmarks , there was not enough/much items organized as a self-balancing tree in the individual chains of the hashtable, so , almost all the items was found and inserted in O(1) , so the parallel part in the Amdahl equation was not much bigger compared to to the serial part. But you will notice in pratice that as soon as you will have more items on the chains of the Hash table , organized as self-balancing tree, with a worst case log(n)  , the parallel part will become bigger in the Amdahl equation and you will have better performance and scalability than the numbers in the graph of the benchmarks ...


Required FPC switches: -O3 -Sd -dFPC -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


Zip
WinMenus version 1.22


Author:
Amine Moulay Ramdane


Click here to download the zip file: Zip


Description:

Drop-Down Menu widget using the Object Pascal CRT unit. Please look at the test.pas example inside the zip file.

Use the 'Delete' on the keyboard to delete the items
Use the 'Insert' on the keyboard to insert the items
and use the 'Up' and 'Down' and 'PageUp and 'PageDown' to scroll ..
and use the 'Tab' on the keyboard to switch between the Drop Down Menus
and 'Enter' to select an item..
and the 'Esc' on the keyboard to exit..
and the 'F1' on keyboard to delete all the items from the list

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

Operating Systems: Windows, Mac OSX , Linux , Unix...


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

-Sd for delphi mode....

-dUnix for Linux , Unix and Mac OSX

-dWindows for windows

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi 5,6,7 use -DDelphi switch

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

Zip

Synch module version 1.04


Authors: Amine Moulay Ramdane,Marcel van Brakel ,Olivier Sannier ,Matthias Thoma,Florent Ouchet.Robert Marquardt.



Click here to download the zip file:
Zip


Description:

The following classes have been added to the Synch module: TCriticalSection,TMutex,TSimpleEvent,TSemaphore,TMultiReadExclusiveWrite.

Note: I have modified a little bit the TJclMultiReadExclusiveWrite from the Jedi code Library and rename it TMultiReadExclusiveWrite. TCriticalSection,TMutex,TSimpleEvent,TSemaphore are not from JCL

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

Operating Systems: Windows, Mac OSX , Linux , Unix...


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

-Sd for delphi mode....

-dUnix for Linux , Unix and Mac OSX

-dWindows for windows

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi 5,6,7 use -DDelphi switch

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

Zip

AWE version 1.1


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


Description:

Why the 2 GB limitation on the Win 32bits systems ?

My AWE object pascal module is here, it allows your application to use up to 64GB of RAM.

And here is the public interface of TAWEStream class, i have implemented the following methods:

TAWEStream = class(TStream)

public

Size:longword;
position:longword;
PageSize:integer;

constructor Create();
destructor Destroy(); override;
function GetMem(ulBytes: ulong): bool;
function FreeMem(): bool;
function HowManyPagesAllocated(): ulong;
function CopyFrom(in_stream:TStream;count:longint):longint;
function CopyTo(out_stream:TStream;count:longint):longint;
function Read(var Buffer;count:longint):longint;
function Write(const Buffer;count:longint):longint;
procedure LoadFromStream(in_stream: TStream);
procedure LoadFromFile(const FileName: string);
function ToString:string;

published

property TotalMem:int64 read gettotalmem;
property AvailMem:int64 read getavailmem;
property MemLoad:int64 read getmemload;


end;

Note: To be able to use AWE you have to set the user rights correctly, so, go to:

Control Panel -> Administrative tools -> Local Security Policy -> User Rights Assignment and give 'Lock pages in memory' right to the user that wants to use AWE.

Every TAWEStream object can go up to 4GB , and you can go up to 64GB !


And please look at the test examples 'test.pas' and 'test1.pas' inside the zipfile - compile and execute them... -


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

Operating Systems: Windows 2000 and up (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+

Zip

Parallel Compression 2.15


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


Description:

Parallel Gzip , Parallel Bzip , Parallel LZMA and Parallel LZ algorithms that use my Thread Pool Engine.

Please see the benchmarks here: benchmarks.

Please look at test_pgzip.pas , test_pbzip.pas and test_plzma.pas demos inside the zip file, compile and execute them... -


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

Note: Parallel Gzip , Parallel Bzip work with both FreePascal and Delphi , but Parallel LZMA works only with Delphi 7 and up.

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

Note: to be able to port to Linux and Mac OSX you have to compile the dynamic libraries...

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

-Sd for delphi mode....

-dUnix for Linux,MacOSX etc.

Required Delphi switches: -DMSWINDOWS -$H+ -DDelphi

Zip

Parallel Sort Library 2.15


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


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 -

And as you know , Quicksort is a divide and conquer algorithm that have the following best case performance:
 
T(n) = T(n/2) + T(n/2) + O(n)
       = 2T(n/2) + (n)

And from case 2 of Master theorem, the recurrence equation gives:

        T(n) = (n lg n)


Parallelizing the Sorts

One way to parallelize the sorts is:

  1. Divide the data among the processors
  2. Sort the data on the individual processors.
  3. Merge the various data

Note that the merge operation is a reduction operation !

Please see the benchmarks here: benchmarks.

And please look at test.pas a parallel quicksort on many cores - compile and execute it...


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+

Zip

Threadpool 1.35 (stable version)


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


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

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


Description:

Thread Pool Engine.

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

The following have been added:

  • Lockfree ParallelQueue for less contention and more efficiency or it can use lockfree_mpmc - flqueue that i have modified, enhanced and improved... -
  • 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.


Look into defines.inc there is many options:


Lockfree_MPMC: it uses lockfree_MPMC
RingBuffer: it uses lock-free RingBuffer
SINGLE_PRODUCER
: for a single producer (thread)
MUTIPLE_PRODUCER: mutiple producer (threads)
CPU32: for 32 bits architecture

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.


Zip

Threadpool with priority 1.24 (stable version)


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


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

- Lockfree ParallelQueue for less contention and more efficiency or it can use lockfree_mpmc - flqueue that i have modified, enhanced and improved... -

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

- Enters in a wait state when there no is 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 0(1) on enqueue and 0(3) worst case on dequeue.

Look into defines.inc there is many options:

CPU32: for 32 bits architecture
MUTIPLE_PRODUCER: mutiple producer (threads)
SINGLE_PRODUCER: for a single producer (thread)


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.


Zip
   
   

Lockfree priority SPMC queue 1.0


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip


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

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

Description:

Lock-free SPMC priority queue. It does use 0(1) on enqueue and 0(3) worst case on dequeue


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+


Zip
   

Parallel Matrix demo


Author: Amine Moulay Ramdane


Click here to download the zip file: Zip



Language: Delphi 5+

Operating Systems: NT/2000/XP and above.

Description:

Parallel program of Matrix multiply by a vector that uses SSE+ and my Lock-free Threadpool. Please look at the example testpool.pas inside the zip file...

This demonstration does use SSE+ , so if you don't have SSE support it will not work. It does work with P4 and above.

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+


Zip
   

LockfreeUtils



Click here to download the zip file:
Zip


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

Operating Systems: NT/2000/XP and above

Description:

TLFMemoryStream is like the Freepascal and Delphi TMemoryStream, but it's Lock-free: it mean that it's scalable and ready for multicores. Use the Lock-Free TLFMemoryStream to store data in a dynamic memory buffer that is enhanced with file-like access capabilities. TLFMemoryStream provides the general I/O capabilities of a stream object while introducing methods and properties to manage a dynamic memory buffer. Memory streams are useful as intermediary objects that can hold information as well as read it from or write it to another storage medium. They provide a useful format for comparing the contents of streams, or for manipulating data that is stored in a less accessible medium.

The zip file also include TAsyncFileStream - asynchronous file input/output in Windows NT. Please read AFS.txt inside the zip.


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+


Zip

API module (By Aldo Calpini)
version 0.58


Language: Perl: http://www.activestate.com

With this module you can import and call arbitrary functions from Win32's Dynamic Link Libraries (DLL).

API module for ActivePerl 5.10: Zip

Operating Systems: Windows 95/98/Me/NT/2000/XP

How to install:

Please read the readme file inside the zipfile.


.Zip

AdvNotify module (By Amine Moulay Ramdane)
version 1.32



Click here to download the zip file: Exe


Description:

With this object oriented Perl module you will be able to monitor the changes on your directories, this allows your Perl application to respond to changes in the file system, such as new file and/or directory creation, renaming, size, attribute, time, security-descriptor changes etc. Also, with AdvNotify you can run multiple threads from inside your Perl application to monitor the file system changes and you will be notified of wich file has been changed. The AdvNotify's interface has been carefully designed to be very easy to use.

Note: AdvNotify does use asynchronous completion to receive notification from the WinNT OS (no wasting CPU time "polling"), hence AdvNotify is very efficient. This module needs the API module, please download and install the API module before installing AdvNotify.

Perl: ActivePerl: 5.0050x, 5.6 or higher.

Operating Systems: Windows NT/2000/XP

How to install: Read the readme file inside the zip.

Documentation:

After installing AdvNotify, click on your \perl\html\index.html and scroll down to the Win32 links and you will find it there, or you can also access it directly from \perl\html\lib\win32\AdvNotify.html or from Start => Programs => ActivePerl (documentation).

Exe

Doc


NTFS module (By Amine Moulay Ramdane)
version 1.0


This object oriented Perl module implements a high level interface to the NTFS filesystem.

Please take a look at the documentation..

Perl: ActivePerl: 5.0050x, 5.6 or higher.

Operating System: Windows 2000/XP

Note: This module needs the API module, please download and install the API module before installing NTFS.

Zip

MemMap module (By Amine Moulay Ramdane)
version 2.12



Click here to download the zip file:
Zip


Description:


Shared memory is very important for client-server application developers and is also the fastest mechanism by wich server developers can etablish (local) interprocess communication between the cooperating tasks of an application program, often server applications are designed as a set of processes and threads, these tasks must use some kind of interprocess-communication mechanisms to communicate data and coordinate processing between each other, for example: TCP/IP,Pipes,Shared memory etc., but shared memory is the fastest one. This object oriented Perl module will allow you to map both memory and files into virtual address space, processes or threads can gain access to mapped memory via naming mechanism. If for example one process writes a data into a particular region of shared memory the other processes see it immediatly hence shared memory does avoid system space buffering and slow I/O operations, also shared memory will take benefit of the underlying VM paging mechanism and it will improve the memory access time (pages hits,locked memory regions). Any data structure you want can be embeded in a shared memory area and thus made accessible to multiple processes. This gives you the flexibility to create any communication structure you desire, both text and binary data are supported by this module.

Perl: ActivePerl: 5.0050x, 5.6 or higher.

Operating Systems: Windows 95/98/Me/NT/2000/XP

Note: This module needs the API module, please download and install the API module before installing MemMap.

Zip

Doc


ISync module (By Amine Moulay Ramdane)
version 1.21



Click here to download the zip file:
Zip


Description:

This object oriented Perl module implements the Win32 synchronisation mechanisms: Semaphore,Mutex, Event,Timer objects.

Perl: ActivePerl: 5.0050x, 5.6 or higher.

Operating Systems: Windows 95/98/Me/NT/2000/XP

Note: This module needs the API module, please download and install the Perl API module before installing ISync.

Zip

Doc

   

More to come,Thank you.