CUDA constant memory symbols

☆樱花仙子☆ 提交于 2020-01-05 05:39:07

问题


I am using CUDA 5.0 and I have modules which are compiled separately. I would like to access the same value in the constant memory from all modules. The problem is the following, when I define the symbol in each module the linker claims that the symbol has been redefined. Is there a workaround or a solution for this problem? Thank you for helping.


回答1:


In CUDA separate compilation mode, there is a true linker, and every symbol which is linked into the final device binary payload much be uniquely defined. This means __constant__ memory symbols must be only be defined in one place in all the code which is linked together.

The solution is probably to declare the symbol as extern at every translation unit scope except one, which contains the definition of the symbol. Note that this is the only case where it is valid to use extern with __constant__ symbols, otherwise they are implicitly static. There is a general discussion of the separate compilation model which describes this scenario buried in the documentation (both the programming guide and nvcc manual IIRC).



来源:https://stackoverflow.com/questions/18213988/cuda-constant-memory-symbols

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