Sorry, it’s my fault. actually I have nxnynz*sizeof(float), as you have written.
However, it does not work.
What do you mean: you do not need the cudaMemset.
I need to copy “a” array to the cuda device.
The memset is not causing any issues, you just do not need it. It is like painting a wall white before you paint it green.
My uneducated guess would be that the operating system is reserving/using some of the device memory and will not let you allocate that size. Maybe there are some programs running in the background which also are using device memory.
There may be some OS setting you can modify to free up some space.
Probably the a variable you are passing to the function is not allocated to be large enough. You should show a complete code or at least the allocation of a. Are you allocating it on the stack? That likely won’t work.
Error At Lin10:
cudaMemcpy(cuda_a, a, nxnynz, cudaMemcpyHostToDevice);
Dear you are copying nxnynz bytes of memory. As you are working with FLOAT, you have to copy “nxnynz*sizeof(float)” amount of memory.
cudaMemcpy(cuda_a, a, nxnynz*sizeof(float), cudaMemcpyHostToDevice); will work for you.