FFT is suddenly slow down for repeated operations.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hosung Jeon
il 13 Mag 2024
Commentato: Hosung Jeon
il 16 Mag 2024
Hello. I am conducting a simulation with a 3-dimensional matrix using Matlab. While performing FFT about one dimension of the 3-dimensional matrix using GPU for repeated operations, I noticed that the computation speed suddenly slows down. Below is a brief summary of the problematic code.
matlab
clear all; close all; clc;
k = 501;
A = zeros(k,k,k,'gpuArray');
B = zeros(k,k,k,'gpuArray');
for n = 1:k
tic
B(:,:,:) = fftshift(fft(ifftshift(A,1),[],1),1);
disp(num2str([n, toc]))
end
The result of running the code is as follows:
Result
....
236 7.52e-05
237 7.03e-05
238 7.11e-05
239 7.34e-05
240 7.29e-05
241 7.02e-05
242 0.0235287
243 0.0472623
244 0.0312132
245 0.0444045
246 0.0305904
247 0.0463637
248 0.0309244
....
As the result, from the 242nd iteration, the FFT operation significantly slows down.
I am curious about the cause of this issue.
The GPU used is 4090.
I would appreciate it if you could let me know what the problem might be.
0 Commenti
Risposta accettata
Edric Ellis
il 16 Mag 2024
This is due to the asynchronous nature of gpuArray operations. Where possible, operations on the GPU are queued up and run in the background. At some point, we run out of queue, and the operations have to actually run - that's the point at which you see the change in time.
The best way to time operations on the GPU is to use gputimeit which takes into account this asynchronous behaviour. The other option is to call wait on the gpuDevice before calling toc, like this:
d = gpuDevice();
t = tic();
% do stuff on the GPU
wait(d);
time = toc(t)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su GPU Computing in MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!