From 430198169fdec50259ac2b4e8b71eeab107be5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Tue, 24 Sep 2024 09:52:43 +0200 Subject: [PATCH] fix cray clang compiler errors (#2392) * fix cray clang compile issue ``` include/alpaka/acc/TagAccIsEnabled.hpp:34:66: error: template template argument has different template parameters than its corresponding template template parameter 34 | using EnabledAccTags = alpaka::meta::Filter; | ^ ``` * fix cray clang OpenMP linker issues CMake is not setting the linker flag `-fopenmp` for the cray clang compiler. * remove clang `-frelaxed-template-template-args` remove clang workaround --- cmake/alpakaCommon.cmake | 20 +++++--------------- include/alpaka/meta/Filter.hpp | 15 +++++++++------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/cmake/alpakaCommon.cmake b/cmake/alpakaCommon.cmake index 8516a0090720..09872beca68e 100644 --- a/cmake/alpakaCommon.cmake +++ b/cmake/alpakaCommon.cmake @@ -194,13 +194,6 @@ else() endif() endif() - # C++17 relaxed template template argument matching is disabled by default until Clang 19 - # https://github.com/llvm/llvm-project/commit/b86e0992bfa6 - # https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150 - # for example, is required to create alpaka::EnabledAccTags - # the feature is implemented since Clang 4 - alpaka_set_compiler_options(HOST_DEVICE target alpaka "$<$>:SHELL:-frelaxed-template-template-args>") - # Add debug optimization levels. CMake doesn't do this by default. # Note that -Og is the recommended gcc optimization level for debug mode but is equivalent to -O1 for clang (and its derivates). alpaka_set_compiler_options(HOST_DEVICE target alpaka "$<$,$,$>:SHELL:-Og>" @@ -357,6 +350,11 @@ if(alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE OR alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE) else() find_package(OpenMP REQUIRED COMPONENTS CXX) target_link_libraries(alpaka INTERFACE OpenMP::OpenMP_CXX) + # shown with CMake 3.29 and cray clang 17 + # workaround: cmake is missing to add '-fopenmp' to the linker flags + if(CMAKE_CXX_COMPILER_ID STREQUAL "CrayClang") + target_link_libraries(alpaka INTERFACE -fopenmp) + endif() endif() endif() @@ -605,13 +603,6 @@ if(alpaka_ACC_GPU_HIP_ENABLE) alpaka_set_compiler_options(HOST_DEVICE target alpaka "$<$:-D__HIP_PLATFORM_HCC__>") endif() - # C++17 relaxed template template argument matching is disabled by default until Clang 19 - # https://github.com/llvm/llvm-project/commit/b86e0992bfa6 - # https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150 - # for example, is required to create alpaka::EnabledAccTags - # TODO(SimeonEhrig): restict HIP version, if first HIP version is release using Clang 19 - alpaka_set_compiler_options(HOST_DEVICE target alpaka "$<$:SHELL:-frelaxed-template-template-args>") - alpaka_compiler_option(HIP_KEEP_FILES "Keep all intermediate files that are generated during internal compilation steps 'CMakeFiles/.dir'" OFF) if(alpaka_HIP_KEEP_FILES) alpaka_set_compiler_options(HOST_DEVICE target alpaka "$<$:SHELL:-save-temps>") @@ -672,7 +663,6 @@ if(alpaka_ACC_SYCL_ENABLE) alpaka_set_compiler_options(HOST_DEVICE target alpaka "-fsycl") target_link_options(alpaka INTERFACE "-fsycl") alpaka_set_compiler_options(HOST_DEVICE target alpaka "-sycl-std=2020") - alpaka_set_compiler_options(HOST_DEVICE target alpaka "-frelaxed-template-template-args") #----------------------------------------------------------------------------------------------------------------- # Determine SYCL targets diff --git a/include/alpaka/meta/Filter.hpp b/include/alpaka/meta/Filter.hpp index 4a260777a4e5..52e93dc1e1b1 100644 --- a/include/alpaka/meta/Filter.hpp +++ b/include/alpaka/meta/Filter.hpp @@ -12,16 +12,16 @@ namespace alpaka::meta { namespace detail { - template class TList, template class TPred, typename... Ts> + template class TList, template class TPred, typename... Ts> struct FilterImplHelper; - template class TList, template class TPred> + template class TList, template class TPred> struct FilterImplHelper { using type = TList<>; }; - template class TList, template class TPred, typename T, typename... Ts> + template class TList, template class TPred, typename T, typename... Ts> struct FilterImplHelper { using type = std::conditional_t< @@ -30,15 +30,18 @@ namespace alpaka::meta typename FilterImplHelper::type>; }; - template class TPred> + template class TPred> struct FilterImpl; - template class TList, template class TPred, typename... Ts> + template class TList, template class TPred, typename... Ts> struct FilterImpl, TPred> { using type = typename detail::FilterImplHelper::type; }; } // namespace detail - template class TPred> + + /// \tparam TPred Only the first parameter is used, all other must be set by TPred to some default. + /// Using '...' instead of a single type is a workaround for CrayClang. + template class TPred> using Filter = typename detail::FilterImpl::type; } // namespace alpaka::meta