CUDA 中的逻辑移位
rshift = ((J[i]-1)*((2*net)-J[i]) >> -1);
L[i] = rshift + K[i]-J[i];
当我编译它时,我得到与第一行相对应的“错误:表达式必须具有整数或枚举类型”。除了 'i' 之外,所有都具有双精度。
它不适用于左移或右移。我使用的是 Fedora 12,并且有 nvcc 3.2,V0.2.1221。对于c++(g++编译器),它工作得很好。
但是当我尝试它时,
rshift = ((J[i]-1)*((2*net)-J[i]) >>= -1);
L[i] = rshift + K[i]-J[i];
它是“错误:表达式必须是可修改的左值”,我尝试了很多,但无法修复它。有什么想法吗?
rshift = ((J[i]-1)*((2*net)-J[i]) >> -1);
L[i] = rshift + K[i]-J[i];
when i compile this, i get "error: expression must have integral or enum type" corresponding to the first line. except for 'i' all have double precision.
it works for neither left nor right shift. i'm using fedora 12 and i have nvcc 3.2, V0.2.1221. for c++(g++ compiler), it works perfectly.
but when i tried it for
rshift = ((J[i]-1)*((2*net)-J[i]) >>= -1);
L[i] = rshift + K[i]-J[i];
it was "error: expression must be a modifiable lvalue" i tried a lot and couldn't fix it. any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答这个问题 - CUDA C(也不是 C,也不是 C++)中不存在浮点类型位移位之类的东西。通过评论中发布的问题,混乱的根源似乎是翻译一些旧版 Fortran 代码的错误尝试,其中也没有浮点位移支持。
To answer the question - there is no such thing as bit shifting of floating point types in CUDA C (nor C, nor C++). And through questions posted in comments it would appear that the source of the confusion was an incorrect attempt to translate some legacy Fortran code, where there also is no floating point bit shift support.