openMP

Farmer axionator at gmail.com
Tue Oct 2 14:13:45 PDT 2012


And is there also a pragma omp critical analogon?

On Tuesday, 2 October 2012 at 20:16:36 UTC, Peter Alexander wrote:
> On Tuesday, 2 October 2012 at 19:15:19 UTC, Farmer wrote:
>> Hi,
>> I am tempted to start D programming but for me it is crucrial 
>> to be able to parallelize for-loops as can be done with openMP 
>> for C/C++ (mainly @pragma omp parallel for, @pragma omp 
>> critical).
>> I have already seen the std.parallelism library but I'm unsure 
>> whether it can provide me with the same functionality.
>>
>> Thanks
>
> It can. Here's an example from the docs of parallelising a 
> simple for loop:
>
> auto logs = new double[10_000_000];
> foreach(i, ref elem; taskPool.parallel(logs, 100))
> {
>     elem = log(i + 1.0);
> }
>
> This creates a pool of workers that each perform 100 iterations 
> of the loop body in parallel.




More information about the Digitalmars-d mailing list