mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-31 23:27:43 +00:00
Build options for enabling AVX/AVX2/AVX512 (#3373)
1. Add build options for enabling AVX/AVX2/AVX512 2. Update eigen to a newer version, because the current one doesn't work with VC and AVX512.
This commit is contained in:
parent
77c7d09ced
commit
accffded5d
3 changed files with 35 additions and 8 deletions
|
|
@ -139,7 +139,7 @@
|
|||
"component": {
|
||||
"type": "git",
|
||||
"git": {
|
||||
"commitHash": "efd9867ff0e8df23016ac6c9828d0d7bf8bec1b1",
|
||||
"commitHash": "54a0a9c9dd83aad42e79238ec8f0932b2a5e7881",
|
||||
"repositoryUrl": "https://gitlab.com/libeigen/eigen.git"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ option(onnxruntime_USE_PREINSTALLED_EIGEN "Use pre-installed EIGEN. Need to prov
|
|||
option(onnxruntime_BUILD_BENCHMARKS "Build ONNXRuntime micro-benchmarks" OFF)
|
||||
option(onnxruntime_USE_TVM "Build tvm for code-gen" OFF)
|
||||
option(onnxruntime_BUILD_FOR_NATIVE_MACHINE "Enable this option for turning on optimization specific to this machine" OFF)
|
||||
option(onnxruntime_USE_AVX "Use AVX instructions" OFF)
|
||||
option(onnxruntime_USE_AVX2 "Use AVX2 instructions" OFF)
|
||||
option(onnxruntime_USE_AVX512 "Use AVX512 instructions" OFF)
|
||||
option(onnxruntime_USE_LLVM "Build tvm with LLVM" OFF)
|
||||
option(onnxruntime_USE_OPENMP "Build with OpenMP support" OFF)
|
||||
option(onnxruntime_BUILD_SHARED_LIB "Build a shared library" OFF)
|
||||
|
|
@ -115,7 +118,7 @@ if(NOT WIN32)
|
|||
else()
|
||||
check_cxx_compiler_flag(/d2FH4- HAS_D2FH4)
|
||||
if (HAS_D2FH4)
|
||||
message("Enabling /d2FH4-")
|
||||
message("Disabling /d2FH4")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /d2FH4-")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2FH4-")
|
||||
endif()
|
||||
|
|
@ -208,8 +211,25 @@ if (MSVC)
|
|||
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link protobuf to static runtime libraries" FORCE)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib for gtest" FORCE)
|
||||
endif()
|
||||
#A compile option to improve code generation time, mostly for the code that heavily uses eigen.
|
||||
check_cxx_compiler_flag(/d2ReducedOptimizeHugeFunctions HAS_D2ROHF)
|
||||
if(HAS_D2ROHF)
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /d2ReducedOptimizeHugeFunctions")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /d2ReducedOptimizeHugeFunctions")
|
||||
endif()
|
||||
#Always enable exception handling, even for Windows ARM
|
||||
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
||||
string(APPEND CMAKE_CXX_FLAGS " /EHsc")
|
||||
string(APPEND CMAKE_C_FLAGS " /EHsc")
|
||||
if(onnxruntime_USE_AVX)
|
||||
string(APPEND CMAKE_CXX_FLAGS " /arch:AVX")
|
||||
string(APPEND CMAKE_C_FLAGS " /arch:AVX")
|
||||
elseif(onnxruntime_USE_AVX2)
|
||||
string(APPEND CMAKE_CXX_FLAGS " /arch:AVX2")
|
||||
string(APPEND CMAKE_C_FLAGS " /arch:AVX2")
|
||||
elseif(onnxruntime_USE_AVX512)
|
||||
string(APPEND CMAKE_CXX_FLAGS " /arch:AVX512")
|
||||
string(APPEND CMAKE_C_FLAGS " /arch:AVX512")
|
||||
endif()
|
||||
if (onnxruntime_ENABLE_LTO AND NOT onnxruntime_USE_CUDA)
|
||||
SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Gw /GL")
|
||||
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Gw /GL")
|
||||
|
|
@ -234,10 +254,17 @@ if (MSVC)
|
|||
endif()
|
||||
else()
|
||||
if(onnxruntime_BUILD_FOR_NATIVE_MACHINE)
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -march=native -mtune=native")
|
||||
string(APPEND CMAKE_C_FLAGS_RELEASE " -march=native -mtune=native")
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -march=native -mtune=native")
|
||||
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -march=native -mtune=native")
|
||||
string(APPEND CMAKE_CXX_FLAGS " -march=native -mtune=native")
|
||||
string(APPEND CMAKE_C_FLAGS " -march=native -mtune=native")
|
||||
elseif(onnxruntime_USE_AVX)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -mavx")
|
||||
string(APPEND CMAKE_C_FLAGS " -mavx")
|
||||
elseif(onnxruntime_USE_AVX2)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -mavx2")
|
||||
string(APPEND CMAKE_C_FLAGS " -mavx2")
|
||||
elseif(onnxruntime_USE_AVX512)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl")
|
||||
string(APPEND CMAKE_C_FLAGS " -mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
2
cmake/external/eigen
vendored
2
cmake/external/eigen
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit efd9867ff0e8df23016ac6c9828d0d7bf8bec1b1
|
||||
Subproject commit 54a0a9c9dd83aad42e79238ec8f0932b2a5e7881
|
||||
Loading…
Reference in a new issue