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
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);}
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
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,
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():