Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/FBGEMM.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoung Jin Kim <youki@microsoft.com>2021-03-22 05:36:20 +0300
committerYoung Jin Kim <youki@microsoft.com>2021-03-22 05:36:20 +0300
commit9f1183887e8de5cc85a039cf3dcc04cff9d4e9c0 (patch)
tree680f930aa405722d275d07310022ab7d70fe76b1
parent055d2a099c829563aff1fffdeb4594ad8cfe5d99 (diff)
Turn -march=native off when using gcc 9.3+
-rw-r--r--CMakeLists.txt13
1 files changed, 11 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e5dfa6..9d06ec2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,7 @@ else()
if(NOT COMPILER_SUPPORTS_AVX512)
message(FATAL_ERROR "A compiler with AVX512 support is required.")
endif()
+ # string(REPLACE "-march=native" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
#We should default to a Release build
@@ -123,8 +124,16 @@ set_target_properties(fbgemm_generic fbgemm_avx2 fbgemm_avx512 PROPERTIES
CXX_VISIBILITY_PRESET hidden)
if (NOT MSVC)
- target_compile_options(fbgemm_avx2 PRIVATE
- "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c")
+ # '-march=native' makes avx2 assembly generation fail on AVX512 CPUs with gcc 9.3+
+ if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.2)
+ message(WARNING "When built with gcc 9.3+, '-march=native' is disabled.")
+ target_compile_options(fbgemm_avx2 PRIVATE
+ "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c" "-march=x86-64")
+ else()
+ target_compile_options(fbgemm_avx2 PRIVATE
+ "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c")
+ endif()
+
target_compile_options(fbgemm_avx512 PRIVATE
"-m64" "-mavx2" "-mfma" "-mavx512f" "-mavx512bw" "-mavx512dq"
"-mavx512vl" "-masm=intel" "-mf16c")