Suitability of parallel computing?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
I want to make this code run as fast as possible:
f1=[50 20 3 -50 -27]*(1000000); %frequency
p1=[10 200 50 9 0]; %phase
a1=[1 0.2 0.7 0.5 0.1]; % amplitude
s=1000000;
tot=s/max(abs(f1))*2.5;
t=linspace(0 ,tot ,s);
x=zeros(length(f1),s);
x=f1'*t;
y=repmat(p1',1,s);
I=a1*sin((2*pi*x)+y);
Q=a1*cos((2*pi*x)+y);
Is this the sort of problem where using parallel computing could help?
댓글 수: 0
답변 (1개)
Edric Ellis
2015년 3월 30일
편집: Edric Ellis
2015년 3월 30일
You could use the gpuArray support from PCT to perform this calculation. On my machine, this runs about 15x faster. (I have a fairly old Tesla C2070 GPU, and a quad-core CPU). Here's what I timed:
d = gpuDevice();
tic
x=gpuArray(f1)' * gpuArray.linspace(0, tot, s);
y=gpuArray(p1');
I2=a1 * arrayfun(@(xx,yy) sin((2*pi*xx)+yy), x, y);
Q2=a1 * arrayfun(@(xx,yy) cos((2*pi*xx)+yy), x, y);
wait(d);
toc
Note that it's unlikely that using parfor or spmd will speed this computation up much since the CPU computation is already intrinsically multi-threaded by MATLAB.
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!