On Jan 14, 8:27 am, Asbjørn Bjørnstad <asbj...@gmail.com> wrote: > Anyway, here is a core part of the algorithm. It's a diffusion > step, this gets called 3 times and in total this takes up more than > one second of cpu time on my machine which makes framerates very > slow. If anyone got any improvements I'd be happy to hear about it:
Here are a few possibilities: 1. Java 2-D, 3-D, etc. arrays are implemented as arrays of (arrays of ... pointers), which hurts spatial locality. It was enough of a problem that I've seen people reimplement 2-D arrays using 1-D arrays. You might consider using a 1-D array and taking the trouble to do the indexing by hand. Of course only a benchmark can tell whether it really helps. 2. It looks like your inner loop is iterating over the first index of the array (is that right?), which is good for Fortran but bad for Java. Java 2-D arrays are row-oriented. In your inner loop, you should iterate such that successive array values are stored adjacent to each other in memory. 3. I noticed you are doing 20 iterations of Gauss-Seidel. There are some smart ways to speed up multiple stencil applications. I can point you to references if you are interested. Fun to see numeric codes in Clojure! ;-) mfh --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---