Strange phenomenon when running FFT on GP

5 Ansichten (letzte 30 Tage)
anaconpa
anaconpa am 22 Nov. 2021
Kommentiert: anaconpa am 22 Nov. 2021
Parallel Computing Toolbox 7.4
MatlabR2021a
GPU Memory 5GB
I ran the following code.
clear
Nx = 1281;
Ny = 340;
Nz = 340;
A = gpuArray(single(rand(Nx, 1)));
B = single(rand(Nx, Ny, Nz));
C = gpuArray(single(rand(Nx, 1)) + i*single(rand(Nx, 1)));
% ↓ The 9th line ↓
answer = A .* B - real(ifftn(C .* gpuArray(B)));
Then, the first time on line 9, the following error occurs: "An invalid FFT plan was used on the GPU."
Next, I execute only the 9th line as, it was executed normally without any error.
Between the first and second time, GPU memory is not consumed by anything outside. I will get the same result no matter how many times you try
I have no idea what's going on.
Can you explain what is happening? thank you.

Antworten (1)

Walter Roberson
Walter Roberson am 22 Nov. 2021
"CUFFT provides a simple configuration mechanism called a plan that pre-configures internal building blocks such that the execution time of the transform is as fast as possible for the given configuration and the particular GPU hardware selected. Then, when the execution function is called, the actual transform takes place following the plan of execution. The advantage of this approach is that once the user creates a plan, the library retains whatever state is needed to execute the plan multiple times without recalculation of the configuration."
So that is what an FFT plan is .
Why does it complain about invalid FFT plan? Why does it work afterwards?
Over in https://www.mathworks.com/matlabcentral/answers/786066-fftn-on-gpu-array#comment_1424841 we see a hint that maybe you ran out of GPU memory. The comment I link to shows some software to help keep track of GPU variables.
  1 Kommentar
anaconpa
anaconpa am 22 Nov. 2021
Thank you for your reply!
I read the attached question, but unfortunately it didn't help.
My question is why it succeeds the second time.
If a memory error occurs in the first time, will it not fail in the second and subsequent times even if the execution plan is held internally?
How is it explained that the second success and the first failure.
thank you

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu GPU Computing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by