Hi All,

I have this view problem with plan_fft!,

Part of the code is below:

using FFTW

L = (128,16,16);

pad = 2;

data = rand(ComplexF32,128,16,16);

FFT_buffer = zeros(ComplexF32,128,32,32);

FFT_buffer[:,1:L[2],1:L[3]] .= data;

# I want to apply 1D FFT along second dimension in FFT_buffer, because I know half of the data in the second and third dimension are zero.

Therefore, I have created a FFTPlan to do 1D FFT along second dimension as below:

FFTPlan = plan_fft!(rand(ComplexF32,L[1],L[2],L[3].*pad),2,flags=FFTW.MEASURE); # for size 128*16*32

FFTPlan * view(FFT_buffer,:,1:L[2],:); # this doesn’t work

=> ERROR: ArgumentError: FFTW plan applied to wrong-strides array

FFTPlan * FFT_buffer[:,1:L[2],:] # this works but then it doesn’t update FFT_buffer file.

I have to do this to get it working

FFT_buffer[:,1:L[2],:] .= FFTPlan * FFT_buffer[:,1:L[2],:] ;

But then I am allocating the memory by doing this as shown below:

@time FFT_buffer[:,1:L[2],:] .= FFTPlan * FFT_buffer[:,1:L[2],:] ;

0.000603 seconds (22 allocations: 512.750 KiB)

I don’t want to reallocate memory again. I already have done the allocation in FFT_buffer file, I want to avoid any memory allocation now.

I could have avoided if view(FFT_buffer,:,1:L[2], had worked.

Does anyone have any idea how to avoid memory allocation here and use view in FFT_buffer to do such operation?

This is the part of my code, and it runs in the loop for many many iterations, that’s why I want to avoid this memory allocation.

Thank you.