CudaMemcpy fails Memcpy fails


I’m new to CUDA and to this board. I was able to memcpy a dozen times, but instantly memcpy does not work for this small code. Could anyone please help me to find out where an error is.

Thank you in advance.

Here’s the debugging code. I just want to copy an array to device and back. But somehow there is an error that in my second printout all of the F still remain 0;

mesh->numPoints = 15;

cudaMalloc((void**)&(mesh->F), sizeof(float) * mesh->numPoints*3);	

float *F = (float*)malloc(sizeof(float) * mesh->numPoints*3);

for(int i = 0;i<mesh->numPoints*3;i++){


        printf("%.1f ",F[i]);


cudaMemcpy(mesh->F, F, sizeof(float) * mesh->numPoints*3, cudaMemcpyHostToDevice);

printf("\n\n F   ");

for(int i = 0;i<mesh->numPoints*3;i++){



cudaMemcpy(F,mesh->F, mesh->numPoints * 3, cudaMemcpyDeviceToHost);

for(int i=0; i < mesh->numPoints*3; i++){

        printf(" %.1f",F[i]);


-What type has mesh->F?
-Check the return values of the cuda calls (cudaMalloc, cudaMemcpy)!

It wouldn’t explain why all F remain 0, but you’d also want to fix the missing [font=“Courier New”]sizeof(float) *[/font] in the second cudaMemcpy.