MATLAB: GPU processing slower that CPU

gpu

Hello to all!
This is my first question here! I run a code for image processing and I try to implement this on GPU arrays in order to reduce time. The main part of code is below. When I execute loaded all matrixes as gpuArrays, it takes much longer than using it with simple arrays on workspace. I'm very new on GPU processing and this is my first try. Can someone explain to me about this delay?
Thank you a lot
PS: I'm using Matlab R2013a on a Macbook pro
for i = 1:dim(1)
for j = 1:dim(2)
iMin = max(i-w,1);
iMax = min(i+w,dim(1));
jMin = max(j-w,1);
jMax = min(j+w,dim(2));
I = A(iMin:iMax,jMin:jMax);
H = exp(-(I-A(i,j)).^2/(2*sigma_r^2));
F = H.*G((iMin:iMax)-i+w+1,(jMin:jMax)-j+w+1);
B(i,j) = sum(F(:).*I(:))/sum(F(:));
end
end

Best Answer

Relocated to Comment by Matt J