CUDA常量存储符号 [英] CUDA constant memory symbols

查看:88
本文介绍了CUDA常量存储符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CUDA 5.0,并且我有单独编译的模块。
我想从所有模块访问常量存储器中的相同值。
问题如下,当我在每个
模块中定义符号时,链接器声称该符号已被重新定义。
是否有解决此问题的方法或解决方案?
谢谢您的帮助。

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.

推荐答案

在CUDA单独的编译模式下,有一个真正的链接器,并且每个符号被链接到最终设备的二进制有效载荷中,很多都可以唯一定义。这意味着__constant__内存符号只能在链接在一起的所有代码中的一个位置定义。

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.

解决方案可能是将符号声明为 extern 在除包含符号定义的一个翻译单元作用域外。请注意,这是将extern与__constant__符号一起使用的唯一情况,否则它们是隐式静态的。对单独的编译模型进行了一般性的讨论,它描述了文档(编程指南和nvcc手册IIRC)中所包含的这种情况。

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

这篇关于CUDA常量存储符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆