C: x86 Intel Intrinsics usage of _mm_log2_ps() -> error: incompatible type 'int'?

给你一囗甜甜゛ 提交于 2019-12-13 13:25:37

问题


I'm trying to apply the log2 onto a __m128 variable. Like this:

#include <immintrin.h>
int main (void) {
    __m128 two_v = {2.0, 2.0, 2.0, 2.0};
    __m128 log2_v = _mm_log2_ps(two_v); // log_2 := log(2)

    return 0;
}

Trying to compile this returns this error:

error: initializing '__m128' with an expression of
      incompatible type 'int'
                __m128 log2_v = _mm_log2_ps(two_v); // log_2 := log(2)
                       ^        ~~~~~~~~~~~~~~~~~~

How can I fix it?


回答1:


The immintrin.h you look into and immintrin.h used for compilation are different. Likely, you're looking into Intel-specific header (somewhere like /opt/intel/include/immintrin.h), while your compiler uses default immintrin.h

As it was correctly said, extern __m128 _mm_log2_ps(__m128 v1) is SVML routine, so the very first solution I see is to use Intel Compiler. For non-commercial development its free for Linux.

Although you can specify the include path to your custom immintrin.h file as a very first argument during compilation using different compiler, but I think you'll get just way too many errors - just because this header is Intel-specific.



来源:https://stackoverflow.com/questions/20123750/c-x86-intel-intrinsics-usage-of-mm-log2-ps-error-incompatible-type-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!