ndslice, using a slice in place of T[] in template parameters

Jay Norwood via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 10 16:39:04 PST 2016


On Sunday, 10 January 2016 at 23:31:47 UTC, Ilya Yaroshenko wrote:
> Just use normal arrays for buffer (median accepts array on 
> second argument for optimisation reasons).

ok, I think I see. I created a slice(numTasks, bigd) over an 
allocated double[] dbuf, but slb[task] will be returning some 
struct instead of the double[] that i need in this case.

If I add .array to the Slice, it does compile, and executes, but 
slower than using the buffer directly.

medians[i] = median(vec, slb[task].array);
parallel time medians msec:113

original version using the computed slice of the original 
allocated dbuf.
medians[i] = median(vec,dbuf[j .. k]);
parallel time medians msec:85

The .array appears to make a copy. Is there some other call in 
ndslice to return the double[] slice of the original array?



More information about the Digitalmars-d-learn mailing list