From 028441988360d010ac05106c2e625e367ee68cc8 Mon Sep 17 00:00:00 2001 From: Steve Macenski Date: Mon, 2 Oct 2023 13:21:46 -0700 Subject: [PATCH] add option for sse4 and avs512 (#3853) (cherry picked from commit 7274811c5cb512a05b87523183e29e75ace77f4a) --- nav2_mppi_controller/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nav2_mppi_controller/CMakeLists.txt b/nav2_mppi_controller/CMakeLists.txt index 9d8e0d690d..5f0c5359db 100644 --- a/nav2_mppi_controller/CMakeLists.txt +++ b/nav2_mppi_controller/CMakeLists.txt @@ -36,9 +36,19 @@ nav2_package() include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-mno-avx512f" COMPILER_SUPPORTS_AVX512) +check_cxx_compiler_flag("-msse4.2" COMPILER_SUPPORTS_SSE4) check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2) check_cxx_compiler_flag("-mfma" COMPILER_SUPPORTS_FMA) +if(COMPILER_SUPPORTS_AVX512) + add_compile_options(-mno-avx512f) +endif() + +if(COMPILER_SUPPORTS_SSE4) + add_compile_options(-msse4.2) +endif() + if(COMPILER_SUPPORTS_AVX2) add_compile_options(-mavx2) endif() @@ -48,7 +58,7 @@ if(COMPILER_SUPPORTS_FMA) endif() # If building one the same hardware to be deployed on, try `-march=native`! -add_compile_options(-O3 -finline-limit=10000000 -ffp-contract=fast -ffast-math -mtune=generic -mno-avx512f) +add_compile_options(-O3 -finline-limit=10000000 -ffp-contract=fast -ffast-math -mtune=generic) add_library(mppi_controller SHARED src/controller.cpp