I have not looked at pmap yet, but I expect it will be a better fit, since Monte Carlo is a good fit for Fork/Join.
I am considering using this example across a variety of implementation strategies for the concurrency chapter in the book. Aside from agents and pmap, any other approaches spring to mind? Stuart P.S. I think that is the second time you have had to tell me to stop using "count" as a local name. Bad habits die slowly... :-) > On Mon, Oct 27, 2008 at 10:06 PM, Stuart Halloway > <[EMAIL PROTECTED]> wrote: >> >> The code below implements a Monte Carlo simulation to estimate the >> value of pi. It works, and it was easy to reuse the original single- >> threaded approach across multiple agents. >> >> How idiomatic is this use of agents? Other than bringing in ForkJoin, >> are there other idiomatic ways to parallelize divide-and-conquer in >> Clojure? > > Did you look at pmap? You might be able to use something like (pmap > (fn [_] (sample-for-pi count)) (range count)), and then use that in > your guess-from-samples reduce. I'm thinking this might be better > because it would handle more of the work: scaling to the number of > CPUs, launching the agents, waiting for the results. I'm not sure > it's a perfect fit -- perhaps pmap adds unneeded overhead. > > BTW, using "count" as a local name can cause surprises later when > someone tries to use the clojure/count function. > > --Chouser > > > --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---