使用Intel AVX从压缩双精度向量存储单个双精度

编程入门 行业动态 更新时间:2024-10-26 12:24:30
本文介绍了使用Intel AVX从压缩双精度向量存储单个双精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用C内在函数编写英特尔AVX指令的代码.如果我有一个压缩的双矢量(__m256d),那么将每个矢量存储到内存中不同位置的最有效方法(即最少的操作数)是什么(即,我需要将它们散开到另一个位置)使其不再包装的位置)?伪代码:

I'm writing code using the C intrinsics for Intel's AVX instructions. If I have a packed double vector (a __m256d), what would be the most efficient way (i.e. the least number of operations) to store each of them to a different place in memory (i.e. I need to fan them out to different locations such that they are no longer packed)? Pseudocode:

__m256d *src; double *dst; int dst_dist; dst[0] = src[0]; dst[dst_dist] = src[1]; dst[2 * dst_dist] = src[2]; dst[3 * dst_dist] = src[3];

使用SSE,我可以使用_mm_storel_pi和_mm_storeh_pi内部函数对__m128类型执行此操作.我无法找到与AVX类似的任何东西,从而无法将单个64位片段存储到内存中.是否存在?

Using SSE, I could do this with __m128 types using the _mm_storel_pi and _mm_storeh_pi intrinsics. I've not been able to find anything similar for AVX that allows me to store the individual 64-bit pieces to memory. Does one exist?

推荐答案

您可以使用一些提取的解释器来做到这一点:(警告:未经测试)

You can do it with a couple of extract instrinsics: (warning: untested)

__m256d src = ... // data __m128d a = _mm256_extractf128_pd(src, 0); __m128d b = _mm256_extractf128_pd(src, 1); _mm_storel_pd(dst + 0*dst_dist, a); _mm_storeh_pd(dst + 1*dst_dist, a); _mm_storel_pd(dst + 2*dst_dist, b); _mm_storeh_pd(dst + 3*dst_dist, b);

您想要的是AVX2中的收集/分散说明...但这还需要几年的时间.

What you want is the gather/scatter instructions in AVX2... But that's still a few years down the road.

更多推荐

使用Intel AVX从压缩双精度向量存储单个双精度

本文发布于:2023-10-28 13:42:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536798.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:精度   向量   Intel   AVX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!