[fpc-devel] Suggestion: reference counted objects
mschnell at lumino.de
Mon Sep 29 10:07:56 CEST 2014
On 09/26/2014 06:06 PM, Mark Morgan Lloyd wrote:
> Different implementations could potentially use either local threads
> or OpenMPI.
With "Local Thread" you supposedly mean user land threads. Same would
need to be implemented together with an appropriate set of synchronizing
functions. Seems like a huge effort (in fact a complete preemptive
multitasking OS running in user land)
I suppose there are several ways to implement OpenMP.
>> Same could be accessible by the user for more complex stuff and be
>> used as the infrastructure of a parallel loop syntax.
> Agreed, but a good starting point would be working out how to map a
> sequential (non-reentrant) block syntax onto e.g. the existing
> critical section class.
As "easy to use" syntax I meant simple stuff that don't need explicit
critical sections but just a means to hold the main line code until the
spawned parallel processing is ready. I understand in Prism this is
done with "future" variable, but I don't know how they are used.
Something like this to do a matrix multiplication
parallel for i := 0 to m-1 do begin
parallel for j = 0 to n-1 do begin
r := 0;
for k := 0 to n-1 do begin
r := r + x[k,j] * y[i,k];
z[i,j] = r
(or similar :-) )
Here, obviously Z needs to be defined as a "future" that is available
not before all instances of the parallel loops are done.
The compiler magic and library would need to take care of launching an
appropriate count of threads (about as many as the count of processors
available in hardware).
More information about the fpc-devel