- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have written a program to check the correctness of 2D FFT using two different menthods.
First one has input data in complex format(real and imaginary are interlevaed).
2nd one has input data in de-interved format(two seperate arrays of real and imaginary parts).
we have two different routines available in MKL to solve this purpose. I found that the outputs are not mathcing using these routines when input size is 128*128, 256*256, 512*512,....
I included the code below. Please have a look and let me know if i do any mistake.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <complex>
#define MKL_Complex8 std::complex<float>
#include "mkl_dfti.h"
#include "mkl.h"
int main(int argc, char* argv[])
{
printf("hi\n");
int N1 = atoi(argv[1]);
int N2 = atoi(argv[2]);
MKL_LONG status = 0;
MKL_Complex8 *x = 0;
MKL_Complex8 *y = 0;
MKL_Complex8 *z = 0;
float* real;
float* imag;
float* real1;
float* imag1;
DFTI_DESCRIPTOR_HANDLE hand = 0;
DFTI_DESCRIPTOR_HANDLE hand1 =0;
DFTI_DESCRIPTOR_HANDLE hand2 =0;
MKL_LONG N[2]; N[0] = N1; N[1] = N2;
status = DftiCreateDescriptor(&hand, DFTI_SINGLE, DFTI_COMPLEX, 2, N);
if (0 != status) printf("failed\n");
status = DftiSetValue( hand, DFTI_PLACEMENT, DFTI_INPLACE );
if (0 != status) printf("failed\n");
status = DftiCommitDescriptor(hand);
if (0 != status) printf("failed\n");
x = (MKL_Complex8*)malloc(N1*N2*sizeof(MKL_Complex8));
real = (float*)malloc(N1*N2*sizeof(float));
imag = (float*)malloc(N1*N2*sizeof(float));
status = DftiCreateDescriptor(&hand1, DFTI_SINGLE, DFTI_COMPLEX, 2,N);
if (0 != status) printf("failed\n");
status = DftiSetValue(hand1, DFTI_COMPLEX_STORAGE, DFTI_REAL_REAL);
if (0 != status) printf("failed\n");
status = DftiCommitDescriptor(hand1);
if (0 != status) printf("failed\n");
for(int i = 0; i < N1*N2; i++)
{
x.real() =(float) i;
real = i;
imag = i+1;
x.imag() = (float)(i+1);
}
printf("before FFT\n");
for(int i =0 ; i < N1*N2; i++)
{
//printf(" (%f, %f)----------(%f, %f)\n",x.real(),x.imag(),real,imag);
}
status = DftiComputeForward(hand, x);
if (0 != status) printf("failed\n");
status = DftiComputeForward(hand1,real, imag);
printf("after FFT prints if value not matches\n");
for(int i =0 ; i < N1*N2; i++)
{
if(x.real()!= real || x.imag() != imag)
printf("not matching %d -- (%f, %f)--------(%f, %f)\n",i,x.real(),x.imag(),real,imag);
}
}
complie command: icc checkFFT.cpp -o checkFFT.o -mkl.
./checkFFT 128 128
Thanks
sivaramakrishna
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, shiva rama krishna bharadwaj I.
Very strange - when I tried to use your code, it passed (as it supposed to do). I tested it on linux ia32 and intel64. Could you please share what mkl version do you use and the platform?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Evarist Fomenko,
I am using Intel MKL 11.1.2 version on linux 64 bit kernel version 2.6.32-358.el6.x86_64. It seems it is a bug in 11.1.2 version. when i tried with MKL 11.0.1 the code was working.
Thanks
sivaramakrishna
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page