Copying structure to device

I have structure

typedef struct

{

	int XNum;

	int YNum;

	float *Signal; // Signal =new float[XNum*YNum];

}sSignal;

Inside main host function I wrote:

sSignal *cpuSignal,*gpuSignal;

cpuSignal=new sSignal;

cpuSignal->XNum=10;

cpuSignal->YNum=10;

cpuSignal->Signal=new float[XNum*YNum]

/*....... Initializing Signal........*/

cudaMalloc((void**)&gpuSignal,sizeof(sSignal));

gpuSignal->XNum=cpuSignal->XNum;

gpuSignal->YNum=cpuSignal->YNum;

cudaMalloc((void**)&gpuSignal->Signal,sizeof(float)*cpuSignal->XNum*cpuSignal->YNum);

cudaMemcpy(gpuSignal->Signal,cpuSignal->Signal,sizeof(float)*cpuSignal->XNum*cpuSignal->YNum);

I know, that it’s no correct. Please tell me, how it shold be correct?

P.S. I’m using SDK 2.3.

I have tried it, but failed, as well…

So I don’t think it’s possible that we can use pointers in a structure, since that the current CUDA toolkit do not support pointer well…

I have tried it, but failed, as well…

So I don’t think it’s possible that we can use pointers in a structure, since that the current CUDA toolkit do not support pointer well…

Right answer:

typedef struct

{

	int *XNum;

	int *YNum;

	float *Signal; // Signal =new float[XNum*YNum];

}sSignal;

“Main” host function:

sSignal *cpuSignal,gpuSignal;

cpuSignal=new sSignal;

cpuSignal->XNum=new int[1];

cpuSignal->YNum=new int[1];

....

cpuSignal->Signal=new float[cpuSignal->XNum*cpuSignal->YNum]

/*....... Initializing Signal........*/

cudaMalloc((void**)&gpuSignal.XNum,sizeof(int);

cudaMemcpy(&gpuSignal.XNum,cpuSignal->XNum,sizeof(int));

and so on…

Right answer:

typedef struct

{

	int *XNum;

	int *YNum;

	float *Signal; // Signal =new float[XNum*YNum];

}sSignal;

“Main” host function:

sSignal *cpuSignal,gpuSignal;

cpuSignal=new sSignal;

cpuSignal->XNum=new int[1];

cpuSignal->YNum=new int[1];

....

cpuSignal->Signal=new float[cpuSignal->XNum*cpuSignal->YNum]

/*....... Initializing Signal........*/

cudaMalloc((void**)&gpuSignal.XNum,sizeof(int);

cudaMemcpy(&gpuSignal.XNum,cpuSignal->XNum,sizeof(int));

and so on…