AVX convert 64 bit integer to 64 bit float

女生的网名这么多〃 提交于 2019-12-04 10:59:00

All of the cast intrinsics perform a bitwise cast, which is why you're not seeing meaningful results with that.

A vector conversion (the cvt intrinsics) between 64-bit integer and 64-bit float does not exist.

For what it's worth, I looked in Agner Fog's vectorclass to see how he does it. He simply stores the 64-bit integers to an array and casts each array value to a double. It's inefficient but it works.

From file "vectorf256.h":

// function to_double: convert integer vector elements to double vector (inefficient)
static inline Vec4d to_double(Vec4q const & a) {
    int64_t aa[4];
    a.store(aa);
    return Vec4d(double(aa[0]), double(aa[1]), double(aa[2]), double(aa[3]));
}

// function to_double: convert integer vector to double vector
static inline Vec4d to_double(Vec4i const & a) {
    return _mm256_cvtepi32_pd(a);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!