Reading single values from arrays


I have some 3d memory allocated on the device, using cudaPitchedPtr and cudaMalloc3D.

cudaExtent gridSize = make_cudaExtent(sizeof(float) * 32, 32, 32);

cudaPitchedPtr d_data;

CUDA_SAFE_CALL( cudaMalloc3D(&d_data, gridSize) );

And now I would like to read only a single float value from the memory, so there is no need to transfer all data from the device to the host.

I tried using the


, but that wasn’t successful. Any ideas ?


  • Glimberg

Look at the simpleTexture3D sample in the SDK for usage of memcopies to/from 3D CUDA arrays.

cudaMemcpyFromSymbol will copy data from CPU to GPU. Is that your intended direction?