Re: Using parallellisation

2014-04-11 Thread Cecil Westerhof
2014-04-11 3:10 GMT+02:00 Andy Fingerhut andy.finger...@gmail.com: Your check-concurrent2 is a much better way to use parallelism in your program -- create a few threads, each of which does a lot of work. I haven't analyzed the values you are computing in detail, but note that your program

Re: Using parallellisation

2014-04-11 Thread atucker
I haven't tried it, but for parallelisation it's sometimes worth starting from more array-oriented code, e.g. (defn max-diff [check-until] (let [val (map #(Math/sqrt %) (range 1 check-until))] (reduce max (map #(Math/abs (- %1 %2)) (map #(Math/pow % 2) val) (map #(* % %) val) On

Using parallellisation

2014-04-10 Thread Cecil Westerhof
I have the following in my code: (let [val (Math/sqrt i) diff (Math/abs (- (Math/pow val 2) (* val val)))] I expect that calculating the difference is the most expensive part of my code. I understood that Clojure is very good in parallellisation. How would I let (Math/pow val

Re: Using parallellisation

2014-04-10 Thread Andy Fingerhut
Forcing small bits of computation to be done in parallel using the tools Clojure and the JVM have at hand, e.g. pmap, future, etc., which rely on creating JVM Thread objects, tends to slow things down rather than speed things up, because the extra overhead of creating threads and waiting for them

Re: Using parallellisation

2014-04-10 Thread Timothy Baldridge
Some would also argue that any parallelism system is going to slow down code as trivial as this. Never underestimate the power of properly optimized single threaded code :-). But yes, futures are the way to go if you want to execute a given expression on a different thread. On Thu, Apr 10, 2014

Re: Using parallellisation

2014-04-10 Thread Cecil Westerhof
2014-04-10 16:45 GMT+02:00 Andy Fingerhut andy.finger...@gmail.com: Forcing small bits of computation to be done in parallel using the tools Clojure and the JVM have at hand, e.g. pmap, future, etc., which rely on creating JVM Thread objects, tends to slow things down rather than speed things

Re: Using parallellisation

2014-04-10 Thread Andy Fingerhut
Your check-concurrent2 is a much better way to use parallelism in your program -- create a few threads, each of which does a lot of work. I haven't analyzed the values you are computing in detail, but note that your program still has lots of inter-thread 'communication' because of the use of a