gpu computing and parallel computing (vectorize code)
Afficher commentaires plus anciens
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
Réponses (1)
b=max(0, floor( (1e4-S)/dt) )*dt + S;
Catégories
En savoir plus sur GPU Computing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!