pow的SSE类型 [英] pow for SSE types

查看:250
本文介绍了pow的SSE类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SSE类型进行一些明确的向量化计算,例如 __ m128 (在 xmmintrin.h 等中定义) ,但现在我需要将向量的所有元素提升到一些(相同的)权力,即理想情况下,我会想要像 __ m128 _mm_pow_ps(__ m128,float),不幸的是

I do some explicitly vectorised computations using SSE types, such as __m128 (defined in xmmintrin.h etc), but now I need to raise all elements of the vector to some (same) power, i.e. ideally I would want something like __m128 _mm_pow_ps(__m128, float), which unfortunately doesn't exist.

这是最好的方法是什么?我可以存储向量,调用 std :: pow 在每个元素,然后重新加载它。这是我能做的最好的吗?当自动向量化代码否则是很好的向量化的时,编译器如何实现对 std :: pow 的调用?是否有任何库提供了有用的功能?

What is the best way around this? I could store the vector, call std::pow on each element, and then reload it. Is this the best I can do? How do compilers implement a call to std::pow when auto-vectorising code that otherwise is well vectorisable? Are there any libraries that provide something useful?

(请注意

(note that this question is related by not a duplicate and certainly doesn't have a useful answer.)

推荐答案

pow(x,y) exp(y * log(x)) c>和具有exp和log的SSE实现的库

Use the formula exp(y*log(x)) for pow(x, y) and a library with SSE implementations of exp and log.

这篇关于pow的SSE类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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