我有以下代码:
complex<double> data[n2][n1][n0];
//data_device is the equivalent double* vector in the device memory
cErr = cufftPlan3d(&planBWD, n2, n1, n0, CUFFT_Z2Z);
cufft_error_check(cErr, __LINE__);
cErr = cufftExecZ2Z(planBWD, (cufftDoubleComplex*)data_device,(cufftDoubleComplex*) data_device, CUFFT_INVERSE);
cufft_error_check(cErr, __LINE__);
我和
FFTW
库比较后得到了相同的结果,所以我认为没问题。
这段代码在相同长度的不同向量上循环重复batches
次(每次迭代都将对应的向量复制到data_device
);因此,我想执行一个批处理的 3D-FFT。我做:
int n[3]; n[0]=n2; n[1]=n1, n[2]=n0;
int in[3]; in[0]=n[0]; in[1]=n[1]; in[2]=n[2];
int out[3]; out[0]=n[0]; out[1]=n[1]; out[2]=n[2];
int nelem=n2*n1*n0;
cErr = cufftPlanMany(&planBWDbatch,3,n,in, 1,nelem, out, 1, nelem, CUFFT_Z2Z, batches);
cufft_error_check(cErr,__LINE__);
cErr = cufftExecZ2Z(planBWDbatch, (cufftDoubleComplex*)data_device,(cufftDoubleComplex*) data_device, CUFFT_INVERSE);
cufft_error_check(cErr,__LINE__);
在哪里
data_device
现在有以下布局:data[batches][n2][n1][n0]
。然而,结果不同。关于我做错了什么的任何线索?
谢谢。