cuFFT sample Error: Segmentation fault

Hello

I’m trying to implement a 1D Complex to Complex Transform, using the example of the CUFFT documentation. When i run my programm i just get the error Segmentation fault.
Here is my source code:

[b] int N = pow(2.0,i);
cufftHandle p;
cufftComplex *in, out;
float
MWs;
MWs = new float [N];
Messwerte(N, 0, 1, MWs);

complex<float>* Trafo;
Trafo = new complex<float> [N];

cudaMalloc((void**)&in, sizeof(cufftComplex)*N);
cudaMalloc((void**)&out, sizeof(cufftComplex)*N);
cufftPlan1d(&p, N, CUFFT_C2C, 1);

for (int i = 0; i < N ; i++)
{
	in[i].x = MWs[i];
	in[i].y = 0.0;
}
    cufftExecC2C(p, in, out, 1);
for (int i = 0; i < N; i++)
{
	Trafo[i].real() = out[i].x;
	Trafo[i].imag() = out[i].y;
}
Vektorausgabe(Trafo,N);
delete[] Trafo; cufftDestroy(p); cudaFree(in);  cudaFree(out); delete[] MWs;[/b]

The Array MWs cotains the Data which i want to transform. The Error happens when i try to use the in and out arrays. Can anybody tell me, how to write data to the in array and read data from the out array?

Thanks alot

I solved the problem. I wrote a new source to perform a CuFFT. I don’t know where the problem is.

You can not write into device memory using host code. You need to fill out a host array first and then copy that array to device memory using cudaMemcpy(…,…,cudaMemcpyHostToDevice). Same goes for reading data on the device, you have to transfer the date back to host memory using cudaMemcpy(…,…,cudaMemcpyDeviceToHost) before the host can access the values.

N.