gpu computing and parallel computing (vectorize code)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, again I am coming back as having simple example.
At first, I want to speed up using parallel tool box like CPU multicore and GPU computing(Quadro M6000)
But I can't improve my code to speed up using them
I think the reasion is while loop (iteration) .
Please give me genious idea
N Particles simultaneously are computed in the while loop
If you have nice idea about speeding up using GPU (Euler method computing through while loop),
overall, you can modify this code; remove while loop or use good function to solve Euler with gpu.
tic;
gd = gpuDevice();
S = gpuArray(linspace(0, 100, 1E3));
% S = linspace(0, 100, 1E3);
b = arrayfun(@(x) plus_(x),S);
toc;
function b = plus_(a)
dt = 1E-1;
j = 0;
while a < 1E4
j = j + 1;
a = a + j * dt;
end
b = a;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!