Skip to content
Snippets Groups Projects
Unverified Commit 22c77118 authored by boeschf's avatar boeschf Committed by GitHub
Browse files

fix auto detect of sve length (#2257)

- apply pertinent compiler flags when trying to compile the detection
code
- improve compiler error message when sve length is not set
parent f7205975
No related branches found
Tags 8.0.6
No related merge requests found
...@@ -322,6 +322,18 @@ set(arbor_supported_components) ...@@ -322,6 +322,18 @@ set(arbor_supported_components)
# Target microarchitecture for building arbor libraries, tests and examples # Target microarchitecture for building arbor libraries, tests and examples
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Set the full set of target flags in ARB_CXX_FLAGS_TARGET_FULL, which
# will include target-specific -march flags if ARB_ARCH is not "none".
if(ARB_ARCH STREQUAL "none")
set(ARB_CXX_FLAGS_TARGET_FULL ${ARB_CXX_FLAGS_TARGET})
set(ARB_CXX_FLAGS_TARGET_FULL_CPU ${ARB_CXX_FLAGS_TARGET})
else()
set_arch_target(ARB_CXXOPT_ARCH_CPU ARB_CXXOPT_ARCH ${ARB_ARCH})
set(ARB_CXX_FLAGS_TARGET_FULL ${ARB_CXX_FLAGS_TARGET} ${ARB_CXXOPT_ARCH})
set(ARB_CXX_FLAGS_TARGET_FULL_CPU ${ARB_CXX_FLAGS_TARGET} ${ARB_CXXOPT_ARCH_CPU})
endif()
# Add SVE compiler flags if detected/desired
set(ARB_SVE_WIDTH "auto" CACHE STRING "Default SVE vector length in bits. Default: auto (detection during configure time).") set(ARB_SVE_WIDTH "auto" CACHE STRING "Default SVE vector length in bits. Default: auto (detection during configure time).")
mark_as_advanced(ARB_SVE_WIDTH) mark_as_advanced(ARB_SVE_WIDTH)
if (ARB_SVE_WIDTH STREQUAL "auto") if (ARB_SVE_WIDTH STREQUAL "auto")
...@@ -337,15 +349,8 @@ else() ...@@ -337,15 +349,8 @@ else()
set(ARB_SVE_BITS ${ARB_SVE_WIDTH}) set(ARB_SVE_BITS ${ARB_SVE_WIDTH})
set(ARB_CXX_SVE_FLAGS " -msve-vector-bits=${ARB_SVE_BITS}") set(ARB_CXX_SVE_FLAGS " -msve-vector-bits=${ARB_SVE_BITS}")
endif() endif()
list(APPEND ARB_CXX_FLAGS_TARGET_FULL
# Set the full set of target flags in ARB_CXX_FLAGS_TARGET_FULL, which "$<$<BUILD_INTERFACE:$<COMPILE_LANGUAGE:CXX>>:${ARB_CXX_SVE_FLAGS}>")
# will include target-specific -march flags if ARB_ARCH is not "none".
if(ARB_ARCH STREQUAL "none")
set(ARB_CXX_FLAGS_TARGET_FULL ${ARB_CXX_FLAGS_TARGET} ${ARB_CXX_SVE_FLAGS})
else()
set_arch_target(ARB_CXXOPT_ARCH ${ARB_ARCH})
set(ARB_CXX_FLAGS_TARGET_FULL ${ARB_CXX_FLAGS_TARGET} ${ARB_CXXOPT_ARCH} ${ARB_CXX_SVE_FLAGS})
endif()
# Compile with `-fvisibility=hidden` to ensure that the symbols of the generated # Compile with `-fvisibility=hidden` to ensure that the symbols of the generated
# arbor static libraries are hidden from the dynamic symbol tables of any shared # arbor static libraries are hidden from the dynamic symbol tables of any shared
......
...@@ -95,7 +95,7 @@ set(CXXOPT_WALL ...@@ -95,7 +95,7 @@ set(CXXOPT_WALL
# Architectures are given by the same names that GCC uses for its # Architectures are given by the same names that GCC uses for its
# -mcpu or -march options. # -mcpu or -march options.
function(set_arch_target optvar arch) function(set_arch_target optvar optvar_cuda_guarded arch)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# Correct compiler option unfortunately depends upon the target architecture family. # Correct compiler option unfortunately depends upon the target architecture family.
# Extract this information from running the configured compiler with --verbose. # Extract this information from running the configured compiler with --verbose.
...@@ -111,7 +111,7 @@ function(set_arch_target optvar arch) ...@@ -111,7 +111,7 @@ function(set_arch_target optvar arch)
string(REGEX REPLACE "-.*" "" target_model "${target}") string(REGEX REPLACE "-.*" "" target_model "${target}")
# Use -mcpu for all supported targets _except_ for x86 and Apple arm64, where it should be -march. # Use -mcpu for all supported targets _except_ for x86 and Apple arm64, where it should be -march.
if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" AND CMAKE_CXX_COMPILER_VERSION LESS 15) if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" AND CMAKE_CXX_COMPILER_VERSION LESS 15)
set(arch_opt "") set(arch_opt "")
else() else()
...@@ -125,6 +125,7 @@ function(set_arch_target optvar arch) ...@@ -125,6 +125,7 @@ function(set_arch_target optvar arch)
endif() endif()
endif() endif()
set("${optvar}" "${arch_opt}" PARENT_SCOPE)
get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES) get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if ("CUDA" IN_LIST enabled_languages) if ("CUDA" IN_LIST enabled_languages)
# Prefix architecture options with `-Xcompiler=` when compiling CUDA sources, i.e. # Prefix architecture options with `-Xcompiler=` when compiling CUDA sources, i.e.
...@@ -134,16 +135,19 @@ function(set_arch_target optvar arch) ...@@ -134,16 +135,19 @@ function(set_arch_target optvar arch)
list(APPEND arch_opt_cuda_guarded "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=>${opt}") list(APPEND arch_opt_cuda_guarded "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=>${opt}")
endforeach() endforeach()
set("${optvar}" "${arch_opt_cuda_guarded}" PARENT_SCOPE) set("${optvar_cuda_guarded}" "${arch_opt_cuda_guarded}" PARENT_SCOPE)
else() else()
set("${optvar}" "${arch_opt}" PARENT_SCOPE) set("${optvar_cuda_guarded}" "${arch_opt}" PARENT_SCOPE)
endif() endif()
endfunction() endfunction()
# Set ${has_sve} and ${sve_length} in parent scope according to auto detection. # Set ${has_sve} and ${sve_length} in parent scope according to auto detection.
function(get_sve_length has_sve sve_length) function(get_sve_length has_sve sve_length)
try_run(run_var cc_var ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/sve_length.cpp RUN_OUTPUT_VARIABLE out_var) try_run(run_var cc_var
${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/sve_length.cpp
COMPILE_DEFINITIONS ${ARB_CXX_FLAGS_TARGET_FULL_CPU}
RUN_OUTPUT_VARIABLE out_var)
if(NOT cc_var) if(NOT cc_var)
message(FATAL_ERROR "compilation of ${PROJECT_SOURCE_DIR}/cmake/sve_length.cpp failed") message(FATAL_ERROR "compilation of ${PROJECT_SOURCE_DIR}/cmake/sve_length.cpp failed")
......
...@@ -15,7 +15,7 @@ static constexpr unsigned vls_sve_width = @ARB_SVE_BITS@/64; ...@@ -15,7 +15,7 @@ static constexpr unsigned vls_sve_width = @ARB_SVE_BITS@/64;
// Check required compiler features for VLS_SVE // Check required compiler features for VLS_SVE
#if (!defined(__ARM_FEATURE_SVE_BITS) || __ARM_FEATURE_SVE_BITS != @ARB_SVE_BITS@) #if (!defined(__ARM_FEATURE_SVE_BITS) || __ARM_FEATURE_SVE_BITS != @ARB_SVE_BITS@)
#error "Vector length specific scalable vector extension (VLS_SVE) not enabled - did you compile with -msve-vector-bits=@ARB_SVE_BITS@?" #error "Vector length specific scalable vector extension (VLS_SVE) not enabled - consider setting ARB_SVE_LENGTH=@ARB_SVE_BITS@"
#endif #endif
// We currently do not rely on GNU vector extension, __attribute__((vector_size(vls_sve_width)). If defined, we could // We currently do not rely on GNU vector extension, __attribute__((vector_size(vls_sve_width)). If defined, we could
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment