Undefined function or variable

2 views (last 30 days)
selim
selim on 2 Jul 2012
Hello,
I'm trying to improve my code execution speed by using GPU, here is my code :
.
......
size_mat=size(ind_mat,1);
tryy=gpuArray(tryy);
ind_mat=gpuArray(ind_mat);
tryy=arrayfun(@aGpuFunction, tryy, ind_mat,size_mat);
sinogram = tryy;
sinogram = gather(sinogram);
.......
And the function:
.
function tryy = aGpuFunction(tryy,ind_mat,size_mat)
for k=1:size_mat
if( ind_mat(k,2)~=1&&ind_mat(k,3)~=4008&&ind_mat(k,1)~=1&&ind_mat(k,1)~=4500)
tryy(ind_mat(k,1),ind_mat(k,2))=(tryy(ind_mat(k,1)-1,ind_mat(k,2))+tryy(ind_mat(k,1)+1,ind_mat(k,2))+tryy(ind_mat(k,1),ind_mat(k,2)-1))./3;
tryy(ind_mat(k,1),ind_mat(k,3))=(tryy(ind_mat(k,1)-1,ind_mat(k,3))+tryy(ind_mat(k,1)+1,ind_mat(k,3))+tryy(ind_mat(k,1),ind_mat(k,3)+1))./3;
end
end
When I execute my code, i got the following error :
Error using parallel.gpu.GPUArray/arrayfun
Undefined function or variable 'k'.
Error in antispeckle_filter (line 22)
tryy=arrayfun(@aGpuFunction, tryy, ind_mat,size_mat);
I'm stuck here... Does anyone got an idee ?
Thanks!
Selim

Accepted Answer

Andy
Andy on 3 Jul 2012
hello Selim,
sorry for the poor error message. it will be improved in a future release.
the main problem with the MATLAB code you are trying to evaluate via arrayfun is it does indexing. currently, indexing is not supported for functions being evaluated by arrayfun as discussed in the doc.
the following link is a good place to start exploring PCT's GPU offering, http://www.mathworks.com/help/toolbox/distcomp/bsic4n4-1.html
for more specific information about arrayfun on the GPU a good place to start is, http://www.mathworks.com/help/toolbox/distcomp/arrayfun.html
thanks,
Andy

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!