使用 SSE 在 __m128i 向量中获取最大值? [英] Getting max value in a __m128i vector with SSE?

查看:35
本文介绍了使用 SSE 在 __m128i 向量中获取最大值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 SSE,我很困惑如何获得 __m128i 的最大整数值 (max).例如:

I have just started using SSE and I am confused how to get the maximum integer value (max) of a __m128i. For instance:

__m128i t = _mm_setr_ps(0,1,2,3);
// max(t) = 3;

四处搜索使我找到了 MAXPS 指令,但我似乎无法找到如何将其与 "xmmintrin.h" 一起使用.

Searching around led me to MAXPS instruction but I can't seem to find how to use that with "xmmintrin.h".

另外,是否有任何您会推荐的 "xmmintrin.h" 文档,而不是查看头文件本身?

Also, is there any documentation for "xmmintrin.h" that you would recommend, rather than looking into the header file itself?

推荐答案

如果您发现自己需要对向量进行水平操作,尤其是在内循环中,那么通常表明您以错误的方式接近您的 SIMD 实现.SIMD 喜欢在向量上按元素操作——如果你愿意,可以垂直"操作,而不是水平操作.

If you find yourself needing to do horizontal operations on vectors, especially if it's inside an inner loop, then it's usually a sign that you are approaching your SIMD implementation in the wrong way. SIMD likes to operate element-wise on vectors - "vertically" if you like, not horizontally.

至于文档,intel.com 上有一个非常有用的参考包含从 MMX 到各种 SSE 一直到 AVX 和 AVX-512 的所有操作码和内在函数.

As for documentation, there is a very useful reference on intel.com which contains all the opcodes and intrinsics for everything from MMX through the various flavours of SSE all the way up to AVX and AVX-512.

这篇关于使用 SSE 在 __m128i 向量中获取最大值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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