How works internally ParallelForEach
Zardoz
luis.panadero at gmail.com
Sat Dec 1 02:35:37 PST 2012
How works internally ParallelFor ?
I read that lauchn multiple tasks. Each task procces a chunk of
the range, but each task it's syncronized , ahve some kind of
comunication between or are using shared memory or what ??
In this example code :
import std.stdio;
import std.parallelism;
import std.math;
void main() {
auto logs = new double[10_000_000];
double total = 0;
foreach(i, ref elem; taskPool.parallel(logs, 100)) {
elem = log(i + 1.0);
total += elem;
}
writeln(total);
}
I understand that are launched N task, doing a chunk of 100
elements from logs array. But what happen with "total". There is
only a "total" and D is using memory barriers / atomic operations
to write in it ? Or each Task have his own "total" and later
joint each private "total" in the outside "total".
More information about the Digitalmars-d-learn
mailing list