Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6734 Discussions

## Problems usind DFT

Beginner
893 Views

I want to compare the performance of Fourier Transforms between IPPS library and cuFFT library. Now Im comparing the Real to Complex case. For IPPS, I implemented the FFT (inputs size equal to 2^n) and then I tryed with the DFT (inputs of any size).

The FFT works fine but when I run the DFT I get an output of 0s. I read all the documentation about the DFT and did a very similiar code from  https://software.intel.com/content/www/us/en/develop/articles/how-to-use-intel-ipp-s-1d-fourier-transform-functions.html  but it stills dont work.

Im using IPPS version 2020.0.1 and Debian 10 as OS.

In the code I have a matrix as input and I will do as many DFT as row in the matrix. For each row I perform a DFT.

``````// NX == amount of columns in matrix
// BATCH == amounto of rows in matrix
int NX = 4;
int BATCH = 1;
int SEED = 1;
int flag = IPP_FFT_NODIV_BY_ANY;

int sizeSpec= 0;
int sizeInit = 0;
int sizeBuffer = 0;

Ipp8u *pMemInit = 0;
Ipp8u *pMemBuffer = 0;

// For this case, BATCH is 1 so only the NX is important
float **datos = (float**) malloc(sizeof(float*) * NX * BATCH);

// Generates a NX x BATCH matrix with random numbers of the 4 possibles //(-3.533, -1.000, 1.000, 3.533) using the SEED
datos = genMatrix(NX, BATCH, SEED);

Ipp32fc **dst = (Ipp32fc**) malloc(sizeof(Ipp32fc*) * (NX / 2 + 1) * BATCH);

// Check is NX is power of 2
if (!((NX) & (NX - 1)))
{
// FFT
// ...
}
else
{
IppsDFTSpec_R_32f *pSpec = 0;
ippsDFTGetSize_R_32f(NX, flag, ippAlgHintNone, &sizeSpec, &sizeInit, &sizeBuffer);
/// allocate memory for required buffers
if (sizeInit > 0)
{
pMemInit = (Ipp8u*) ippMalloc_8u(sizeInit);
}

if (sizeBuffer > 0)
{
pMemBuffer = (Ipp8u*) ippMalloc_8u(sizeBuffer);
}

ippsDFTInit_R_32f(NX, flag, ippAlgHintNone, pSpec, pMemInit);

if (sizeInit > 0)
{
ippFree(pMemInit);
}

// Do the DFT
for (int i = 0; i < BATCH; i++)
{
dst[i] = (Ipp32fc*) malloc(sizeof(Ipp32fc) * (NX / 2 + 1));
/// perform forward DFT
ippsDFTFwd_RToCCS_32f((Ipp32f*) datos[i], (Ipp32f*) dst[i], pSpec, pMemBuffer);
}

}
``````

In the FFT option (power of 2) I have a similar code than in DFT. I run this code for both cases and in FFT it works but in DFT I only get 0s.

P.D: excuse me for my english

4 Replies
Moderator
858 Views

Hi,

Thanks for reaching out to us.

>>Im using IPPS version 2020.0.1

Could you please try with latest ipp version which comes with oneAPI toolkit 2021.3.0.

and also share a complete reproducer if possible (along with the compiler that you are using) so that we can work on it from our end.

Thanks & Regards,

Vidya.

Moderator
829 Views

Hi,

Reminder:

Is your issue resolved ? Please let us know if the issue still persists by providing above mentioned details.

Regards,

Vidya.

Beginner
815 Views

Hi,

Yes, I solved the problem.

I forgot to allocate memory for the pSpec variable.

Moderator
812 Views

Hi,

>>Yes, I solved the problem.

Thanks for the confirmation!

Glad to know that you have figured it out.