Java, FFT, Stuff
Just received what appears to be Intel hiring spam on the Beagleboard list. I hope technology like the beagleboard eventually wipes their sorry criminal arses off the planet, the last thing I want is to hear about their stinking jobs.
Anyway. Java n stuff.
I kept working on my prototype and added the Apache Maths library mostly because I wanted a simple Complex type that was supposedly written by Java people who know how to write such things. Got a bunch of algorithms converted and just ran it a few times looking at the printf's just to admire my handiwork.
Then I saw the profiler button and thought what the hell, lets see how it works. Well apart from being pretty friggan kick-arse (I can't even remember the last time I ran a profiler over C, but I can tell you it sucked - Visual Studio had absolutely naught without 'paying extra' for some shareware crap) I noticed huge bottlenecks all over the place. For one my image loading was taking about 70% of the time (loads 10 images, does a few fft's over part of them). Well I was flying blind on that one so made a bit of a mess of it. Anyway, did something about that .. next ... the complex arithmetic and the array references were taking all the time. SST arrays are accessed through multi-dimensional capable getters, which are abstracted a couple of levels to an index calculation that loops over an array of strides. Yes very efficient. For some reason I imagined the 'hotspot' compiler could remove all that, but alas it cannot.
Anyway ... to cut a long and rather boring story short, I've thrown away apache.maths's Complex type and written my own that has mutable elements and is used just to hold values. I found a decent FFT library in Java and since that was pretty much the only reason I was using SST I also got rid of that and wrote my own 2D array classes, and re-wrote most of the code to use simple one-dimensional arrays directly.
Man it's ugly code - but it was pretty fugly using apache.maths.complex too - the C is much, much cleaner for the inner loops. For all that it's about 10x faster than it was and on par roughly with the C code (don't quite have the same processing to really compare yet), which i think is worth it. Even if it took most of the day, although I cleaned stuff up as I went too so it wasn't wasted. Well i'm about where I was with the C a week ago, but in the meantime there's been a 4 day long-weekend and now I can easily add GUI. I looked at gtk+ very briefly but it just looked like no fun at all. And besides being cross platform at this point is a big plus.
So along the way I found JTransforms - this is the nice Java FFT library. I'm not sure why it took so long to find - I looked all over the place and all I could find were dinky little implementations. And lots of people looking for decent implementations. And really old stuff. Maybe it's the age of Java, or maybe google just failed me yet again as a search service.Another tool I found along the way was ImageJ - actually I'd looked at it a few weeks ago but not in any great detail. The AWT interface is a bit clunky, but it is pretty fast. From that I worked out how to access the image buffers directly so sped up my image loading about 100x (well I was using 'getpixel' basically, now just a byte array directly). I don't really know if the gimp's implementations are particularly good/bad/or whatever, but doing the same sized guassian filter for example over a 1024x768 image noticeably faster in ImageJ.
... Visual Studio ...
... a rotting pile ofpig shit
Oh here's a funny thing which will probably be very easy to get used to. In the debugger (or even running the code), `fatal' errors like array bounds exceptions don't mean the end of execution. Oh yes I know, welcome to the late 90s, but .NET in VS was a pig, nay a bloaty fat diseased pig, oh lets not mince words; a rotting pile of pig shit, when trying to debug, and fatal errors were fatal too, so I forgot it doesn't have to be that way in so-called 'modern' languages. Not that Netbeans has been too kind to me, I've had a few pointer grabs and it brought system down twice (or maybe SELinux did in its own 'denial of service' attack for added security, if i understood the stack trace at all - it's now disabled), one pointer grab required hitting the power button to reboot, and the other required the reset button as trying to run any programme ended in an oops. Not having much luck debugging threaded code either (it just 'vanishes' if it has a fatal error).
Oh yeah and so much for getting some dry-work done in the back yard. Later that night it started bucketing down, and bucketing down, and it then rained a lot - around 32mm in a few hours - a lot of rain for here, and particularly loud on a tin roof. Barely a drop for months and then all that. The yard is still totally soaked 2 days later.