无法对 long double 数据类型进行 openMP 矢量化操作吗? [英] Is openMP vectorization operations on long double datatype not possible?

查看:28
本文介绍了无法对 long double 数据类型进行 openMP 矢量化操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 openMP,以我有限的知识,我的代码被并行化了.我正在尝试使用 openMP 矢量化技术改进此代码.但是在浏览相关阅读材料时(link),我发现这是不可能的对 long double 数据类型进行矢量化操作.有人可以提供有关原因的信息并提出除降低精度之外的解决方案吗?

I'm learning openMP and with my limited knowledge, have parallised my code. I'm trying to improve this code using openMP vectorisation techniques. But while going through relevant reading materials(link), I found it is not possible to do vectorisation operations on long double datatype. Can someone provide information on why it is so and suggest a solution other than to reduce the precision?

链接中的内容如下:避免SIMD硬件不支持的操作.Linux上(80位)长双精度算术,余数运算符%"是SIMD硬件不支持的操作示例."

The content in the link is as follows: "Avoid operations not supported in SIMD hardware. Arithmetic with (80 bit) long doubles on Linux, and the remainder operator "%" are examples of operations not supported in SIMD hardware. "

附言我正在使用 INTEL C++ 编译器 16.0.2、具有 128 位长向量寄存器和 Linux 的 INTEL XEON 处理器.我的数据类型大多是 long double.

P.S. I'm using INTEL C++ compiler 16.0.2, INTEL XEON processsor with 128bit long vector register and Linux. My datatypes are mostly long double.

推荐答案

x86 指令集的 SIMD 指令仅支持 32 位和 64 位浮点运算(对 16 位浮点数的支持有限).此外,即使有 64 位乘以 64 位到 128 位标量整数指令(例如 mulx),也没有相应的 SIMD 指令.许多人尝试过但未能实现高效的 128 位整数 x86 SIMD 算法(乘法 可能还有添加).没有通用的 x86 SIMD 整数除法指令.

The SIMD instructions of the x86 instruction set only support 32-bit and 64-bit floating point operations (with some limited support for 16-bit floats). Additionally, even though there are 64-bit times 64-bit to 128-bit scalar integer instructions (e.g. mulx) there are no corresponding SIMD instructions. Many people have tried and failed to implement efficient 128-bit integer x86 SIMD arithmetic (there are some exceptions for multiplication and maybe addition). There are no general x86 SIMD integer division instructions.

然而,对于浮点数,人们使用 双双.与具有 80 位长双精度的 64 位精度相比,双精度具有 106 位精度.但并非每个 C++ 编译器都使用 80 位长双精度.有些只使用只有 54 位精度的双精度(例如 MSVC),有些使用具有 113 位精度的 128 位四精度,维基百科甚至声称在某些编译器中 long double 被实现为 double-double.

However, for floating point people have had more success with higher precision floating point SIMD operations using double-double. Double-double has 106-bits of precision compared with 64-bits of precision with 80-bit long double. But not every C++ compiler uses 80-bit long double. Some just use double (e.g. MSVC) which only has 54-bits of precision and some use 128-bit quad precision which has 113 bits of precision and Wikipedia even claims that with some compilers long double is implemented as double-double.

我在这里描述了双倍的一些细节.请注意,double-double 不是 IEEE 浮点类型,它具有一些不寻常的属性.此外,double-double 的范围与 double 相同,因此它只会提高精度.

I described some details of double-double here. Note that double-double is not a IEEE floating point type and it has some unusual properties. Also, the range of double-double is the same as double so it only improves the precision.

double double 与 long double 相比有多快?我从来没有测试过这个.但是我发现在进行乘法和加法运算的某种平衡组合时,double-double 比 double 运算慢 10 倍左右.并且 long double 肯定比 double 慢(除非它作为 double 实现).但是由于您可以将 SIMD 与 double-double 一起使用,但不能与内置 long double 一起使用,因此速度提高与 SIMD 宽度成正比.所以 SSE2 有 2 次双双运算,AVX 有 4 次,AVX512 有 8 次.

How fast is double-double compared to long double? I have never tested this. But I found double-double to be about 10 times slower than double operations when doing a somewhat balanced mix of multiplication and addition operations. And long double is certainly slower than double (except when it's implemented as a double). But since you can use SIMD with double-double, but not with the bulit-in long double, then the speed improves proportional to the SIMD width. So 2 double-double operations with SSE2, 4 with AVX, and 8 with AVX512.

不要指望 OpenMP 的 simd 构造实现双倍.您需要自己实现它或找到一个库.

Don't expect OpenMP's simd construction to implement double-double though. You will need to implement this yourself or find a library.

这篇关于无法对 long double 数据类型进行 openMP 矢量化操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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