error when using gpu

조회 수: 2 (최근 30일)
Mate 2u
Mate 2u 2012년 5월 21일
Hi this is the part of code which troubles me:
for j=1:length(ZZ)
array(:,index) = A(ZZ(j)+n:ZZ(j)+n+x-1);
index=index+1;
end
The error I get is:
Undefined function 'colon' for input arguments of type 'parallel.gpu.GPUArray'.
Any help?

채택된 답변

Ben Tordoff
Ben Tordoff 2012년 5월 24일
Unfortunately, an expression like:
gpuArray(1):gpuArray(10)
won't work, and (as Walter says) it looks like one of your ":" expressions involves an argument that is a gpuArray. You have two choices. If you want the result of the ":" to be on the GPU you have to say so explicitly:
tmp = parallel.gpu.GPUArray.colon(ZZ(j)+n, ZZ(j)+n+x-1);
array(:,index) = A(tmp);
If you prefer the result in host memory, gather it first:
tmp = colon(gather(ZZ(j)+n), gather(ZZ(j)+n+x-1));
array(:,index) = A(tmp);
The result should be the same either way, but you may find one faster than the other depending on your data size, hardware and MATLAB release.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 21일
This implies that ZZ or n are located on the GPU, with the result that ZZ(j)+n is a GPU object. The ":" operator cannot deal with GPU objects.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by