I don't know why David set a work unit of 100 for a 1 million element
array. I get slow results for this example:
foreach(i, ref elem; taskPool.parallel(logs, 100)) {
elem = log(i + 1.0);
}
CPUs : 4
Serial usecs: 70418.
Parallel usecs: 91519.
But if I up the work unit size to 10
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 =
On 06/23/2011 02:27 AM, Dainius (GreatEmerald) wrote:
I have a related enhancement request since lot of time:
http://d.puremagic.com/issues/show_bug.cgi?id=4716
Bye,
bearophile
That's exactly what I'd like to see. Voted.
After all, D is created with practicality in mind, and doing all that
p
Zardoz wrote:
const num = 10;
>
foreach (t; 0..num) {
foreach(i, ref elem; taskPool.parallel(logs, 100)) {
elem = log(i + 1.0);
}
}
I think you just spawned 10 tasks. Look at foreach (t; 0..num).
Ok, so why in std.parallelism examples are this :
// Same thing, but use the default work unit size.
//
// Timings on an Athlon 64 X2 dual core machine:
//
// Parallel foreach: 388 milliseconds
// Regular foreach: 619 milliseconds
foreach(i, ref elem; taskPool.parallel(l
On 23/06/2011 11:05, Zardoz wrote:
I'm trying std.parallelism, and I made this code (based over foreach parallel
example) :
import std.stdio;
import std.parallelism;
import std.math;
import std.c.time;
void main () {
auto logs = new double[20_000_000];
const num = 10;
I'm trying std.parallelism, and I made this code (based over foreach parallel
example) :
import std.stdio;
import std.parallelism;
import std.math;
import std.c.time;
void main () {
auto logs = new double[20_000_000];
const num = 10;
clock_t clk;
> I have a related enhancement request since lot of time:
> http://d.puremagic.com/issues/show_bug.cgi?id=4716
>
> Bye,
> bearophile
>
That's exactly what I'd like to see. Voted.
After all, D is created with practicality in mind, and doing all that
parsing is the opposite of what it's trying to a