Thursday, 10 July 2008

GPULIB (trip to never-neverland)

I seem to be making a little progress with the clustering algorithm. One problem is that I have to invert a covariance matrix on each iteration, which means jumping back to the CPU to do it. This probably slows things down. Doesn't CUBLAS provide matrix inversion?

Anyway, while coding I stumbled into a horrible trap:

gpuPutArr,A,A_gpu
gpuView,A_gpu,n,m,Av_gpu
;...
;lots of code, so I kind of forgot
;what Av_gpu is
;...
gpuFree,A_gpu
gpuFree,Av_gpu ; very, very bad thing to do

This put me Somewhere Over the Rainbow. Nothing, but nothing works anymore on the GPU until I exit IDL and restart. Took a long time to get back to earth. Incidently, another way to get up there with Judy Garland is to forget that

gpuWhere,A_gpu,ind_gpu,count

overwrites A_gpu.

4 comments:

topher hughes said...

So from the looks of it you're a much better programmer than I, but, I did had to do the same thing. I used a call to correlate to get covariance of my matrix, and then a call to invert. For as often as I have to call that for my clustering (ISODATA + mahalnobis distance for the distance measurement), that particular procedure never slowed things down.

topher hughes said...

And having now read over much more of your blog, I realize just how dumb my comment is. =-) I'd be very interested to see how much of a speedup you get. I'm willing to invest in a nice video card for my computer if it can make my clustering go faster!

Mort Canty said...

So far only about a factor of two speedup, so maybe not yet worth your investment. Apart from matrix inversion, there are some other bread-and-butter things which you can't yet do on the GPU (at least I don't think you can), such as the equivalent of

A[index_array] = B

But I'm still learning and Tech-X is still developing :-)

messmer said...

We do have support for subscripting LHS, but it's not yet part of the distribution. If you need it, just send me an email and I can send you the fix.