Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #916

Re: The following libraries have been ported to 64 bits architecture...

From "aminer" <aminer@videotron.ca>
Newsgroups comp.programming.threads, comp.programming
Subject Re: The following libraries have been ported to 64 bits architecture...
Date 2012-06-03 10:05 -0500
Organization A noiseless patient Spider
Message-ID <jqfqvq$2cn$1@dont-email.me> (permalink)
References <jqfoej$iqt$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


Hello,

Since my threadpool engine is using lockfree_mpmc
I had to port lockfree_mpmc to 64 bits architecture an
this was easy , i had to change two thinks, first i had to
change the longword type to use a qword type (8 bytes types),
and also i had to change the CAS to support the 64 bits architecture.

I have changed also the following inside my thread pool engine:

Before entering the wait state the worker threads have to do a test like
this: If ThreadPool.Queues[self.threadcount].count <> 0 Then continue


Like this
--
If ThreadPool.Queues[self.threadcount].count <> 0
Then continue;

for i:=0 to FThreadpool.Fthreadcount-1 do 
count:=count+FThreadPool.Queues[i].count;

if count=0 then
begin
FThreadpool.events[self.threadcount].waitfor(INFINITE);
FThreadpool.events[self.threadcount].resetevent;
end;
---

And the following have been added to Threadpool:

Lock-free_mpmc - flqueue that i have modified, enhanced and improved... -
1.  It  uses a lock-free queue for each worker thread and it uses 
work-stealing - for more efficiency -
2. The worker threads enters in a wait state when there is no job in the 
lock-free queues - for more efficiency -
3. You can distribute your jobs to the worker threads and call any method 
with the threadpool's execute() method.


Here is the first change for 64 bits architecture in lockfree_mpmc:

--
type
{$IFDEF CPU64}
long = qword;
{$ENDIF CPU64}
{$IFDEF CPU32}
long = longword;
{$ENDIF CPU32}
---

and here is the CAS in lockfree_mpmc that i have changed to support
the 64 bits architecture:

--
function CAS(var Target:long;Comp ,Exch : long): boolean;assembler;stdcall;
asm
{$IFDEF CPU64}
mov rax, comp
lock cmpxchg [Target], Exch
setz al
{$ENDIF CPU64}
{$IFDEF CPU32}
mov eax, comp
mov ecx,Target
mov edx,exch
lock cmpxchg [ecx], edx
setz al
{$ENDIF CPU32}

---


And the Object Pascal language was fun fun...

And here is where you can download Lazarus for 64 bits architecture:

http://www.lazarus.freepascal.org/

And here is where you can download Freepascal for 64 bits architecture:

http://www.freepascal.org/



Thank you,
Amine Moulay Ramdane.




"aminer" <aminer@videotron.ca> wrote in message 
news:jqfoej$iqt$1@dont-email.me...
>
> The following libraries have been ported to 64 bits architecture...
>
>
> 1. My ParallelSort library
>
> 2. My ParallelGzip inside my parallelcompression library,
>   but you have to use the zlib1.dll for 64 bits architecture.
>
> 3. Lockfree_mpmc
>
> 4. Parallelhashlist
>
> 5. Threadpool engine.
>
>
> To compile them, for 64 bits architecture, just open the defines.inc
> and use the following defines:
> {$DEFINE CPU64} for 64 bits architecture
>
> {$DEFINE CPU32} for 32 bits architecture
>
>
> You have to use Freepascal for 64 bits architecture
> or Lazarus for 64 bits architecture to compile the
> libraries for 64 bits architecture.
>
> You can download those libraries from:
>
> http://pages.videotron.com/aminer/
>
>
>
> Thank you.
> Amine Moulay Ramdane.
>
>
>
>
>
>
>
>
> 

Back to comp.programming.threads | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

The following libraries have been ported to 64 bits architecture... "aminer" <aminer@videotron.ca> - 2012-06-03 09:22 -0500
  Re: The following libraries have been ported to 64 bits architecture... "aminer" <aminer@videotron.ca> - 2012-06-03 09:31 -0500
  Re: The following libraries have been ported to 64 bits architecture... "aminer" <aminer@videotron.ca> - 2012-06-03 10:05 -0500

csiph-web