two - loop with GPU
2 views (last 30 days)
I just have GPU on my desktop with matlab R2012b I plotted a Gaussian profile using two - loop on CPUas below:
I read somewhere that GPU does not support index like that, I even tried but it not work either. Is there any way possible to do the same thing on GPU?
Thank so much
James Lebak on 23 Apr 2013
Yes, 1:gpuArray(N) for scalar N doesn't work in MATLAB R2013a. Try the following:
G = exp(-((x.*x).'*gpuArray.ones(1,N)+gpuArray.ones(N,1)*(y.*y)))./(w^2);
This vectorizes the calculation of x and y and calculates all the elements in the matrix at once, which should be much more efficient on the GPU than using a loop.