您如何将这个“无符号整数”标量代码移植到“有符号整数”向量?

问题描述

我需要将 Xorshift 算法从标量移植到矢量代码(SSE/SIMD 版本使用 -march=nocona 构建)。 我正在使用算法的 uint32_t 版本(直接取自 wiki):

#include <stdint.h>

struct xorshift32_state {
  uint32_t a;
};

/* The state word must be initialized to non-zero */
uint32_t xorshift32(struct xorshift32_state *state)
{
    /* Algorithm "xor" from p. 4 of Marsaglia,"Xorshift RNGs" */
    uint32_t x = state->a;
    x ^= x << 13;
    x ^= x >> 17;
    x ^= x << 5;
    return state->a = x;
}

主要问题是:

  1. 它使用 uint32,所以(按照标准)它会自动环绕
  2. 由于 SSE3 的“限制”,我会继续使用 m128i(我相信它已签署,并提供我需要的所有操作)
  3. 有符号溢出是 C++ 标准中未定义的行为

您将如何使用 SIMD 管理此移植?处理 epu32 并减去 uint32 最大值的一半(然后添加)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...