On Thursday, May 24, 2012 3:17:56 AM UTC-4, Cedric Greevey wrote:
>
> On Thu, May 24, 2012 at 3:00 AM, Sean Corfield wrote: 
> > On Wed, May 23, 2012 at 11:37 PM, Cedric Greevey wrote: 
> >> Replacing (range 10) with (take 10 (iterate inc 0)) didn't change 
> >> anything. It's still not parallelizing. 
> > 
> > My point was that when you replace (range 10) with (range 100) in your 
> > code, it prints numbers up to 31 and no more. You didn't try that, I 
> > presume? 
>
> Sounds like pmap is *really* broken. (doall (pmap identity x)) should 
> realize every element of x, surely, just like (doall x)? 
>
>  
Unfortunately (pmap identity ...) won't do what you want. The only 
computation that will be parallelized is the call to identity.

To pmap, the for-expression is a black box - just a seq - it cannot reach 
into it and parallelize its insides. It can only consume it sequentially.

The meat of pmap is this: (map #(future (f %)) coll)
That must produce each element of coll (in this case, the for-loop), in 
order, *before* passing it to future.


Also, pmap is not broken; the problem with the code you pasted is simply an 
errant closing paren. You had (do (doall (pmap ...) nil)), where you meant 
(do (doall (pmap ...)) nil). Apparently doall has a two-arg version, which 
is news to me :)


- Chris Perkins
 
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to