each! vs foreach parallel timings

2015-12-27 Thread Jay Norwood via Digitalmars-d-learn
I'm doing some re-writing and measuring. The basic task is to take 10K samples (in struct S samples below) and calculate some metrics (just per sample for now). It isn't evident to me how to write the parallel foreach in the same format as each!, so I just used the loop form that I

Re: each! vs foreach parallel timings

2015-12-27 Thread Ali Çehreli via Digitalmars-d-learn
On 12/27/2015 04:17 PM, Jay Norwood wrote: On Sunday, 27 December 2015 at 23:42:57 UTC, Ali Çehreli wrote: That does not compile because i is size_t but apply_metrics() takes an int. One solution is to call to!int: foreach( i, ref a; parallel(samples[])){ apply_metrics(i.to!int,a);}

Re: each! vs foreach parallel timings

2015-12-27 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 27 December 2015 at 23:42:57 UTC, Ali Çehreli wrote: On 12/27/2015 11:30 AM, Jay Norwood wrote: > samples[].each!((int i, ref a)=>apply_metrics(i,a)); Are you using an older compiler? That tuple expansion does not work any more at least with dmd v2.069.0 but you can use

Re: each! vs foreach parallel timings

2015-12-27 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 27 December 2015 at 23:42:57 UTC, Ali Çehreli wrote: That does not compile because i is size_t but apply_metrics() takes an int. One solution is to call to!int: foreach( i, ref a; parallel(samples[])){ apply_metrics(i.to!int,a);} It builds for me still, and executes ok,

Re: each! vs foreach parallel timings

2015-12-27 Thread Ali Çehreli via Digitalmars-d-learn
On 12/27/2015 11:30 AM, Jay Norwood wrote: > samples[].each!((int i, ref a)=>apply_metrics(i,a)); Are you using an older compiler? That tuple expansion does not work any more at least with dmd v2.069.0 but you can use enumerate():