如何将两个 __m128 值组合为 __m256? [英] How to combine two __m128 values to __m256?

查看:38
本文介绍了如何将两个 __m128 值组合为 __m256?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将两个 __m128 值合并为一个 __m256.

I would like to combine two __m128 values to one __m256.

像这样:

__m128 a = _mm_set_ps(1, 2, 3, 4);
__m128 b = _mm_set_ps(5, 6, 7, 8);

类似于:

__m256 c = { 1, 2, 3, 4, 5, 6, 7, 8 };

是否有任何内在函数可用于执行此操作?

are there any intrinsics that I can use to do this?

推荐答案

这应该可以满足您的需求:

This should do what you want:

__m128 a = _mm_set_ps(1,2,3,4);
__m128 b = _mm_set_ps(5,6,7,8);

__m256 c = _mm256_castps128_ps256(a);
c = _mm256_insertf128_ps(c,b,1);

如果顺序与你想要的相反,那么只需切换ab.

If the order is reversed from what you want, then just switch a and b.

感兴趣的内在是 _mm256_insertf128_ps,它可以让您将 128 位寄存器插入到 256 位 AVX 寄存器的下半部分或上半部分:

The intrinsic of interest is _mm256_insertf128_ps which will let you insert a 128-bit register into either lower or upper half of a 256-bit AVX register:

http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011/compiler_c/intref_cls/common/intref_avx_insertf128_ps.htm

他们的完整家庭在这里:

The complete family of them is here:

这篇关于如何将两个 __m128 值组合为 __m256?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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