inlining failed in call to always_inline ‘_mm_mullo_epi32’: target specific option mismatch

后端 未结 2 879
生来不讨喜
生来不讨喜 2020-12-06 06:27

I am trying to compile a C program using cmake which uses SIMD intrinsics. When I try to compile it, I get two errors

/usr/lib/gcc/x86_64-linux-gnu/5/include/

相关标签:
2条回答
  • 2020-12-06 06:46

    A general method to find the instruction switch for gcc

    File intrin.sh:

    #!/bin/bash
    
    get_instruction ()
    {
        [ -z "$1" ] && exit
        func_name="$1 "
    
        header_file=`grep --include=\*intrin.h -Rl "$func_name" /usr/lib/gcc | head -n1`
        [ -z "$header_file" ] && exit
        >&2 echo "find in: $header_file"
    
        target_directive=`grep "#pragma GCC target(\|$func_name" $header_file | grep -B 1 "$func_name" | head -n1`
        echo $target_directive | grep -o '"[^,]*[,"]' | sed 's/"//g' | sed 's/,//g'
    }
    
    instruction=`get_instruction $1`
    if [ -z "$instruction" ]; then
        echo "Error: function not found: $1"
    else
        echo "add this option to gcc: -m$instruction"
    fi
    

    Usage:

    ./intrin.sh _mm_shuffle_epi8      # output: -mssse3
    ./intrin.sh _mm_cvtepu8_epi32     # output: -msse4.1
    ./intrin.sh _mm_loadu_ps          # output: -msse
    ./intrin.sh _mm_clmulepi64_si128  # output: -mpclmul
    ./intrin.sh _mm256_loadu_si256    # output: -mavx
    ./intrin.sh _mm512_and_ps         # output: -mavx512dq
    
    0 讨论(0)
  • 2020-12-06 07:05

    Since you are compiling C code, not C++, you need:

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
    

    You can get rid of all the other -march XXX and -msseXXX settings.

    If you're using a mix of C and C++ then you could also add:

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
    
    0 讨论(0)
提交回复
热议问题