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

## DftiSetValue and DFTI_NUMBER_OF_TRANSFORMS Beginner
232 Views

Hi MKL experts

I hope someone can help me understand the setting of DFTI_NUMBER_OF_TRANSFORMS

For example if I have a loop that implements an FFT of the same dimensions on each iteration:

StatusSmall = DftiCreateDescriptor(FFTid, DFTI_SINGLE, DFTI_COMPLEX, 2, lgth)
StatusSmall = DftiCommitDescriptor(FFTid)

DO lps=1,10
StatusBig = DftiComputeForward(FFTid, DFTarray)
DFTarray = SomeFunction(DFTarray)
END DO

Do I set DFTI_NUMBER_OF_TRANSFORMS to 1 or 10?

If not 10, then for what kind of situation do you need to set DFTI_NUMBER_OF_TRANSFORMS to a number other than 1?

Thanks

John
6 Replies Employee
232 Views
Hi John,

With DFTI_NUMBER_OF_TRANSFORMS = N function DftiComputeForward will do N transforms in a single call. The idea can be illustrated on basis of your example as follows:

```[fortran]complex :: multple_dftarray(lgth(1),lgth(2),10)
...
DftiSetValue(fftid,DFTI_NUMBER_OF_TRANSFORMS,10)
DftiSetValue(fftid,DFTI_INPUT_DISTANCE, lgth(1)*lgth(2) )
...
statusbig = DftiComputeForward(fftid, multiple_dftarray) ! does 10 two-d transforms
do lps = 1, 10
dft_array = somefunction( multiple_dftarray(:,:,lps) )
enddo
[/fortran]```

Thanks
Dima Beginner
232 Views

Thanks Dima,

One follow up question. Is this multiple dft process more efficient than doing the 10 two-d transforms separately or does it just provide for more compact syntax?

Cheers

John Employee
232 Views
Hi John,

If you do a bunch of small transforms, where function call overhead comprises a noticeable part of the transform time, doing the bunch in a single call is more efficient. For large transforms doing the transforms separately may be more efficient, because each of the separate transforms will be done in parallel, whereas the bunch of transform will be often parallelized in a transform per thread fashion.

Thanks
Dima Beginner
232 Views
Thanks Dima,

That makes a lot of sense :)

Do you have a rough intuition of what would be small enough for the function call overhead to become significant?

Thanks

John Employee
232 Views
Hi John,

For example, if the data for one transform fits into L1 cache (32Kb) then threading overhead will likely overweight speedup due to parallelization. The data includesprecomputed trigonometric tables used toperfrom the FFT.

Thanks
Dima Beginner
232 Views

Thanks again Dima,

I really appreciate your help.

Best

John 