map! filter! and range algorithm

Ali Çehreli acehreli at yahoo.com
Mon Mar 4 13:22:36 PST 2013


On 03/04/2013 12:06 PM, Andrea Fontana wrote:
> If I understand it correctly something like:
>
> range.filter!(...).map!(...)
>
> browse range 2 times, one for filter and one for mapping doesn't it?
>
> Is there a way to "parallelize" this kind of operations?
>

std.parallelism has lots of cool features to help with range 
parallelization. Here is map:

   http://dlang.org/phobos/std_parallelism.html#.TaskPool.map

There are some examples of mine at

   http://ddili.org/ders/d.en/parallelism.html

Here is an excerpt from the Summary section at that link:

- parallel() executes the iterations of foreach loops in parallel.

- asyncBuf() iterates the elements of an InputRange semi-eagerly in 
parallel.

- map() calls functions with the elements of an InputRange semi-eagerly 
in parallel.

- amap() calls functions with the elements of a RandomAccessRange 
fully-eagerly in parallel.

- reduce() makes calculations over the elements of a RandomAccessRange 
in parallel.

Ali


More information about the Digitalmars-d-learn mailing list