for loop and data in GPU memory
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
If the for loop is parallelizable, does the Parallel Computing Toolbox execute for loop in a parallel fashion when it is acting on data stored in GPU memory?
2 comentarios
Jill Reese
el 8 de Nov. de 2012
It would be a bit easier to answer your question if you provided some sample code.
Thanks, Jill
Respuesta aceptada
Jill Reese
el 9 de Nov. de 2012
The for loop is not performed in parallel when you write code like this:
A = gpuArray(X);
for i = 1:length(A)
B(i) = f(A(i));
end
However, if your function f contains only elementwise operations, then you could achieve more parallelism by using arrayfun like so:
B = arrayfun(@f, A);
0 comentarios
Más respuestas (0)
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!