How do I construct a complex gpuArray directly on the GPU?
조회 수: 10 (최근 30일)
이전 댓글 표시
I am trying to initialize a complex gpuArray directly on the GPU (i.e. without first creating a complex array in host memory and then copying it over to the device).
So far the only thing I've found that works is:
foo = gpuArray(complex(0));
bar = zeros(4, 1, 'like',foo);
which seems kinda silly. Is there a way to allocate a complex gpuArray directly using something like gpuArray.zeros?
댓글 수: 0
채택된 답변
Edric Ellis
2017년 9월 12일
None of MATLAB's build methods (the zeros, ones family) build complex arrays, so the nearest you can get is to do something like:
complex(zeros(3, 'gpuArray'))
which never allocates any host memory, and results in a complex gpuArray.
댓글 수: 1
Jacob Lynch August
2018년 11월 9일
What about elements on the host that need to be transferred to the GPU, like
G = complex( gpuArray(V(:,1)), gpuArray(:,2) );
It seems silly to me to have those two temporary gpuArrays.
추가 답변 (1개)
KSSV
2017년 9월 12일
G = gpuArray(rand(10,1)+1i*rand(10,1));
댓글 수: 2
Jacob Lynch August
2018년 11월 9일
Alternatively:
complex(gpuArray.rand(size,type),gpuArray(size,type))
참고 항목
카테고리
Help Center 및 File Exchange에서 GPU Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!