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

About DFTI_BACKWARD_SCRAMBLED option usage

Lei_F_Intel1
Employee
493 Views

Hello Sir or Madam,

Recently I am leaning and using MKL FFT in my work. I noticed that there is a option DFTI_BACKWARD_SCRAMBLED  can applying an FFT to input data whose order is scrambled, or allowing a scrambled order of the FFT results. This may help us improve the code performance. It's possible to share some detail about this? Thanks a lot!

Best Regards,

Lei Fu

0 Kudos
7 Replies
Ying_H_Intel
Employee
493 Views

Hi LeiFu, 

The parameter explanation in MKL user reference may be helpful.  

https://software.intel.com/en-us/node/521974

DFTI_ORDERING

Some FFT algorithms apply an explicit permutation stage that is time consuming [4]. The exclusion of this step is similar to applying an FFT to input data whose order is scrambled, or allowing a scrambled order of the FFT results. In applications such as convolution and power spectrum calculation, the order of result or data is unimportant and thus using scrambled data is acceptable if it leads to better performance. The following options are available in Intel MKL:

  • DFTI_ORDERED: Forward transform data ordered, backward transform data ordered (default option).

  • DFTI_BACKWARD_SCRAMBLED: Forward transform data ordered, backward transform data scrambled.

Table "Scrambled Order Transform" tabulates the effect of this configuration setting.

Scrambled Order Transform
 

DftiComputeForward

DftiComputeBackward

DFTI_ORDERING

Input → Output

Input → Output

DFTI_ORDERED

ordered → ordered

ordered → ordered

DFTI_BACKWARD_SCRAMBLED

ordered → scrambled

scrambled → ordered

NOTE

The word "scrambled" in this table means "permit scrambled order if possible". In some situations permitting out-of-order data gives no performance advantage and an implementation may choose to ignore the suggestion.

So you can  set the paramater in your sample ( or use MKL sample code)  when the result is not important and see if there is performance benefit and result scrambled. 

Regards,

Ying 

0 Kudos
Lei_F_Intel1
Employee
493 Views

Hi Ying,

Thanks for your reply. I have tried to add "status = DftiSetValue(FFT_desc, DFTI_ORDERING, DFTI_BACKWARD_SCRAMBLED);"

And using " status = DftiComputeBackward(FFT_desc, FFT_in_singlePrecision, FFT_out_singlePrecision);" to run the FFT. But the output is no different. What's I missing;

My example code:

        status = DftiCreateDescriptor(&FFT_desc, DFTI_SINGLE, DFTI_COMPLEX, 1, FFTSize);
        //DFTI_INPLACE is FFT output overwrites input, DFTI_NOT_INPLACE is FFT output does not overwrite input
        status = DftiSetValue(FFT_desc, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

        status = DftiSetValue(FFT_desc, DFTI_ORDERING, DFTI_BACKWARD_SCRAMBLED);

        status = DftiComputeBackward(FFT_desc, FFT_in_singlePrecision, FFT_out_singlePrecision);

        status = DftiFreeDescriptor(&FFT_desc);
  

Thanks a lot!

Lei Fu

0 Kudos
Ying_H_Intel
Employee
493 Views

Hi Lei Fu, 

Do you have  DftiCommitDescriptor functions after the descriptor value setting changed.   How about to add the commit?  

Performs all initialization for the actual FFT computation.
Syntax

f you call the DftiSetValuefunction to change configuration parameters of a committed descriptor (see 
Descriptor Configuration Functions), you must re-commit the descriptor before invoking a computation
function. Typically, a committal function call is immediately followed by a computation function call (see FFT
Computation Functions).

On the other hands,  although the note claimed

The word "scrambled" in this table means "permit scrambled order if possible". In some situations permitting out-of-order data gives no performance advantage and an implementation may choose to ignore the suggestion.

Anyway, if you hope to see the effect of the parameter,  According  Table "Scrambled Order Transform" show,  DftiComputeBackward, scrambled → ordered. you may try first  DftiComputeForward  and  see the result.

Best Regards,

Ying 

0 Kudos
Lei_F_Intel1
Employee
493 Views

Hi Ying,

Let me copy my full example code:

printf("Doing %d-point FFT!\n", FFTSize);
        fprintf(fp_timingLog, "Doing %d-point FFT:\n", FFTSize);
        fprintf(fp_PrecisionLog, "Doing %d-point FFT:\n", FFTSize);
  //mkl_set_num_threads(2);
        //configure and run single precision floating-point FFT
        //configure fft descriptor: single precision, 2048-point FFT
        //DFTI_SINGLE is single precision, DFTI_DOUBLE is double precision
        status = DftiCreateDescriptor(&FFT_desc, DFTI_SINGLE, DFTI_COMPLEX, 1, FFTSize);
        //DFTI_INPLACE is FFT output overwrites input, DFTI_NOT_INPLACE is FFT output does not overwrite input
        status = DftiSetValue(FFT_desc, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
  status = DftiSetValue(FFT_desc, DFTI_NUMBER_OF_USER_THREADS, 2);
#if FORWARD
        //status = DftiSetValue(FFT_desc, DFTI_ORDERING, DFTI_BACKWARD_SCRAMBLED);
#else
        status = DftiSetValue(FFT_desc, DFTI_ORDERING, DFTI_BACKWARD_SCRAMBLED);
#endif
        //frease FFT descriptor
        status = DftiCommitDescriptor(FFT_desc);

#if FORWARD
                //run fft with forward method
                status = DftiComputeForward(FFT_desc, FFT_in_singlePrecision, FFT_out_singlePrecision);
#else
                //run fft with backward method
                status = DftiComputeBackward(FFT_desc, FFT_in_singlePrecision, FFT_out_singlePrecision);
#endif

        status = DftiFreeDescriptor(&FFT_desc);

And I also noticed that     in mkl_dfti.h

/* DFTI_ORDERING */
    DFTI_ORDERED = 48,
    DFTI_BACKWARD_SCRAMBLED = 49,
    /* DFTI_FORWARD_SCRAMBLED = 50, ## NOT IMPLEMENTED */

No any different in forward and backward FFT computation.

My MKL version is 11.2 Update 3

Thanks a lot!

Best Regards,

Lei

 

0 Kudos
Ying_H_Intel
Employee
493 Views

Hi Lei, 

Could you please attach a whole cpp file.  By the button  Attach media  at the end of the webpage. 

Thanks

Ying 

0 Kudos
Lei_F_Intel1
Employee
493 Views

Hi Ying,

I have attached my example test C code.

Thanks a lot!

Best Regards,

Lei Fu

0 Kudos
Ying_H_Intel
Employee
493 Views

Hi Lei Fu. 

the note claimed

The word "scrambled" in this table means "permit scrambled order if possible". In some situations permitting out-of-order data gives no performance advantage and an implementation may choose to ignore the suggestion. ( you may ask what is the situations, i will check with developer and get back to you). 

I change the test problem size as 

#define SCRAMBLED 1  //0
#define FORWARD 1

int FFT_sizeBuf[FFT_SIZE_NUM]= {2000}

and change the   SCRAMBLED as 0. 

The results was scrambled. 

Regards,

Ying 

0 Kudos
Reply