Skip to content

Commit

Permalink
ARROW-8080: [C++] Add ARROW_SIMD_LEVEL option
Browse files Browse the repository at this point in the history
Default set to off.

Signed-off-by: Frank Du <frank.du@intel.com>

Closes #6585 from jianxind/avx512-build-option

Authored-by: Frank Du <frank.du@intel.com>
Signed-off-by: Wes McKinney <wesm+git@apache.org>
  • Loading branch information
frankdjx authored and wesm committed Mar 18, 2020
1 parent f2f9d8f commit c15637d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cpp/cmake_modules/DefineOptions.cmake
Expand Up @@ -98,7 +98,13 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
# Disable this option to exercise non-SIMD fallbacks
define_option(ARROW_USE_SIMD "Build with SIMD optimizations" ON)

define_option(ARROW_SSE42 "Build with SSE4.2 if compiler has support" ON)
define_option_string(ARROW_SIMD_LEVEL
"SIMD compiler optimization level"
"SSE4_2" # default to SSE4.2
"NONE"
"SSE4_2"
"AVX2"
"AVX512")

define_option(ARROW_ALTIVEC "Build with Altivec if compiler has support" ON)

Expand Down
9 changes: 8 additions & 1 deletion cpp/cmake_modules/SetupCxxFlags.cmake
Expand Up @@ -20,6 +20,8 @@
include(CheckCXXCompilerFlag)
# x86/amd64 compiler flags
check_cxx_compiler_flag("-msse4.2" CXX_SUPPORTS_SSE4_2)
check_cxx_compiler_flag("-mavx2" CXX_SUPPORTS_AVX2)
check_cxx_compiler_flag("-mavx512f" CXX_SUPPORTS_AVX512)
# power compiler flags
check_cxx_compiler_flag("-maltivec" CXX_SUPPORTS_ALTIVEC)
# Arm64 compiler flags
Expand Down Expand Up @@ -266,7 +268,12 @@ if(BUILD_WARNING_FLAGS)
endif(BUILD_WARNING_FLAGS)

# Only enable additional instruction sets if they are supported
if(CXX_SUPPORTS_SSE4_2 AND ARROW_SSE42)
if(CXX_SUPPORTS_AVX512 AND ARROW_SIMD_LEVEL STREQUAL "AVX512")
# skylake-avx512 consist of AVX512F,AVX512BW,AVX512VL,AVX512CD,AVX512DQ
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -march=skylake-avx512")
elseif(CXX_SUPPORTS_AVX2 AND ARROW_SIMD_LEVEL STREQUAL "AVX2")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -mavx2")
elseif(CXX_SUPPORTS_SSE4_2 AND ARROW_SIMD_LEVEL STREQUAL "SSE4_2")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -msse4.2")
endif()

Expand Down

0 comments on commit c15637d

Please sign in to comment.