Skip to content

Commit

Permalink
ARROW-90: [C++] Check for SIMD instruction set support
Browse files Browse the repository at this point in the history
This also adds an option to disable the usage of a specific instruction
set, e.g. you compile on a machine that supports SSE3 but you want to
use the binary also on machines without SSE3. (Distribution packagers
will love that option!)

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #50 from xhochy/arrow-90 and squashes the following commits:

6fd80d3 [Uwe L. Korn] ARROW-90: Check for SIMD instruction set support
  • Loading branch information
xhochy authored and wesm committed Apr 1, 2016
1 parent 6d31d59 commit 79fddd1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
"Build the Arrow IPC extensions"
ON)

option(ARROW_SSE3
"Build Arrow with SSE3"
ON)

option(ARROW_ALTIVEC
"Build Arrow with Altivec"
ON)

endif()

if(NOT ARROW_BUILD_TESTS)
Expand All @@ -81,9 +89,25 @@ endif()
# Compiler flags
############################################################

# Check if the target architecture and compiler supports some special
# instruction sets that would boost performance.
include(CheckCXXCompilerFlag)
# x86/amd64 compiler flags
CHECK_CXX_COMPILER_FLAG("-msse3" CXX_SUPPORTS_SSE3)
# power compiler flags
CHECK_CXX_COMPILER_FLAG("-maltivec" CXX_SUPPORTS_ALTIVEC)

# compiler flags that are common across debug/release builds
# - Wall: Enable all warnings.
set(CXX_COMMON_FLAGS "-std=c++11 -msse3 -Wall")
set(CXX_COMMON_FLAGS "-std=c++11 -Wall")

# Only enable additional instruction sets if they are supported
if (CXX_SUPPORTS_SSE3 AND ARROW_SSE3)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -msse3")
endif()
if (CXX_SUPPORTS_ALTIVEC AND ARROW_ALTIVEC)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -maltivec")
endif()

if (APPLE)
# Depending on the default OSX_DEPLOYMENT_TARGET (< 10.9), libstdc++ may be
Expand Down

0 comments on commit 79fddd1

Please sign in to comment.