小编Sac*_*aki的帖子

在CUDA中使用SIMD实现位旋转运算符

我知道StackOverflow不是为了向其他人询问代码,而是让我说话.

我正在尝试在CUDA C++设备代码中实现一些AES函数.在尝试实现左侧按字节旋转运算符时,我感到不安的是看到没有原生的SIMD内向.所以我开始了一个天真的实现,但......它是巨大的,虽然我还没有尝试过,但由于昂贵的拆包/打包,它不会很快......所以,有什么意思吗每字节位旋转操作至少有些效率?

如果您不想看看,这是代码.

__inline__ __device__ uint32_t per_byte_bit_left_rotate(uint32_t input, uint8_t amount) {
return ((((input & 0xFF) >> 0) << amount) | (((input & 0xFF) >> 0) >> 7) & ~0x100) << 0 |
     ((((input & 0xFF00) >> 8) << amount) | ((input & 0xFF00 >> 8) >> 7) & ~0x100) << 8 |
     ((((input & 0xFF0000) >> 16) << amount) | ((input & 0xFF0000 >> 16) >> 7) & ~0x100) << 16 |
     ((((input & 0xFF000000) >> 24) …
Run Code Online (Sandbox Code Playgroud)

c++ cuda simd bitwise-operators

6
推荐指数
2
解决办法
1103
查看次数

标签 统计

bitwise-operators ×1

c++ ×1

cuda ×1

simd ×1