Am Mon, 5 Sep 2016 10:21:53 +0200 schrieb Andrei Alexandrescu <[email protected]>:
> On 9/5/16 7:08 AM, Manu via Digitalmars-d wrote: > > I mostly code like this now: > > data.map!(x => transform(x)).copy(output); > > > > It's convenient and reads nicely, but it's generally inefficient. > > What are the benchmarks and the numbers? What loss are you looking > at? -- Andrei As Manu posted this question (and he's working on a color/image library) it's not hard to guess one problem is SIMD/vectorization. E.g if transform(x) => x + 2; It is faster to perfom 1 SIMD operation on 4 values instead of 4 individual adds. As autovectorization is not very powerful in current compilers I can easily imagine that complex range based examples can't compete with hand-written SIMD loops. @Manu: Have you had a look at std.parallelism? I think it has some kind of parallel map which could provide some inspiration?
