#include #include #include #include #include #include #include #include "SIMDBase.h" #include "DFT.h" #if 1 typedef float REAL; #define TYPE SIMDBase_TYPE_FLOAT #else typedef double REAL; #define TYPE SIMDBase_TYPE_DOUBLE #endif #define THRES 1e-3 // complex forward int check_cf(int n, int mode, int veclen, int sizeOfVect) { int i, j; DFT *p = DFT_init(mode, n, 0); fftw_plan w[n]; fftw_complex *in[sizeOfVect], *out[sizeOfVect]; REAL *sx = SIMDBase_alignedMalloc(sizeOfVect*n*2); // for(j=0;j THRES) success = 0; if (fabs(sx[(i*2+1)*veclen+j] - cimag(out[j][i])) > THRES) success = 0; } } // for(j=0;j THRES) success = 0; if (fabs(sx[(i*2+1)*veclen+j] - cimag(out[j][i])) > THRES) success = 0; } } // for(j=0;j THRES) success = 0; if (fabs(sx[(i*2+1)*veclen+j] - creal(out[j][n/2])) > THRES) success = 0; } else { if (fabs(sx[(i*2+0)*veclen+j] - creal(out[j][i])) > THRES) success = 0; if (fabs(sx[(i*2+1)*veclen+j] - cimag(out[j][i])) > THRES) success = 0; } } } // for(j=0;j THRES)) { success = 0; } } } // for(j=0;j\n", argv[0]); exit(-1); } const int n = 1 << atoi(argv[1]); srandom(time(NULL)); // int mode = SIMDBase_chooseBestMode(TYPE); printf("mode : %d, %s\n", mode, SIMDBase_getModeParamString(SIMDBase_PARAMID_MODE_NAME, mode)); int veclen = SIMDBase_getModeParamInt(SIMDBase_PARAMID_VECTOR_LEN, mode); int sizeOfVect = SIMDBase_getModeParamInt(SIMDBase_PARAMID_SIZE_OF_VECT, mode); printf("complex forward : %s\n", check_cf(n, mode, veclen, sizeOfVect) ? "OK" : "NG"); printf("complex backward : %s\n", check_cb(n, mode, veclen, sizeOfVect) ? "OK" : "NG"); printf("real forward : %s\n", check_rf(n, mode, veclen, sizeOfVect) ? "OK" : "NG"); printf("real backward : %s\n", check_rb(n, mode, veclen, sizeOfVect) ? "OK" : "NG"); exit(0); }