Ok, so I followed your suggestions and the block size did the trick with
regards to using all 4 cores of mine...However, even so, I get no
performance improvements!!! It still needs close to 4 min to go to level
4 and it still needs 5-6 sec to go to level 2 (a tiny bit faster than
the sequential equivalent)...
Jim
On 22/08/12 13:33, Jim - FooBar(); wrote:
Hi again Nicolas,
1) My moves at the top are a result of r/map...I did try to pou it all
in a vector with 'nto []'
but nothing changes.
2)well, no there is no way to have 512 moves at any point in in the
game!!! The game actually starts with 20 branches (2 moves for each
pawn and 2 for each knight) but quickly goes up to 30, 40, 50 etc. I
will try your suggestion...
3)I'm not sure I understand what you mean...You're returning nil - I'm
returning a very small number, they can both be read by the next
branch don't they?
Jim
On 22/08/12 10:04, nicolas.o...@gmail.com wrote:
Hi,
3 questions:
1. Are you sure your moves list at the op level is in a vector?
Looking at the code for reducers, it seems that it is the only
implementation actually doing concurrency.
2. The default block size for spawning a new thread is 512. Meaning
that if you have
less than 512 first move in your game (quite likely, or else your
tree is too highly branching to do anything
by min-max anyway), then it is only working on one thread.
This is tuned for large data set with moderate amount of work per datum.
Exactly the opposite of your workload. (Only 20 datums, but a lot of
work per datum).
You will want to change the size of the block to something like 1,
2 or 3.
So your last line should look like that:
(defn best-move "Start folding here." [dir b d]
(r/fold 1 best best
(r/map #(Move-Value. (:move %) (search score-by-count (:tree %) d))
(:children (game-tree dir b
next-level)))))
3. I have doubte about your best function. The first branch should
return something that the second branch can read.
I suggest:
(defn best
([] nil)
([best1 best2]
(cond
(nil? best1) best2
(nil? best2) best1)
t (if (>= (:value best1) (:value best2))
best1 best2))))
With these modifications, it should run in // and be quite fast.
--
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