Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-90: [C++] Check for SIMD instruction set support #50

Closed
wants to merge 1 commit into from
Closed
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
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're probably also going to want some defines so that we can include or exclude code that depends on these features, but doesn't need to be in this patch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What implications does ARROW_SSE3=on by default have if we also add ARROW_SSE42 for SSE 4.2? I figure that -msse4.2 -msse3 is equivalent to just -msse3 but let me know if that is not the case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-msse4.2 -msse3 can be used together and they will enable SSE3 and SSE4.2 support. The semantics of those switches are "also use this instruction set". It may even be that -msse4.2 implies -msse3 so that -msse4.2 -msse3 is actually equivalent to -msse4.2. In general those -m* options add up together to enable more instructions sets, not less.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, good to know


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