[fpc-pascal] Threading vs Parallelism ?
ryan at thealchemistguild.com
Thu Mar 30 03:48:49 CEST 2017
> On Mar 30, 2017, at 4:25 AM, fredvs <fiens at hotmail.com> wrote:
>> how software parallelism ( in the sense of true simultaneous execution )
>> in a single process without using ( OS dependent ) threads can be achieved
> Huh, it is exactly was I do not understand...
Look at an OpenCL tutorial for more information. If you select a CPU device (instead of a GPU device with hundreds of compute units) then the API will automatically allocate the amount of threads available on the all cores available (which may be only 2). It’s still threaded but scales easily depending on the task. I don’t know why but I got the OpenCL CPU target to process multiple times faster than just using the CPU directly.
Parallelism is only helpful if you have a problem involving massive amounts of discrete tasks which are part of larger task and can be designed as such. If your problem is designed like this then you can offload the processing to the GPU and get some serious performance benefits. The catch is that reading/writing memory to the GPU is slow so unless you’re processing on large batches of data you’ll spend more time accessing memory than processing.
More information about the fpc-pascal