is there any substitute for "gather" function in MATLAB?

조회 수: 1 (최근 30일)
nelson
nelson 2017년 8월 3일
댓글: Joss Knight 2017년 8월 3일
tic
k = gpuArray(1:0.5:10);
a = gpuArray(1:0.5:10);
n1 = numel(k);
nump = kron(k, ones(1, length(a)))';
n2 = numel(a);
denp = repmat([ones(n2,1), a.', zeros(n2,1)], n1, 1);
w = gpuArray([0.1 0.5 1 5 10 20 30 50 70 100]);
%%%%%% freqcp %%%%%%%%%%%%%%%%%%%%
delay = 0;
w = w(:)';
s = 1i * w;
upper = nump(:, 1);
for i = 2:size(nump, 2)
upper = bsxfun(@plus, bsxfun(@times, s, upper), nump(:, i));
end
lower = denp(:, 1);
for i = 2:size(denp, 2)
lower = bsxfun(@plus, bsxfun(@times, s, lower), denp(:, i));
end
P = bsxfun(@times, bsxfun(@rdivide, upper, lower), exp(-s * delay));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p=gather(P);
  댓글 수: 6
José-Luis
José-Luis 2017년 8월 3일
편집: José-Luis 2017년 8월 3일
Yes, thanks for the correction. I will die in acronym hell.
I've never actually used OpenGL and since it is low-level graphics then it probably has ways of interacting with the GPU. I'll google that out of curiosity... eventually.
Joss Knight
Joss Knight 2017년 8월 3일
The alternative to gather is to not call gather and just leave your data on the GPU. Don't move your data around unless you need to display it, save it, or run some code on it that doesn't support gpuArray.
People often blame gather for all ills because it appears to be very slow, but what's really happening is that in order for the data to be copied to the host, MATLAB has to wait for all the asynchronous operations currently queued on the device to finish. Sometimes that makes it look like gather is being slow.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by