Appropriate usage of cudaGetSymbolAddress and cudaMemcpyToSymbol with global memory?

谁都会走 提交于 2021-02-05 07:56:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!