Tuesday, 8 July 2008

GPULIB succes story (cont'd)

Regarding my last post, Peter Messmer at Tech-X pointed out to me that I should use gpuView rather than shifting subarrays around with gpuSubArr. Doesn't make things much faster in this case, but the code is nicer:

while i lt num_rows do begin
; ggi = GG[*,i*num_cols:(i+1)*num_cols-1]
gpuView,GG_gpu,i*num_cols*num_bands,$
num_bands*num_cols,ggi_gpu
gpuReform,ggi_gpu,num_bands,num_cols
; KK = transpose(G2)##(intarr(num_cols)+1)
gpuMatrix_Multiply,onesnc_gpu,G2_gpu,$
KK_gpu,/btranspose
; KK = KK + transpose(intarr(m)+1)##$
; GG2[i*num_cols:(i+1)*num_cols-1]
gpuView,GG2_gpu,i*num_cols,num_cols,gg2i_gpu
gpuMatrix_Multiply,gg2i_gpu,$
onesm_gpu,res_gpu,/btranspose
gpuAdd,KK_gpu,res_gpu,KK_gpu
; KK = KK - 2*G##transpose(ggi)
gpuMatrix_Multiply,ggi_gpu,G_gpu,$
res_gpu,/atranspose
gpuAdd,1.0,KK_gpu,-2.0,res_gpu,0.0,KK_gpu
; KK = exp(-gma*KK)
gpuExp,1.0,-gma,KK_gpu,0.0,0.0,KK_gpu
; image[*,i,*] = alpha[*,0:npc-1]##KK
gpuMatrix_Multiply,KK_gpu,alpha_gpu,res1_gpu
gpuGetArr,res1_gpu,res
image[*,i,*]=res
i++ ; next row
endwhile

With my new-found skills ;-) I want next to have a go at image clustering. If you cluster all of the pixel vectors in a multispectral image (typically millions) then things can get pretty slow.

1 comments:

toto said...

Hi,

I was excited by your "Kernel PCA" code under IDL and wanted to use it. Unfortunately I was not able to install the gpulib properly. This installation turns out to be painful and is a serious obstacle to use this code. Can anyone give me some advises ?

1. gpulib is difficult to download:
On the download page http://www.txcorp.com/products/GPULib/download-oss.php,the CAPTCHA security refused me several times before succes. I did not see why.

2. In the gpulib-1.0.6/README file, I learned that I would also need CUDA SDK and Toolkit from NVIDIA.

3. I downloaded CUDA SDK and Toolkit from NVIDIA for my Mac... and then I realised that it only works on leopard (the new Mac OS since few months). Bad luck: I work under Tiger (the previous Mac OS). That is weird: Tiger is still very popular

4. I made another try and installed CUDA SDK and Toolkit on a linux machine. Back to gpulib: During the installation, I get some error messages concerning "autoheader" and "automake" (and the installation is not complete)