SIMD和标量和标量双精度之间的区别 [英] SIMD and difference between packed and scalar double precision

查看:252
本文介绍了SIMD和标量和标量双精度之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在实现SIMD支持时,我正在阅读英特尔的内在指南.我有些困惑,我的问题如下.

I am reading Intel's intrinsics guide while implementing SIMD support. I have a few confusions and my questions are as below.

  1. __m128 _mm_cmpeq_ps (__m128 a, __m128 b)文档说,它用于比较压缩的单精度浮点数. 打包"是什么意思?在使用浮点值之前,是否需要进行打包?

  1. __m128 _mm_cmpeq_ps (__m128 a, __m128 b) documentation says it is used to compare packed single precision floating points. What does "packed" mean? Do I need to pack my float values somehow before I can use them?

对于双精度,有类似_mm_cmpeq_sd的内在函数,这意味着比较较低"的双精度浮点元素.上下双精度元素是什么意思?是否可以使用它们比较C ++ double类型元素的向量?还是在比较它们之前需要以某种方式处理它们?

For double precision there are intrinsics like _mm_cmpeq_sd which means compare the "lower" double precision floating point elements. What does lower and upper double precision elemtns mean? Can I use them to compare a vector of C++ double type elements or not? Or do I need to process them in some way before I compare them?

推荐答案

在SSE中,128位寄存器可以表示为32位的4个元素.

In SSE, the 128 bits registers can be represented as 4 elements of 32 bits.

SSE定义了两种类型的操作;标量和包装.标量运算仅对最低有效的数据元素(位0〜31)进行运算,而打包运算将并行计算所有四个元素.

SSE defines two types of operations; scalar and packed. Scalar operation only operates on the least-significant data element (bit 0~31), and packed operation computes all four elements in parallel.

_mm_cmpeq_sd仅比较两个操作数中最低有效的数据元素(前32位),而_mm_cmpeq_ps将并行比较每组32位.

_mm_cmpeq_sd would only compare the least-significant data element (first 32 bits) of the two operands while _mm_cmpeq_ps would compare each group of 32 bits in parallel.

如果您使用64位double,则可以成对打包double以利用128位空间.这样,_mm_cmpeq_ps可以并行进行4个double的两个比较.

If you're using 64 bits double, you could pack the double by pair to make use of the 128 bits space. That way, _mm_cmpeq_ps would be able to make two comparaison of 4 double in parallel.

如果您一次只想进行一次比较,则您可以使用_mm_cmpeq_pd来比较两个64位双精度值.

If you want to make only one comparison at a time, you can use _mm_cmpeq_pd to compare two 64 bits double.

请注意,_mm_cmpeq_pd是SSE2,而_mm_cmpeq_ps是SSE.

Note that _mm_cmpeq_pd is SSE2 while _mm_cmpeq_ps is SSE.

这篇关于SIMD和标量和标量双精度之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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