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

MKL FFT on Intel Iris

stemsc
Beginner
914 Views

Hi all.

I'm using MKL (ver. 2019.4.245) programmatically to calculate FFT : by linking static .lib (mkl_core.lib, mkl_intel_lp64.lib, mkl_intel_thread.lib) into a VS 2019 C++  project.

All worked fine comparing results with the FFT by Matlab on all PC with Intel processor (11th generation family) and Intel Graphics UHD Family.

Problem : running the same project on PC with Intel Iris Graphics Family, results are wrong: some output values are NaN (!) and only some values (the first) of original matrix columns are well processed.

So that I moved to use last MKL : Intel oneAPI 2022.01 supposing new version supporting those Iris, but obtaining the same results as previous version of MKL.

 

The C/C++ code is very simple:

---------------------------------------------------------------------------------------------------------------------

void FourierTransform(_MKL_Complex8* l_pMklInputOutputData, // input vectors
int p_iNumberOfRow, // num rows
int p_iNumberOfCol) // num columns
{
DFTI_DESCRIPTOR* l_pMklDftDescriptor=NULL;
DftiCreateDescriptor(&l_pMklDftDescriptor, DFTI_SINGLE, DFTI_COMPLEX, 1, (MKL_LONG)p_iNumberOfRow);
float l_fRangeScaleFactor = (float)(1.0);
DftiSetValue(l_pMklDftDescriptor, DFTI_FORWARD_SCALE, l_fRangeScaleFactor);
DftiCommitDescriptor(l_pMklDftDescriptor);

for(l_iCol = 0; l_iCol< p_iNumberOfCol;l_iCol++)
{
_MKL_Complex8* l_pMklData = &l_pMklInputOutputData[l_iCol*p_iNumberOfRow];

// calculate FFT
l_ulResult = DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData, l_pMklData);
}
}

 

... where l_pMklInputOutputData is the input vector of complex data to manage, previously allocated and filled by FourierTransform caller.

Exiting from this method, the same vector will contain results of FFT by DftiComputeForward one column at time. 

On all PC with Intel CPU the results are the same except on Hw with Intel Iris *** Graphics.

-------------------------------------------------------------------------------------------------------------

 

A simple workaround is to separate input from output vector of FFT, so that :

 

It works by changing :

l_ulResult = DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData, l_pMklData);

to :

l_ulResult = DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData, l_pOutData);

(where l_pOutData is a temporarely vector previously allocated like l_pMklData)

 

Previous change is needed only on PC with Intel Iris Graphics.

 

I'm asking to Intel why that MKL API for FFT doesn't work on Intel Iris Graphics:

  • is there an hidden advice to avoid using the same vector as input/output, advice not available on MKL specifications? or
  • is a know bug of MKL FFT working on Intel Iris Graphics? or
  • some particular configuration of MKL linking is required to use it on Intel Iris Graphics ?

Thanks to all

0 Kudos
6 Replies
ShanmukhS_Intel
Moderator
880 Views

Hi,


Thank you for posting on Intel Communities.


Could you please let us know if you are working with One-dimensional In-place FFT or One-dimensional Out-of-place FFT?


In addition, Could you please share a complete working reproducer or a project file and steps(if any) so that we could try reproducing the issue at our end and we could let you know the possible root cause?


Thank you for sharing the detailed elaboration regarding the issue.


Best Regards,

Shanmukh.SS



0 Kudos
stemsc
Beginner
874 Views

Thanks for your friendly reply.

 

I'm using Two dimensional FFT with descriptor set to DFTI_NOT_INPLACE.

I can't post entire or a shapshot of project, but involved/useful code is very simple :

 

---------------------------------------------------------------------------------------------------------------------------------------------------
#include "mkl.h"

.......

......

void FourierTransform(_MKL_Complex8* l_pMklInputOutputData, // input vectors
int p_iNumberOfRow, // num rows
int p_iNumberOfCol) // num columns
{
DFTI_DESCRIPTOR* l_pMklDftDescriptor=NULL;
DftiCreateDescriptor(&l_pMklDftDescriptor, DFTI_SINGLE, DFTI_COMPLEX, 1, (MKL_LONG)p_iNumberOfRow);

DftiSetValue(l_pMklRangeDftDescriptor , DFTI_PLACEMENT, DFTI_NOT_INPLACE);
float l_fRangeScaleFactor = (float)(1.0);
DftiSetValue(l_pMklDftDescriptor, DFTI_FORWARD_SCALE, l_fRangeScaleFactor);
DftiCommitDescriptor(l_pMklDftDescriptor);

for(l_iCol = 0; l_iCol< p_iNumberOfCol;l_iCol++)
{
_MKL_Complex8* l_pMklData = &l_pMklInputOutputData[l_iCol*p_iNumberOfRow];

// calculate FFT
l_ulResult = DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData, l_pMklData);
}
}

.......

......

---------------------------------------------------------------------------------------------------------------------------------------------------

  • Used project is a VS2019 project with following main specifications:
    • Windows SDK version : 10.0.19041.0
    • Platform toolset : Visual Studio 2019 v.142
    • C++ Language : ISO C++ ver. 14
    • Target architecture : Windows x64
  • Used MKL : ver. 2019.4.245 or (from) oneAPI 2022.01.
  • Linked MKL libraries (static) : mkl_core.lib, mkl_intel_lp64.lib, mkl_intel_thread.lib

 

In attachment a textual version of an example (InputDataOfFFT.txt) of Input Data (to fill into l_pMklInputOutputData) at execution time.

Using that input (filled to l_pMklInputOutputData), with p_iNumberOfRow = 5551 and p_iNumberOfCol = 401, you can see (in attachment too) Wrong output of FFT running on PC with Intel Iris, and related Correct output running on another Intel Graphics (i.e Intel UHD).

 

To test:

you can easily insert "void FourierTransform" into a simple "main.cpp" and call it using a preallocated and filled array of _MKL_Complex8 with size p_iNumberOfRow * p_iNumberOfCol.

Array could be filled with example data in attachment (InputDataOfFFT.txt).

 

I suppose, even if I use "DftiComputeForward(desc_handle, x_in, y_out);"  with separated parameter for input and output - caused by DFTI_PLACEMENT previously set to  DFTI_NOT_INPLACE - "x-in" and "y-out"  can't be the same vector....

.....But that code worked fine on all Intel Graphics until now. Why?

....Maybe was an hidden problem using these statements running on other Intel Graphics? .... and now the problem shows its effect on Intel Iris?

 

If previous code was wrong due to the same vector as input and output and DFTI_PLACEMENT set to DFTI_NOT_INPLACE,

I propose two solutions:

 

DftiSetValue(l_pMklRangeDftDescriptor , DFTI_PLACEMENT, DFTI_NOT_INPLACE);

DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData, l_pOutData);

or

DftiSetValue(l_pMklRangeDftDescriptor , DFTI_PLACEMENT, DFTI_INPLACE);

DftiComputeForward(l_pMklRangeDftDescriptor, l_pMklData);

 

 

What's your opinion? Do you agree? Which is the best solution?

Many thanks for your friendly support.

0 Kudos
ShanmukhS_Intel
Moderator
834 Views

Hi Stemsc,

 

Thank you for sharing the details. The previous code was wrong as the same vector was used for input and output. We would require a minimum reproducer to trace the issue. Please refer to the below link for details regarding the DftiComputeForward handle and for corresponding configuration seeings.

 

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/fourier-transform-functions/fft-functions/fft-computation-functions/dfticomputeforward.html#dfticomputeforward

 

For configuration settings:

https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/fourier-transform-functions/fft-functions/configuration-settings.html#configuration-settings

 

Best Regards,

Shanmukh.SS

 

0 Kudos
ShanmukhS_Intel
Moderator
766 Views

Hi Stemsc,


I can't post entire or a shapshot of project
>> Could you please let us know if we could contact you in a private way (via mail) for the complete source reproducer? Based in the shared source code, we'll reproduce the issue and we will be assisting on that.

Best Regards,
Shanmukh.SS

 

0 Kudos
ShanmukhS_Intel
Moderator
705 Views

 

Hi Stemsc,


A gentle reminder:
Could you please let us know if we could contact you in a private way (via mail) for the complete source reproducer so that we could try investigating the issue at our end?

 

Best Regards,
Shanmukh.SS

0 Kudos
ShanmukhS_Intel
Moderator
638 Views

Hi Stemsc,


We assume your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS


0 Kudos
Reply