Regarding the speed optimizations, execution time for a given model was
reduced from 2735 seconds to 70 seconds, over several versions by doing
several optimizations.
The same calculation implemented in C# takes 12 seconds using the same
computer and OS. Maybe the Clojure code can still be improved, but for the
time being I'm happy with the Clojure version being six times slower, since
the new software has many advantages.
For these tests the model was the circle with radius 1 using the "diffmr1"
tracker, the simulation was run using 10000 particles and 10000 total
random walk steps.
These modifications in the critical parts of the code accounted for most of
the improvement:
- Avoid reflection by using type hints.
- Use Java arrays.
- In some cases call Java arithmetic functions directly instead of Clojure
ones.
- Avoid using partial functions in the critical parts of the code.
Avoiding lazyness did not help much. Regarding the use of Java arrays,
there are many small functions performing typical vector operations on
arrays, such as the following example:
Using Clojure types:
(defn dot-prod
"Returns the dot product of two vectors"
[v1 v2]
(reduce + (map * v1 v2)))
Using Java arrays:
(defn dot-prod-j
"Returns the dot product of two arrays of doubles"
[^doubles v1 ^doubles v2]
(areduce v1 i ret 0.0
(+ ret (* (aget v1 i)
(aget v2 i)))))
This gives a general idea of which optimizations helped the most. These
changes are not in the public repository, since previous commits have been
omitted because the code code was not ready for publication (different
license disclaimer, contained email addresses, etc.). If anyone is
interested in the diffs and the execution times over several optimizations,
please contact me.
Kind regards,
Jose.
On Sunday, December 21, 2014 3:38:35 AM UTC-5, Jose M. Perez Sanchez wrote:
>
>
> Hi everyone:
>
> Sorry that it has taken so long. I've just released the software in
> GitHub under the EPL. It can be found at:
>
> https://github.com/iosephus/gema
>
>
> Kind regards,
>
> Jose.
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.