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

OpenMP and FFT

mandrew
Beginner
606 Views
Hello,

I am currently trying to take the FFTs of several functions using the following command:

DO i=1,N
Status = DftiComputeForward( Desc_Handle, f1(i,:))
Status = DftiComputeForward( Desc_Handle, f2(i,:))
Status = DftiComputeForward( Desc_Handle, f3(i,:))
Status = DftiComputeForward( Desc_Handle, f4(i,:))
END DO

Where I have used the following initializations:

Threads = 1
Status = DftiCreateDescriptor( Desc_Handle, DFTI_DOUBLE, &
DFTI_REAL, 1, M )
Status = DftiSetValue(Desc_Handle, DFTI_BACKWARD_SCALE, Scale)
Status = DftiSetValue(Desc_Handle, DFTI_NUMBER_OF_USER_THREADS, Threads)
Status = DftiSetValue(Desc_Handle, DFTI_PACKED_FORMAT, DFTI_CCS_FORMAT)
Status = DftiCommitDescriptor( Desc_Handle )

I would like to parallelize the the loop given above using OpenMP:

!$OMP DO
DO i=1,N
Status = DftiComputeForward( Desc_Handle, f1(i,:))
Status = DftiComputeForward( Desc_Handle, f2(i,:))
Status = DftiComputeForward( Desc_Handle, f3(i,:))
Status = DftiComputeForward( Desc_Handle, f4(i,:))
END DO
!$OMP END DO

However, I realize that this cannot work using the same Desc_Handle. Can anyone make a recommendation on how to treat the descriptor handle? In other words, what is the simplest way to parallelize the above loop using Intel's FFT functions?

Thanks,
Mandrew
0 Kudos
3 Replies
Dmitry_B_Intel
Employee
606 Views


Hi Mandrew,

Once single descriptor is to be shared between N user threads, the value of parameter DFTI_NUMBER_OF_USER_THREADS should be set to N. And the OpenMP loop should be limited to that number via num_threads(N) clause.

Thanks,
Dima

0 Kudos
Gennady_F_Intel
Moderator
606 Views

Mandrew,
as an addition to Dima's comments, please look at the article "Different parallelization techniques for MKL FFT" by the following the link "http://software.intel.com/en-us/articles/different-parallelization-techniques-and-intel-mkl-fft/" See the example #4.
--Gennady

0 Kudos
mandrew
Beginner
606 Views

Dima and Gennady:

Thanks for your help - it is now working great!

Mandrew
0 Kudos
Reply