将__m256i设置为两个__m128i值的值 [英] Setting __m256i to the value of two __m128i values

查看:65
本文介绍了将__m256i设置为两个__m128i值的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,AVX具有 immintrin.h 中的功能,该功能应允许将两个 __ m128i 值的串联存储到单个 __ m256i 中价值.功能是

So, AVX has a function from immintrin.h, which should allow to store the concatenation of two __m128i values into a single __m256i value. The function is

__m256i _mm256_set_m128i (__m128i hi, __m128i lo)

但是,当我使用它时,就像这样:

However, when I use it, like so:

__m256i as[2]; __m128i s[4]; as[0] = _mm256_setr_m128i(s[0], s[1]);

我收到编译错误:

error: incompatible types when assigning to type ‘__m256i’ from type ‘int’

我真的不明白为什么会这样.任何帮助,我们将不胜感激!

I don't really understand why this happens. Any help is greatly appreciated!

推荐答案

并不是所有的编译器似乎都具有 _mm256_setr_m128i ,甚至没有在 immintrin中定义的 _mm256_set_m128i .h .因此,通常我只需要根据需要定义宏,并在适当的 #ifdef 后面加上括号,以测试编译器和版本:

Not all compilers seem to have _mm256_setr_m128i, or even _mm256_set_m128i, defined in immintrin.h. So I usually just define macros as needed, bracketed with suitable #ifdefs which test for compiler and version:

#define _mm256_set_m128i(v0, v1)  _mm256_insertf128_si256(_mm256_castsi128_si256(v1), (v0), 1)

#define _mm256_setr_m128i(v0, v1) _mm256_set_m128i((v1), (v0))

  • Intel ICC 11.1和更高版本同时具有 _mm256_set_m128i _mm256_setr_m128i .

    MSVC 2012及更高版本仅具有 _mm256_set_m128i .

    MSVC 2012 and later has just _mm256_set_m128i.

    gcc/clang似乎也没有,尽管我还没有检查最新版本以查看是否已解决.

    gcc/clang don't seem to have either, although I haven't checked recent versions to see if this has been fixed yet.

    这篇关于将__m256i设置为两个__m128i值的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆