Possibility to retrieve 1 elemen from device array

Is it possible to retrieve on host side 1 element from an array that is located on device memory with a simple cudaMemcpy or something similar without having to copy the whole array to the host side.

can’t we just access that element on the device side and pass that back to the host side?
depending on what that element is we might not even need a memCpy.

Absolutely. You just have to give the correct address and number of bytes to copy to the memcopy call. For example, say you have an array of 1000s of ints on the device and you want to get just the one at index 13. So your code might look something like:

int x;

cudaMemcpy(&x, &d_a[13], sizeof(int), cudaMemcpyDeviceToHost);


Thank you so much Paulius. Never thought about this.