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

I get wrong Backward DFT answer and can not find the problem

王_子_
Beginner
547 Views

Hi ,I use the MKL DFT recently ,and use the forward DFT including one dimension and two dimensions without problem. 

However, when I use the backward DFT, the result is zero !

I also study the examples in /opt/intel/mkl/examples/dft and the following is my test short code ,the result in my computer is zero.

I really can not find the problem in these short code and really need your help 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include "mkl_service.h"
#include "mkl_dfti.h"
#include "mkl.h"
#include<sys/time.h>

#define ALIGN_SIZE 64
#define REP_TIMES 1

int main()
{

	
   #pragma offload target(mic:0) 
	{
		MKL_LONG status = 0;
		int dim[2];
		dim[0]=20;dim[1]=20;
		DFTI_DESCRIPTOR_HANDLE handle = 0;
	
		MKL_Complex8 *in=(MKL_Complex8*)mkl_malloc(dim[0]*dim[1]*sizeof(MKL_Complex8),ALIGN_SIZE);
		MKL_Complex8 *out=(MKL_Complex8*)mkl_malloc(dim[0]*dim[1]*sizeof(MKL_Complex8),ALIGN_SIZE);
		for(int i=0;i<dim[0]*dim[1];i++)
		{
			in.real=i%100;
			in.imag=0;
		}
		status = DftiCreateDescriptor(&handle, DFTI_SINGLE, DFTI_COMPLEX, 2, dim);

		status =DftiSetValue( handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

		status = DftiCommitDescriptor(handle);
	
		DftiComputeBackward(handle,in, out);
		for(int i=0;i<10;i++)
		{
			printf("%f %f\n",out.real,out.imag);
		}

	}
}

And the output  is :

0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000
0.000000 0.000000

Best Regards !

0 Kudos
1 Solution
Zhen_Z_Intel
Employee
547 Views

Hi,

Please set type of dim as MKL_LONG, otherwise you could not create descriptor successfully. Thank you.

MKL_LONG dim[2];

Best regrads,
Fiona

View solution in original post

0 Kudos
2 Replies
Zhen_Z_Intel
Employee
548 Views

Hi,

Please set type of dim as MKL_LONG, otherwise you could not create descriptor successfully. Thank you.

MKL_LONG dim[2];

Best regrads,
Fiona

0 Kudos
王_子_
Beginner
547 Views

Thank you very much! You are right.

 

Best regards !

0 Kudos
Reply