I copy 2 unsigned int values from device to host with
cudaMemcpy(h_etns, d_etns, 2*sizeof(d_etns[0]), cudaMemcpyDeviceToHost);
The strange thing is that when I filled
d_etns[0]=25
d_etns[1]=35
in the kernel routine
but on the host side I find
h_etns[0]=0
h_etns[1]=25
If I extend it to 3 numbers the data on the host seems one shifted
Is there a minimum size for data transfers with cudaMemcpy?
float *memoirecpu1, *memoiregraphique1; // Pointer to host & device arrays
size_t size = N * sizeof(float);
//---------------------------
cudaMalloc((void **) &memoiregraphique1, size); // Allocate array on device
cudaMemcpy(memoiregraphique1, memoirecpu1, size, cudaMemcpyHostToDevice);
seem to work with N=2
.
Should definitely work with any size.
This
however makes me think you have an out of bounds access somewhere in your kernel (or in the memcopies).
Do you mean that an out of bound write to some other array overwrites the first value of my array under investigation?
But why does the data shift? You’d think it would dissapear? It seems more like either the read or write pointer changed.
it really seems like a shift
h_etns = (unsigned int*) malloc(sizeof(unsigned int)4);
cutilSafeCall(cudaMalloc((void*) &d_etns, 4sizeof(unsigned int))); //
mstep(d_etns)
cudaMemcpy(h_etns, d_etns, 4sizeof(d_etns[0]), cudaMemcpyDeviceToHost);
h_etns(0)=0 h_etns(1)=25 h_etns[2]=34 h_etns[3]=49
in mstep a kernel is called in which the only assignment of d_etns is:
d_etns[0]=25;
d_etns[1]=34;
d_etns[2]=49;
It really seems like the pointer has moved 1 position.
P.S. Sorry for wasting people’s time. I made a mistake (there was another variable in my printf statement I overlooked)
can you post a full repro case?
Sorry, I made a stupid error (see previous p.s.). It’s ok to remove this thread as far as I’m concerned.