I wrote a first cuda testing program and it doesn’t work. I hope someone can help me!
I wrote the following function to “initialize” an array in gpu-memory space:
global void VekIni(float3* Vektor)
int i = threadIdx.x;
Vektor[i].x = 1.1f;
Vektor[i].y = 1.2f;
Vektor[i].z = 1.3f;
And i start the function with:
cudaMalloc((void**)&cudaVektor2, N * sizeof(float3));
VekIni<<<1 , N>>>(cudaVektor2);
Then i copy the array back to host-memory space (array “Vektor2” is also initialized, “N” is some integer):
cudaMemcpy(Vektor2, cudaVektor2, N * sizeof(float3), cudaMemcpyDeviceToHost);
And try to printf the x-component it in the console:
printf(“Vektor2[%d].x = %f \n”, i, Vektor2[i].x);
But i only get “zeros” (“0”) and not the “1.1” that should appear by the printf call…
Thx for any help!