假设我真的被迫记忆并想要一个更小的范围(类似于短与int).着色器语言已经支持short
具有精度一半的浮点(不只是来回转换为-1到1之间的值,也就是说,像这样返回一个浮点数:) int
.是否存在2字节浮点数已经存在的实现?
我也有兴趣知道为什么没有2字节浮点数的任何(历史?)原因.
在某些内在函数中,它们使用后缀,x
如_mm256_set1_epi64x
. 它的意义是什么?作为参考,_mm256_set1_epi32
没有这个后缀。
reinterpret_cast
afloat*
到 a__m256*
并float
通过不同的指针类型访问对象是否合法?
constexpr size_t _m256_float_step_sz = sizeof(__m256) / sizeof(float);
alignas(__m256) float stack_store[100 * _m256_float_step_sz ]{};
__m256& hwvec1 = *reinterpret_cast<__m256*>(&stack_store[0 * _m256_float_step_sz]);
using arr_t = float[_m256_float_step_sz];
arr_t& arr1 = *reinterpret_cast<float(*)[_m256_float_step_sz]>(&hwvec1);
Run Code Online (Sandbox Code Playgroud)
做hwvec1
和arr1
依赖undefined behavior
s 吗?
它们是否违反了严格的别名规则?[基本.lval]/11
或者只有一种定义的内在方式:
__m256 hwvec2 = _mm256_load_ps(&stack_store[0 * _m256_float_step_sz]);
_mm256_store_ps(&stack_store[1 * _m256_float_step_sz], hwvec2);
Run Code Online (Sandbox Code Playgroud)