【发布时间】:2015-05-18 22:22:45
【问题描述】:
最近我开始使用 CUDA 和 Ethereum,我在一个函数上发现了一些代码片段,当我尝试移植到 cuda 文件时,我得到了一些错误。
这里是sn-p的代码:
void keccak_f1600_round(uint2* a, uint r, uint out_size)
{
#if !__ENDIAN_LITTLE__
for (uint i = 0; i != 25; ++i)
a[i] = make_uint2(a[i].y, a[i].x);
#endif
uint2 b[25];
uint2 t;
// Theta
b[0] = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20];
#if !__ENDIAN_LITTLE__
for (uint i = 0; i != 25; ++i)
a[i] = make_uint2(a[i].y, a[i].x);
#endif
}
我正在关注b[0] 行的错误是:
error: no operator "^=" matches these operands operand types are: uint2 ^= uint2
说实话,我对 uint2 和 cuda 没有太多经验,这就是为什么我要问我应该如何解决这个问题。
【问题讨论】:
-
显然
uint2不是数字类型;我认为这是一个结构。我对 CUDA 不熟悉,所以我没有更多的细节。 -
你希望这个操作员做什么?按位异或?你需要自己实现它。
-
@m.s.按位异或,通过自己实现,您应该添加两个参数(
a[0].x + a[0].y)而不是a[0]
标签: c cuda bit-manipulation uint