CUDA constant memory symbols

2019-08-14 19:08发布

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条回答
Animai°情兽
2楼-- · 2019-08-14 19:31

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).

查看更多
登录 后发表回答