问题
I am fairly new to CUDA and am familiar with the normal usage of cudaMalloc and cudaMemcpy and also with cudaMemcpyToSymbol for copying to constant memory.
However, I have just been given some code which makes frequent use of cudaGetSymbolAddress and cudaMemcpyToSymbol to copy to global memory and I'm not sure why they have chosen to do this instead of cudaMalloc/cudaMemcpy.
Would somebody be able to explain when it is advantageous and appropriate to use cudaGetSymbolAddress and cudaMemcpyToSymbol?
Thank you!
回答1:
When global memory is allocated dynamically using cudaMalloc, then the correct copying API to use is cudaMemcpy.
When global memory is allocated statically:
__device__ int my_data[DSIZE];
then the correct API to use is cudaMemcpyToSymbol or cudaMemcpyFromSymbol
来源:https://stackoverflow.com/questions/24435132/appropriate-usage-of-cudagetsymboladdress-and-cudamemcpytosymbol-with-global-mem