Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7222 Discussions

Is there a signicant performance difference between DFT and FFTW3 interfaces?

crtierney42
New Contributor I
962 Views
I am trying to convert some code that used FFTPACK to MKL to improve performance. I am not an FFT expert, and the MKL documentation wasn't very clear on how to do a real-to-complex (or vice versa) FFT. I was able to get something working using the FFTW3 interface:

call dfftw_plan_dft_c2r_1d(plan_backward,
& lons_lat,outv,inv,FFTW_ESTIMATE)

do n=1,lot
outv(:)=syn_gr_a_1(:,n)
call dfftw_execute(plan_backward)
syn_gr_a_2(:,n)=inv(:)
end do
call dfftw_destroy_plan(plan_backward)

This function that contains this code is called 1000s of times during the execution of the model.

In this case, the length of each vector is 576 and the number executed is 515. I am getting similar answers to the original code, but it isn't going any faster.

Is this an issue with the wrapper script, and should I be trying to figure out the DFT syntax for this?

Thanks,
Craig
0 Kudos
1 Solution
Dmitry_B_Intel
Employee
962 Views

Hi Craig,
Replacinguse ofFFTW3 interface with use of DFTI interface will not give noticeableperformance advantage.
However, you may getimproved performance if you plan for multiple transforms in a single call of dfftw_execute instead of executing single transform in the loop. Could you look at DFFTW_PLAN_MANY_DFT_C2R, and rearrange your code to something like this:

call dfftw_plan_many_dft_c2r(plan,1,lons_lat, lot, syn_gr_a_1,dontcare,1,
size(syn_gr_a_1,dim=1),syn_gr_a_2,dontcare,1,size(syn_gr_a_2,dim=1),FFTW_ESTIMATE)

call dfftw_execute(plan) !former do n=1,lot ... enddo

Thanks,
Dima

View solution in original post

0 Kudos
2 Replies
Dmitry_B_Intel
Employee
963 Views

Hi Craig,
Replacinguse ofFFTW3 interface with use of DFTI interface will not give noticeableperformance advantage.
However, you may getimproved performance if you plan for multiple transforms in a single call of dfftw_execute instead of executing single transform in the loop. Could you look at DFFTW_PLAN_MANY_DFT_C2R, and rearrange your code to something like this:

call dfftw_plan_many_dft_c2r(plan,1,lons_lat, lot, syn_gr_a_1,dontcare,1,
size(syn_gr_a_1,dim=1),syn_gr_a_2,dontcare,1,size(syn_gr_a_2,dim=1),FFTW_ESTIMATE)

call dfftw_execute(plan) !former do n=1,lot ... enddo

Thanks,
Dima

0 Kudos
crtierney42
New Contributor I
962 Views

Hi Craig,
Replacinguse ofFFTW3 interface with use of DFTI interface will not give noticeableperformance advantage.
However, you may getimproved performance if you plan for multiple transforms in a single call of dfftw_execute instead of executing single transform in the loop. Could you look at DFFTW_PLAN_MANY_DFT_C2R, and rearrange your code to something like this:

call dfftw_plan_many_dft_c2r(plan,1,lons_lat, lot, syn_gr_a_1,dontcare,1,
size(syn_gr_a_1,dim=1),syn_gr_a_2,dontcare,1,size(syn_gr_a_2,dim=1),FFTW_ESTIMATE)

call dfftw_execute(plan) !former do n=1,lot ... enddo

Thanks,
Dima


Thanks for the guideance. Using this works.

0 Kudos
Reply