581
社区成员
发帖
与我相关
我的任务
分享
void main()
{
int n = 100;
float2 *data_h = new float2[n];
for (int i=0; i<n; ++i)
{
data_h[i].x = i;
data_h[i].y = 0;
}
float2 *data_d;
cudaMalloc((void**)&data_d, n * sizeof(float2));
cudaMemcpy(data_d, data_h, n * sizeof(float2), cudaMemcpyHostToDevice);
static StopWatchInterface *timer;
sdkCreateTimer(&timer);
sdkStartTimer(&timer);
cufftHandle plan1;
cufftPlan1d(&plan1, n, CUFFT_C2C, 1);
sdkStopTimer(&timer);
cout<<"Create plan1: "<<sdkGetTimerValue(&timer)<<"ms"<<endl;
sdkResetTimer(&timer);
sdkStartTimer(&timer);
cufftExecC2C(plan1, data_d, data_d, CUFFT_FORWARD);
cufftDestroy(plan1);
sdkStopTimer(&timer);
cout<<"Execute plan1: "<<sdkGetTimerValue(&timer)<<"ms"<<endl;
sdkResetTimer(&timer);
sdkStartTimer(&timer);
cufftHandle plan2;
cufftPlan1d(&plan2, n, CUFFT_C2C, 1);
sdkStopTimer(&timer);
cout<<"Create plan2: "<<sdkGetTimerValue(&timer)<<"ms"<<endl;
sdkResetTimer(&timer);
sdkStartTimer(&timer);
cufftExecC2C(plan2, data_d, data_d, CUFFT_INVERSE);
cufftDestroy(plan2);
sdkStopTimer(&timer);
cout<<"Execute plan2: "<<sdkGetTimerValue(&timer)<<"ms"<<endl;
}