将两个32位整数的向量相乘,生成一个32位结果元素的向量 [英] Multiply two vectors of 32bit integers, producing a vector of 32bit result elements
问题描述
将两个_mm256i
寄存器的每个32位条目彼此相乘的最佳方法是什么?
What is the best way to multiply each 32bit entry of two _mm256i
registers with each other?
_mm256_mul_epu32
不是我想要的,因为它会产生64位输出.我希望每个32位输入元素都具有32位结果.
_mm256_mul_epu32
is not what I'm looking for because it produces 64bit outputs. I want a 32bit result for every 32bit input element.
此外,我确定两个32位值的乘法不会溢出.
Moreover, I'm sure that the multiplication of two 32bit values will not overflow.
谢谢!
推荐答案
您需要_mm256_mullo_epi32()
内在函数.摘自Intel出色的在线内在函数指南:
You want the _mm256_mullo_epi32()
intrinsic. From Intel's excellent online intrinsics guide:
简介
__m256i _mm256_mullo_epi32 (__m256i a, __m256i b)
#include "immintrin.h"
Instruction: vpmulld ymm, ymm, ymm CPUID Flags: AVX2
说明
将a和b中的压缩32位整数相乘, 产生中间的64位整数,并存储低32位的 dst中的中间整数.
Description
Multiply the packed 32-bit integers in a and b, producing intermediate 64-bit integers, and store the low 32 bits of the intermediate integers in dst.
这篇关于将两个32位整数的向量相乘,生成一个32位结果元素的向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!