CUDA常量内存无效符号
struct d_struct {
// stuff
};
__device__ __constant__ d_struct structs[SIZE];
当我调用
cudaMemcpyToSymbol("structs", &h_struct, sizeof(d_struct), index * sizeof(d_struct), cudaMemcpyHostToDevice)
主机内存中的 d_struct "h_struct"
时,我收到 无效设备符号
cuda 错误。
struct d_struct {
// stuff
};
__device__ __constant__ d_struct structs[SIZE];
When I call
cudaMemcpyToSymbol("structs", &h_struct, sizeof(d_struct), index * sizeof(d_struct), cudaMemcpyHostToDevice)
on a d_struct "h_struct"
in host memory, I get an invalid device symbol
cuda error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以提供更多详细信息,将会有所帮助,例如您正在运行什么平台以及哪个主机编译器版本?哪个 CUDA 工具包版本?什么设备?
同时,一些建议:
cudaMemcpyToSymbol()
?如果没有,那么它应该仍然可以工作,因为查找是通过名称而不是符号完成的,但请检查您是否没有将其声明为extern "C"
并且您正在从 C++ 调用If you can provide more details it will help, for example what platform are you running on and which host compiler version? Which CUDA toolkit version? What device?
In the meantime, some suggestions:
cudaMemcpyToSymbol()
from the same file where the constant is declared? If not, then it should still work since the lookup is done by name rather than symbol but check that you haven't declared it asextern "C"
and that you are calling from C++在 CUDA 编程指南 v4.2 D.2.2.1,它说
In CUDA Programming Guide v4.2 D.2.2.1, it says that