Ok, I finally got around to tackling most of this. See individual replies below.

On 1/1/2011 6:07 PM, Andrei Alexandrescu wrote:
I think David Simcha's library is close to reviewable form. Code:

http://dsource.org/projects/scrapple/browser/trunk/parallelFuture/std_parallelism.d


Documentation:

http://cis.jhu.edu/~dsimcha/d/phobos/std_parallelism.html

Here are a few comments:

* parallel is templated on range, but not on operation. Does this affect
speed for brief operations (such as the one given in the example,
squares[i] = i * i)? I wonder if using an alias wouldn't be more
appropriate. Some performance numbers would be very useful in any case.

As I've said before, I strongly believe it's not worth it to give up the features (ref iteration, index variables, consistency with non-parallel syntax) that opApply offers, given that we also have map() and the performance hit is only a small constant that only matters for very fine-grained parallelism. (I've shown it to be pretty small in absolute terms with benchmarks. See previous posts.)


* Why is ThreadPool a class and what are the prospects of overriding its
members?


Made it final.  Done.

* Can't we define the behavior of break inside a parallel loop?

Done. It now aborts the current work unit. A goto from inside the loop to outside the loop is still undefined, though, because it makes even less sense and raises the possibility of conflicting gotos from different threads.


* I think it does make sense to evaluate a parallel map lazily by using
a finite buffer. Generally map looks the most promising so it may be
worth investing some more work in it to make it "smart lazy".

I have added LazyMap, which rotates two buffers of a user-specified size and computes the map functions and dumps them to the back buffer while making the front buffer available via front() and popFront(). One can also achieve pipelining by chaining LazyMap objects.


* waitStop() -> join()?

Done.


* The documentation should use more examples. Currently it uses entities
without defining them (Task, TaskPool etc.)

Can you elaborate on this? I am having trouble thinking of things to add to the docs.

* why runCallable()? There's no runUncallable().

I made this into run().


* Should there be a makeAngel to undo makeDaemon?

Done.  Added makeAngel.


Reply via email to