tags:

views:

41

answers:

2

Hi there, can somebody give me an advice in following. I am copying some data from CPU to GPU and i need to know whether its copied rigth. I can check the return code of cudeMemcpy, but it would much more better if i can print the array at GPU.

int doCopyMemory(char * Input, int InputBytes)
{
        /* Copying needed data on GPU */
    cudaError_t s = cudaMemcpy      ( SOURCE_DATA, Input, InputBytes, cudaMemcpyHostToDevice );
    if (s != cudaSuccess) return 0;
    else return 100;
}

I need to see the content of SOURCE_DATA after copying. Thx in advice.

+1  A: 

You could just copy the memory back again (cudaMemcpyDeviceToHost) to a different, temporary buffer on the host, and verify that this matches the original buffer.

Paul R
A: 

Are you saying that you have seen the copy be unsuccessful, but cudaMemcpy returns cudaSuccess? I've never seen that and if you have then you should submit a bug.

On the other hand, if you're just doing additional checks for some reason (paranoia?!) then you can just copy back. You can print from the GPU (check out cuPrintf in compute capability 1.x, or just use printf if you have a 2.x device) but for what you are doing you're better off copying back to the host.

Tom