Linux运行SSE指令集出错

时间:2024-03-23 16:22:35

Linux运行有关SSE指令集代码出错:error: inlining failed in call to always_inline ‘int _mm_popcnt_u32(unsigned int)’: target specific option mismatch
_mm_popcnt_u32 (unsigned int __X)

先查看自己电脑的CPU是否支持sse指令集:
如何查看是否支持指令集
然后进入网站:https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=3828
查看报错函数对应的指令集(以我的这个错误为例)
for example:
Linux运行SSE指令集出错
搜索框里是报错的指令,下方是对应的指令集,在自己编写的CMakeLists.txt中添加:
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -mpopcnt”)
再执行代码,即可编译成功。