gpu computing and parallel computing (vectorize code)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!