Undefined function or variable
조회 수: 4 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Andy
2012년 7월 3일
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
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 GPU Computing in MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!