[fpc-devel] Suggestion: reference counted objects

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Sep 27 11:26:01 CEST 2014


Mark Morgan Lloyd schrieb:
> Boian Mitov wrote:

>> I think parallel processing belongs in library implementations.
> 
> I have reservations, based in part on the fact that other language 
> implementations are prepared to assume responsibility for 
> parallelisation, in part on experience with e.g. APL which at the very 
> least specifies that the user should assume that operations are 
> parallelised, and in part on the fact that FPC already vectorises on 
> e.g. SSE2 hardware.

What do you (both) mean by "parallel processing"?

Streaming (SSE...) does *vectoring*, i.e. multiple (floating point) 
operands of the same *array* are processed in parallel. Such cases can 
be handled by the compiler, no libraries are involved, no threads, no 
risk of side-effects.

When instead a general loop, possibly containing multiple statements, is 
broken into multiple loops, which are processed in parallel, 
side-effects can occur depending on the operations (virtual methods...) 
in the loop. Then it IMO is up to the developer to check which loop can 
be parallelized without side-effects, and indicates that to the 
compiler. In this case the compiler could turn the body of the loop into 
an TThread, and insert an RTL call to execute this thread split into 
multiple instances. The RTL then creates the threads at runtime 
(depending on what? cores, already active threads...?), assigns to each 
an subrange of the entire loop interval, starts them and waits until all 
of them have terminated. This would limit the types of loops to FOR 
loops, with a known interval, excluding REPEAT, WHILE and FOREACH loops. 
Right?

DoDi




More information about the fpc-devel mailing list