How to output a vector that is the sum of each slice or page from a 3D array on GPU
Mostrar comentarios más antiguos
i7 quadcore, GTX Geforce 960 running CUDA driver, Matlab 2014b
My process I am trying to accomplish:
- Send a 3D array to the GPU
- Distribute each 'page' (:,:,i) for summing on the GPU
- Return the output vector to the CPU
% My stab at it:
array = ones(3,3,5,'gpuArray'); % create a 3x3x5 array of ones on GPU
array = pagefun(@sum,array); % for each page, sum all elements
array = gather(array); % return resulting 1x1x5 array to CPU
% Desired output: array = 1x1x5 vector of 9's
% This throws an error that pagefun does not like the summation function.
On the CPU, a similar process works just fine. It works in a PARFOR or FOR loop just fine on the GPU, but this does not vectorize the process for speed. Would a CUDA kernel using a PTX file be more able to do something like this? Is there a better way to do this? Is this more suitable for a cluster rather than a GPU?
Help appreciated, Will
Respuesta aceptada
Más respuestas (1)
Will Kinsman
el 13 de Mayo de 2016
Editada: Will Kinsman
el 13 de Mayo de 2016
1 comentario
Will Kinsman
el 14 de Mayo de 2016
Categorías
Más información sobre GPU Computing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!