[Cs254f11] pmap problem

Wm. Josiah Erikson wjerikson at hampshire.edu
Mon Nov 21 15:48:47 EST 2011


Oh. That's the easiest thing in the world. clojure.contrib.string went 
to clojure.string, so all I had to do is change:

(require '[clojure.contrib.string :as string])

to:

(require '[clojure.string :as string])

...and then discover that ltrim was gone and I had to use trim instead, 
and they changed the order of the arguments to split. Whatever. I'm back 
in business, using clooj 0.2.6.... and I see as much as 325% processor 
utilization with pmap, but my benchmarks don't show a clear advantage 
with a popsize of 1000 where each member is just "random-code 2". 
However, it shows a very clear advantage when the population is composed 
of larger individuals whose error takes more time to compute (pmap: 
average ~6s vs map: average ~9s with individuals being comprised of 
"random-code 5", population size 1000)

Now to rewrite evolution so that I can use trivial geography :)

     -Josiah



On 11/21/11 2:58 PM, Lee Spector wrote:
> [ I'm echoing to the list, since some others were watching this and may be interested. ]
>
> Very interesting. Looks like it is indeed an eval/pmap interaction bug, but that it has been fixed; I'm pretty sure from what you say that it must be fixed in Clojure 1.3, and that clooj 0.2.6 is working just because it uses Clojure 1.3.
>
> On getting the string stuff to work in 1.3: the whole idea of contrib has changed radically in Clojure 1.3, which is one of the reasons that I didn't want to deal with the transition mid semester. But all of the important functionality still exists, just not in a big "monolithic" contrib JAR, but rather in smaller libraries. I haven't dealt with this myself but I'm pretty sure that clojure.contrib.string stuff will be easily accessible, but in a slightly different way (and you'll need to use leiningen to pull in the library. For details I'd start here:
>
> http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
>
>   -Lee
>
>
> On Nov 21, 2011, at 2:45 PM, Wm. Josiah Erikson wrote:
>
>> So here is an extremely simple example of the problem:
>>
>> (defn pd
>>   "Protected division; returns 0 if the denominator is zero."
>>   [num denom]
>>   (if (zero? denom)
>>     0
>>     (/ num denom)))
>> ;#'critic_evolution.core/pd
>>
>> (def sample-vector ['(pd 5 6) '(+ 5 6)])
>> ;#'critic_evolution.core/sample-vector
>> sample-vector
>> ;[(pd 5 6) (+ 5 6)]
>> (map eval sample-vector)
>> ;(5/6 11)
>> (pmap eval sample-vector)
>> ;#<Exception java.lang.Exception: Unable to resolve symbol: pd in this context>
>>
>> Also, I have "solved" the problem. Maybe Arthur won't care that this is a problem, because the problem does not exist in Clooj 0.2.6 - does that make it a clojure problem and not a clooj problem?
>>
>> I tried just moving my code to clooj 0.2.6, but my clojure.contrib.string broke:
>> critic_evolution.core=>#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/contrib/string__init.class or clojure/contrib/string.clj on classpath:>
>>
>> I can probably figure that out, though... maybe it's called something else now.
>>
>> -- 
>> Wm. Josiah Erikson
>> Network Engineer
>> Hampshire College
>> Amherst, MA 01002
>> (413) 559-6091
>>
> --
> Lee Spector, Professor of Computer Science
> Cognitive Science, Hampshire College
> 893 West Street, Amherst, MA 01002-3359
> lspector at hampshire.edu, http://hampshire.edu/lspector/
> Phone: 413-559-5352, Fax: 413-559-5438
>

-- 
Wm. Josiah Erikson
Network Engineer
Hampshire College
Amherst, MA 01002
(413) 559-6091



More information about the Cs254f11 mailing list