How do I perform muliple FFTs on a stack of data in parallel on a GPU?

5 vues (au cours des 30 derniers jours)
Adam
Adam le 18 Mar 2013
Hi, I have a stack of images, and I want to compute the 2d fourier-transform of each image in parallel. For example, if I was not using a GPU, I would be doing something like this:
A = rand(256,256,100);
B = zeros(256, 256, 100);
for j = 1:100
B(:,:,j) = fftshift(fft2(A(:,:,j)));
end;
I would like to do each iteration of this for-loop in parallel. Is there a way to do that using gpuArray and arrayfun, or do I have to define my own cuda kernel?

Réponses (1)

Edric Ellis
Edric Ellis le 18 Mar 2013
FFT2 in MATLAB already applies to each 'page' of a 3-dimensional array, and this is true on the GPU too. Unfortunately, FFTSHIFT doesn't work that way, so you need something like this:
A = gpuArray.rand(256, 256, 100);
B = fftshift(fftshift(fft2(A), 1), 2);
  1 commentaire
Adam
Adam le 18 Mar 2013
Thanks for your help! This definitely makes things very simple! Out of curiosity, is there a standard way of independently processing multiple independent 'pages' simultaneously by some arbitrary function? For example, if I have a function:
b = myfun(a)
where b and a are both n-by-n, how would I use arrayfun to apply 'myfun' to each page of a n-by-n-by-m gpuArray, (thus returning another 3D gpuArray)?

Connectez-vous pour commenter.

Catégories

En savoir plus sur GPU Computing dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by