For a completely different way of doing this, you could certainly use GPGPU programming to speed this up.
This section: (aset diffused-grid c (float (/ (+ (aget grid c) (* a (+ (+ (aget diffused-grid (dec c)) (aget diffused-grid (inc c))) (+ (aget diffused-grid (- c line-length)) (aget diffused-grid (+ c line-length))))) looks a lot to me like what any blending or bloom pixel shader does. If you are doing large grids (like 4000x1000) then you can't beat CUDA for something like this. Those four lookups would most likely all be in texture cache as texture cache is spatially managed (i.e. function of both x and y). You mentioned frame rate anyway, just read the framebuffer back after the render call and you can work with the next step of your iteration. You want this for a game engine anyway; do it in opengl or directx using shaders. Chris On Jan 14, 1:04 pm, Chouser <chou...@gmail.com> wrote: > On Wed, Jan 14, 2009 at 11: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: > > Not sure if it makes for this algorithm, but there are faster (and > less safe) versions of several functions you're using. Check the > output of (find-doc "unchecked") > > While I think your loop-local 'c' will be a primitive int, I'm not > entirely sure -- might be worth trying (int (unchecked-add x > line-offset)). Same thing on line-offset, not sure it's a primitive. > > --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---