AVX寄存器中的和对 [英] sum pairs in an AVX register

查看:126
本文介绍了AVX寄存器中的和对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有8个花车的_m256:







i想要添加一对值:(0 + 4,1 + 5,2 + 6,3 + 7)



i have an _m256 with 8 floats in it:



i want to add pairs of values : (0+4, 1+5, 2+6, 3+7)

__m256 i;

... i gets some values...
 and then...
i = {
   i.m256_f32[0] + i.m256_f32[4], 
   i.m256_f32[1] + i.m256_f32[5], 
   i.m256_f32[2] + i.m256_f32[6], 
   i.m256_f32[3] + i.m256_f32[7], 
   x, x, x, x
};



x =不在乎

< SSE中的
,我会将4,5,6,7拖入新的寄存器然后添加两个,但我找不到_mm256_shuffle_ps的任何好文档。



有谁知道怎么做?


x = don't care

in SSE, i would shuffle the 4,5,6,7 into a new register then add the two, but i can't find any good docs for _mm256_shuffle_ps.

anyone know how to do this?

推荐答案

nevermind ...



nevermind...

__m256 j = _mm256_permute2f128_ps(i, i, (1 << 0) | (1 << 1));
i = _mm256_add_ps(i,j);


这篇关于AVX寄存器中的和对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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