WTF! Parallel foreach more slower that normal foreach in multicore CPU ?

Zardoz luis.panadero at gmail.com
Thu Jun 23 16:18:36 PDT 2011


Code :
 auto logs = new double[200];
 const num = 2;
 clock_t clk;
 double norm;
 double par;
 writeln("CPUs : ",totalCPUs );
 clk = clock();
 foreach(i, ref elem; logs) {
  elem = log(i + 1.0);
 }
 norm = clock() -clk;
 clk = clock();
 foreach(i, ref elem; taskPool.parallel(logs, 100)) {
  elem = log(i + 1.0);
 }

I get same problem. Parallel foreach, is more slower that normal
foreach. And it's same code that hace lib example that claims that
parallel foreach do it in aprox. half time in Athlon X2


More information about the Digitalmars-d-learn mailing list