Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Check if the target architecture and compiler supports some special
# instruction sets that would boost performance.
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
# Get cpu architecture

message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down Expand Up @@ -60,17 +61,36 @@ if(ARROW_CPU_FLAG STREQUAL "x86")
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
message(STATUS "Disable AVX512 support on MINGW for now")
else()
check_cxx_compiler_flag(${ARROW_AVX512_FLAG} CXX_SUPPORTS_AVX512)
# Check for AVX512 support in the compiler.
set(OLD_CMAKE_REQURED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${ARROW_AVX512_FLAG}")
check_cxx_source_compiles("
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <immintrin.h>
#endif

int main() {
__m512i mask = _mm512_set1_epi32(0x1);
char out[32];
_mm512_storeu_si512(out, mask);
return 0;
}" CXX_SUPPORTS_AVX512)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS})
endif()
# Runtime SIMD level it can get from compiler
# Runtime SIMD level it can get from compiler and ARROW_RUNTIME_SIMD_LEVEL
if(CXX_SUPPORTS_SSE4_2
AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(SSE4_2|AVX2|AVX512|MAX)$")
set(ARROW_HAVE_RUNTIME_SSE4_2 ON)
add_definitions(-DARROW_HAVE_RUNTIME_SSE4_2)
endif()
if(CXX_SUPPORTS_AVX2 AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(AVX2|AVX512|MAX)$")
set(ARROW_HAVE_RUNTIME_AVX2 ON)
add_definitions(-DARROW_HAVE_RUNTIME_AVX2 -DARROW_HAVE_RUNTIME_BMI2)
endif()
if(CXX_SUPPORTS_AVX512 AND ARROW_RUNTIME_SIMD_LEVEL MATCHES "^(AVX512|MAX)$")
set(ARROW_HAVE_RUNTIME_AVX512 ON)
add_definitions(-DARROW_HAVE_RUNTIME_AVX512 -DARROW_HAVE_RUNTIME_BMI2)
endif()
elseif(ARROW_CPU_FLAG STREQUAL "ppc")
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ set(ARROW_SRCS
vendored/double-conversion/diy-fp.cc
vendored/double-conversion/strtod.cc)

if(CXX_SUPPORTS_AVX2)
if(ARROW_HAVE_RUNTIME_AVX2)
list(APPEND ARROW_SRCS util/bpacking_avx2.cc)
set_source_files_properties(util/bpacking_avx2.cc PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
set_source_files_properties(util/bpacking_avx2.cc PROPERTIES COMPILE_FLAGS
${ARROW_AVX2_FLAG})
endif()
if(CXX_SUPPORTS_AVX512)
if(ARROW_HAVE_RUNTIME_AVX512)
list(APPEND ARROW_SRCS util/bpacking_avx512.cc)
set_source_files_properties(util/bpacking_avx512.cc PROPERTIES SKIP_PRECOMPILE_HEADERS
ON)
Expand Down Expand Up @@ -387,14 +387,14 @@ if(ARROW_COMPUTE)
compute/kernels/vector_selection.cc
compute/kernels/vector_sort.cc)

if(CXX_SUPPORTS_AVX2)
if(ARROW_HAVE_RUNTIME_AVX2)
list(APPEND ARROW_SRCS compute/kernels/aggregate_basic_avx2.cc)
set_source_files_properties(compute/kernels/aggregate_basic_avx2.cc PROPERTIES
SKIP_PRECOMPILE_HEADERS ON)
set_source_files_properties(compute/kernels/aggregate_basic_avx2.cc PROPERTIES
COMPILE_FLAGS ${ARROW_AVX2_FLAG})
endif()
if(CXX_SUPPORTS_AVX512)
if(ARROW_HAVE_RUNTIME_AVX512)
list(APPEND ARROW_SRCS compute/kernels/aggregate_basic_avx512.cc)
set_source_files_properties(compute/kernels/aggregate_basic_avx512.cc PROPERTIES
SKIP_PRECOMPILE_HEADERS ON)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ set(PARQUET_SRCS
stream_writer.cc
types.cc)

if(CXX_SUPPORTS_AVX2)
if(ARROW_HAVE_RUNTIME_AVX2)
# AVX2 is used as a proxy for BMI2.
list(APPEND PARQUET_SRCS level_comparison_avx2.cc level_conversion_bmi2.cc)
set_source_files_properties(level_comparison_avx2.cc
Expand Down