diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 77e4456f1a17ed..54677ebace6ccd 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4527,7 +4527,7 @@ bool CompilerInvocation::ParseKitsuneArgs(KitsuneOptions &Opts, ArgList &Args, bool isKokkos = Args.hasArg(options::OPT_fkokkos); bool isKokkosNoInit = Args.hasArg(options::OPT_fkokkos_no_init); - if ((isKokkos || isKokkosNoInit) && !KITSUNE_KOKKOS_ENABLE) { + if ((isKokkos || isKokkosNoInit) && !KITSUNE_KOKKOS_ENABLED) { Diags.Report(diag::err_drv_kitsune_kokkos_disabled); } else { Opts.setKokkos(isKokkos); diff --git a/kitsune/CMakeLists.txt b/kitsune/CMakeLists.txt index 4cb6aaefd5b935..7b10a799619bad 100644 --- a/kitsune/CMakeLists.txt +++ b/kitsune/CMakeLists.txt @@ -24,16 +24,15 @@ option(KITSUNE_INCLUDE_TESTS "Generate build targets for the Kitsune tests" ${LLVM_INCLUDE_TESTS}) +# FIXME: Ideally, this should be KITSUNE_KOKKOS_ENABLED (with a D at the end) to +# be consistent with all the other uses, but leaving it as it is for now because +# there may be folks who are still building it with this. Once we know that no +# one is still using this, it will be removed in favor of ENABLED. option(KITSUNE_KOKKOS_ENABLE "Enable custom recognition and compilation of Kokkos" ON) -set(KITSUNE_CUDA_ENABLE OFF CACHE INTERNAL "Enable the cuda tapir target" FORCE) -set(KITSUNE_HIP_ENABLE OFF CACHE INTERNAL "Enable the hip tapir target" FORCE) -set(KITSUNE_OPENCILK_ENABLE OFF CACHE INTERNAL "Enable the opencilk tapir target" FORCE) -set(KITSUNE_OPENMP_ENABLE OFF CACHE INTERNAL "Enable the openmp tapir target" FORCE) -set(KITSUNE_QTHREADS_ENABLE OFF CACHE INTERNAL "Enable the qthreads tapir target" FORCE) -set(KITSUNE_REALM_ENABLE OFF CACHE INTERNAL "Enable the realm tapir target" FORCE) +set(KITSUNE_KOKKOS_ENABLED ${KITSUNE_KOKKOS_ENABLE} "Enable Kokkos recognition" FORCE) # TODO: The _MAX variables are not currently used but it would be good to # require a range instead of just a minimum. In practice, we may want to @@ -49,38 +48,6 @@ set(KITSUNE_INCLUDE_DIR ${KITSUNE_SOURCE_DIR}/include) set(KITSUNE_BINARY_DIR ${PROJECT_BINARY_DIR}) set(KITSUNE_TARGETS_BINARY_DIR ${KITSUNE_BINARY_DIR}/targets) -# TODO: Need to update the openmp, qthreads and realm targets and add them -# back into this list. These targets have not been tested in a while and have -# probably bit-rotted. Enabling them will raise a configure-time error. -set(KITSUNE_ALL_TAPIR_TARGETS - "cuda;hip;opencilk" - CACHE STRING - "All known Tapir targets.") - -set(KITSUNE_DEFAULT_TAPIR_TARGETS - "cuda;hip;opencilk" - CACHE STRING - "The Tapir targets that are built by default if targets are not explicitly specified.") - -set(KITSUNE_ENABLE_TAPIR_TARGETS - "${KITSUNE_DEFAULT_TAPIR_TARGETS}" - CACHE STRING - "Semicolon-separated list of runtime targets to build (or \"all\".)") - -if (NOT KITSUNE_ENABLE_TAPIR_TARGETS) - message(FATAL_ERROR "At least one runtime target must be built") -endif () - -foreach(target IN LISTS KITSUNE_ENABLE_TAPIR_TARGETS) - if (target IN_LIST KITSUNE_ALL_TAPIR_TARGETS) - message(STATUS "${target} tapir target enabled") - string(TOUPPER "${target}" upper_target) - set(KITSUNE_${upper_target}_ENABLE ON CACHE INTERNAL "Enable the ${target} tapir target" FORCE) - else () - message(FATAL_ERROR "Unknown Tapir target: ${target}") - endif() -endforeach() - # This is just the subpath to the internal directory. It will be interpreted # relative to some base path, typically the ${CMAKE_INSTALL_PREFIX} get_clang_resource_dir(CLANG_RESOURCE_SUBDIR) @@ -91,7 +58,7 @@ get_clang_resource_dir(CLANG_RESOURCE_INTDIR get_clang_resource_dir(CLANG_RESOURCE_INSTALL_DIR PREFIX ${CMAKE_INSTALL_PREFIX}) -if (KITSUNE_KOKKOS_ENABLE) +if (KITSUNE_KOKKOS_ENABLED) # We currently don't support using a pre-built Kokkos - even if it has been # patched the way we need it to be. This could possibly be moved to # kitsune/runtime, just so everything that needs to be fetched and built is @@ -191,7 +158,7 @@ if (KITSUNE_KOKKOS_ENABLE) "Additional linker flags needed for Kokkos support") endif() -if (KITSUNE_CUDA_ENABLE) +if (KITSUNE_CUDA_ENABLED) message(STATUS "Kitsune: CUDA target enabled") find_package(CUDAToolkit ${KITSUNE_CUDA_VERSION_MIN} REQUIRED) @@ -247,7 +214,7 @@ if (KITSUNE_CUDA_ENABLE) "Additional linker flags needed for the Cuda target") endif() -if (KITSUNE_HIP_ENABLE) +if (KITSUNE_HIP_ENABLED) message(STATUS "Kitsune: HIP target enabled.") # Apparently, ROCM_PATH needs to be set for Hip's build system to work @@ -316,7 +283,7 @@ if (KITSUNE_HIP_ENABLE) message(STATUS "hip bitcode file location: ${KITSUNE_HIP_BITCODE_DIR}") endif() -if (KITSUNE_OPENCILK_ENABLE) +if (KITSUNE_OPENCILK_ENABLED) message(STATUS "Kitsune: OpenCilk target enabled") # We currently don't allow using a pre-built Cheetah. It would have to be @@ -425,7 +392,7 @@ if (KITSUNE_OPENCILK_ENABLE) endif() -if (KITSUNE_OPENMP_ENABLE) +if (KITSUNE_OPENMP_ENABLED) message(STATUS "Kitsune: OpenMP target enabled") # TODO: Do we need to check for libomp? @@ -455,7 +422,7 @@ if (KITSUNE_OPENMP_ENABLE) "Additional linker flags needed for the OpenMP target") endif() -if (KITSUNE_QTHREADS_ENABLE) +if (KITSUNE_QTHREADS_ENABLED) message(STATUS "Kitsune: Qthreads target enabled") # FIXME: Do find_package or something here for qthreads. That will set @@ -492,7 +459,7 @@ if (KITSUNE_QTHREADS_ENABLE) "Additional linker flags needed for the Qthreads target") endif() -if (KITSUNE_REALM_ENABLE) +if (KITSUNE_REALM_ENABLED) message(STATUS "Kitsune: Realm target enabled") # FIXME: Do find_package or something here for realm. That will set @@ -600,22 +567,22 @@ ExternalProject_Add(kitrt -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DKITSUNE_CUDA_VERSION_MIN=${KITSUNE_CUDA_VERSION_MIN} -DKITSUNE_ROCM_VERSION_MIN=${KITSUNE_ROCM_VERSION_MIN} - -DKITSUNE_CUDA_ENABLE=${KITSUNE_CUDA_ENABLE} + -DKITSUNE_CUDA_ENABLED=${KITSUNE_CUDA_ENABLED} -DKITSUNE_CUDA_INCLUDE_DIR=${KITSUNE_CUDA_INCLUDE_DIR} -DKITSUNE_CUDA_BINARY_DIR=${KITSUNE_CUDA_BINARY_DIR} -DKITSUNE_CUDA_LIBRARY_DIR=${KITSUNE_CUDA_LIBRARY_DIR} -DKITSUNE_CUDA_LIB_CUDA=${KITSUNE_CUDA_LIB_CUDA} -DKITSUNE_CUDA_LIB_CUDART=${KITSUNE_CUDA_LIB_CUDART} -DKITSUNE_CUDA_LIB_NVPTX_STATIC=${KITSUNE_CUDA_LIB_NVPTX_STATIC} - -DKITSUNE_HIP_ENABLE=${KITSUNE_HIP_ENABLE} + -DKITSUNE_HIP_ENABLED=${KITSUNE_HIP_ENABLED} -DKITSUNE_HIP_PREFIX=${KITSUNE_HIP_PREFIX} -DKITSUNE_HIP_INCLUDE_DIR=${KITSUNE_HIP_INCLUDE_DIR} -DKITSUNE_HIP_LIBRARY_DIR=${KITSUNE_HIP_LIBRARY_DIR} -DKITSUNE_HIP_LIB_AMDHIP64=${KITSUNE_HIP_LIB_AMDHIP64} - -DKITSUNE_OPENCILK_ENABLE=${KITSUNE_OPENCILK_ENABLE} - -DKITSUNE_OPENMP_ENABLE=${KITSUNE_OPENMP_ENABLE} - -DKITSUNE_QTHREADS_ENABLE=${KITSUNE_QTHREADS_ENABLE} - -DKITSUNE_REALM_ENABLE=${KITSUNE_REALM_ENABLE} + -DKITSUNE_OPENCILK_ENABLED=${KITSUNE_OPENCILK_ENABLED} + -DKITSUNE_OPENMP_ENABLED=${KITSUNE_OPENMP_ENABLED} + -DKITSUNE_QTHREADS_ENABLED=${KITSUNE_QTHREADS_ENABLED} + -DKITSUNE_REALM_ENABLED=${KITSUNE_REALM_ENABLED} -DKITRT_ENABLE_DEBUG=${KITRT_ENABLE_DEBUG} -DKITRT_ENABLE_VERBOSE=${KITRT_ENABLE_VERBOSE} -DKITRT_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} diff --git a/kitsune/cmake/caches/kitsune-dev-darwin-aarch64.cmake b/kitsune/cmake/caches/kitsune-dev-darwin-aarch64.cmake index 8a1bbd04bc5e2f..255de943a34a70 100644 --- a/kitsune/cmake/caches/kitsune-dev-darwin-aarch64.cmake +++ b/kitsune/cmake/caches/kitsune-dev-darwin-aarch64.cmake @@ -86,7 +86,7 @@ set(LLVM_TARGETS_TO_BUILD "AArch64;X86;NVPTX;AMDGPU" CACHE STRING "") set(KITSUNE_ENABLE_TAPIR_TARGETS "cuda;hip;opencilk") # Enable tailored Kokkos compilation. -set(KITSUNE_KOKKOS_ENABLE ON CACHE BOOL +set(KITSUNE_KOKKOS_ENABLED ON CACHE BOOL "Enable custom recognition and compilation of Kokkos") # Enable the Kitsune runtime. diff --git a/kitsune/cmake/caches/kitsune-dev-darwin.cmake b/kitsune/cmake/caches/kitsune-dev-darwin.cmake index 0f013f55be9840..bb4ac5d6ea07fd 100644 --- a/kitsune/cmake/caches/kitsune-dev-darwin.cmake +++ b/kitsune/cmake/caches/kitsune-dev-darwin.cmake @@ -83,7 +83,7 @@ set(LLVM_TARGETS_TO_BUILD "X86;NVPTX;AMDGPU" CACHE STRING "") set(KITSUNE_ENABLE_TAPIR_TARGETS "cuda;hip;opencilk") # Enable tailored Kokkos compilation. -set(KITSUNE_KOKKOS_ENABLE ON CACHE BOOL +set(KITSUNE_KOKKOS_ENABLED ON CACHE BOOL "Enable custom recognition and compilation of Kokkos") # Enable the Kitsune runtime. diff --git a/kitsune/cmake/caches/kitsune-dev-desktop.cmake b/kitsune/cmake/caches/kitsune-dev-desktop.cmake index a8b01683ea34e1..5ce26c9597d0f4 100644 --- a/kitsune/cmake/caches/kitsune-dev-desktop.cmake +++ b/kitsune/cmake/caches/kitsune-dev-desktop.cmake @@ -75,7 +75,7 @@ set(CLANG_VENDOR_UTI "gov.lanl.kitsune" CACHE STRING "") set(KITSUNE_ENABLE_TAPIR_TARGETS "cuda;hip;opencilk") # Enable tailored Kokkos compilation. -set(KITSUNE_KOKKOS_ENABLE ON CACHE BOOL +set(KITSUNE_KOKKOS_ENABLED ON CACHE BOOL "Enable custom recognition and compilation of Kokkos") set(KITSUNE_BUILD_EXAMPLES OFF CACHE BOOL "") diff --git a/kitsune/configs/CMakeLists.txt b/kitsune/configs/CMakeLists.txt index 479ab11891a5b2..58f0364904d4a5 100644 --- a/kitsune/configs/CMakeLists.txt +++ b/kitsune/configs/CMakeLists.txt @@ -7,7 +7,7 @@ # cmake_minimum_required(VERSION 3.20) -if (KITSUNE_KOKKOS_ENABLE) +if (KITSUNE_KOKKOS_ENABLED) configure_file(kokkos.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/kokkos.cfg) endif () @@ -18,32 +18,32 @@ configure_file(none.cfg.in configure_file(serial.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/serial.cfg) -if (KITSUNE_CUDA_ENABLE) +if (KITSUNE_CUDA_ENABLED) configure_file(cuda.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/cuda.cfg) endif() -if (KITSUNE_HIP_ENABLE) +if (KITSUNE_HIP_ENABLED) configure_file(hip.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/hip.cfg) endif() -if (KITSUNE_OPENCILK_ENABLE) +if (KITSUNE_OPENCILK_ENABLED) configure_file(opencilk.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/opencilk.cfg) endif() -if (KITSUNE_OPENMP_ENABLE) +if (KITSUNE_OPENMP_ENABLED) configure_file(openmp.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/openmp.cfg) endif() -if (KITSUNE_QTHREADS_ENABLE) +if (KITSUNE_QTHREADS_ENABLED) configure_file(qthreads.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/qthreads.cfg) endif() -if (KITSUNE_REALM_ENABLE) +if (KITSUNE_REALM_ENABLED) configure_file(realm.cfg.in ${LLVM_BINARY_DIR}/share/kitsune/realm.cfg) endif() diff --git a/kitsune/experiments/inc/config.mk.cmake b/kitsune/experiments/inc/config.mk.cmake index e8dfa38653e561..e187d5192ad366 100644 --- a/kitsune/experiments/inc/config.mk.cmake +++ b/kitsune/experiments/inc/config.mk.cmake @@ -1,25 +1,25 @@ -# Kitsune support +# Kitsune support kitsune_install_prefix:=${CMAKE_INSTALL_PREFIX} -# Cuda support -kitsune_cuda_enable:="${KITSUNE_CUDA_ENABLE}" +# Cuda support +kitsune_cuda_enable:="${KITSUNE_CUDA_ENABLED}" ifeq ($(kitsune_cuda_enable),"ON") $(info config: cuda target enabled.) - KITSUNE_CUDA_ENABLE:=true + KITSUNE_CUDA_ENABLED:=true endif -# Hip support -kitsune_hip_enable:="${KITSUNE_HIP_ENABLE}" +# Hip support +kitsune_hip_enable:="${KITSUNE_HIP_ENABLED}" ifeq ($(kitsune_hip_enable),"ON") $(info config: hip target enabled.) - KITSUNE_HIP_ENABLE:=true + KITSUNE_HIP_ENABLED:=true ROCM_PATH:=${ROCM_PATH} -endif +endif -# Kokkos support -kitsune_kokkos_enable:="${KITSUNE_KOKKOS_ENABLE}" +# Kokkos support +kitsune_kokkos_enable:="${KITSUNE_KOKKOS_ENABLED}" ifeq ($(kitsune_kokkos_enable),"ON") $(info config: kokkos codegen enabled.) - KITSUNE_KOKKOS_ENABLE:=true + KITSUNE_KOKKOS_ENABLED:=true endif diff --git a/kitsune/experiments/inc/cuda.mk b/kitsune/experiments/inc/cuda.mk index aa77ce1e58d27d..0a7bec742a7cc4 100644 --- a/kitsune/experiments/inc/cuda.mk +++ b/kitsune/experiments/inc/cuda.mk @@ -1,4 +1,4 @@ -ifneq ($(KITSUNE_CUDA_ENABLE),) +ifneq ($(KITSUNE_CUDA_ENABLED),) CUDA_ARCH?=sm_86 $(info cuda: target arch: $(CUDA_ARCH)) NVCC=$(CUDA_PATH)/bin/nvcc @@ -10,10 +10,10 @@ ifneq ($(KITSUNE_CUDA_ENABLE),) --expt-relaxed-constexpr \ -O$(KITSUNE_OPTLEVEL) - CLANG_CUDA=$(KITSUNE_PREFIX)/bin/clang + CLANG_CUDA=$(KITSUNE_PREFIX)/bin/clang CLANG_CUDA_FLAGS=-x cuda --no-cuda-version-check --cuda-gpu-arch=$(CUDA_ARCH) -O$(KITSUNE_OPTLEVEL) --cuda-path=$(CUDA_PATH) BUILD_CUDA_EXPERIMENTS=true $(info note: cuda experiments enabled) -endif +endif diff --git a/kitsune/experiments/inc/hip.mk b/kitsune/experiments/inc/hip.mk index eb57fb7b3a4f64..0d2b0eefe7c2b9 100644 --- a/kitsune/experiments/inc/hip.mk +++ b/kitsune/experiments/inc/hip.mk @@ -1,4 +1,4 @@ -ifneq ($(KITSUNE_HIP_ENABLE),) +ifneq ($(KITSUNE_HIP_ENABLED),) AMDGPU_ARCH?=gfx90a $(info hip: amdgpu arch: $(AMDGPU_ARCH)) @@ -7,9 +7,9 @@ ifneq ($(KITSUNE_HIP_ENABLE),) -fno-exceptions \ -O$(KITSUNE_OPTLEVEL) - KITSUNE_HIPCC=$(kitsune_prefix)/bin/clang++ -x hip + KITSUNE_HIPCC=$(kitsune_prefix)/bin/clang++ -x hip HIP_LIBS=-L$(rocm_path)/lib -lamdhip64 BUILD_HIP_EXPERIMENTS=true $(info note: hip experiments enabled) -endif +endif diff --git a/kitsune/include/kitsune/Config/config.h.cmake b/kitsune/include/kitsune/Config/config.h.cmake index e38aff9b95ea2c..5ca252f6cc8108 100644 --- a/kitsune/include/kitsune/Config/config.h.cmake +++ b/kitsune/include/kitsune/Config/config.h.cmake @@ -17,18 +17,14 @@ #define KITSUNE_LLD "${KITSUNE_LLD}" // Kokkos configuration -#cmakedefine01 KITSUNE_KOKKOS_ENABLE - -#define KITSUNE_KOKKOS_ENABLED KITSUNE_KOKKOS_ENABLE +#cmakedefine01 KITSUNE_KOKKOS_ENABLED #define KITSUNE_KOKKOS_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_KOKKOS_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_KOKKOS_EXTRA_COMPILER_FLAGS "${KITSUNE_KOKKOS_EXTRA_COMPILER_FLAGS}" #define KITSUNE_KOKKOS_EXTRA_LINKER_FLAGS "${KITSUNE_KOKKOS_EXTRA_LINKER_FLAGS}" // Cuda configuration -#cmakedefine01 KITSUNE_CUDA_ENABLE - -#define KITSUNE_CUDA_ENABLED KITSUNE_CUDA_ENABLE +#cmakedefine01 KITSUNE_CUDA_ENABLED #define KITSUNE_CUDA_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_CUDA_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_CUDA_EXTRA_COMPILER_FLAGS "${KITSUNE_CUDA_EXTRA_COMPILER_FLAGS}" @@ -43,9 +39,7 @@ #define KITSUNE_CUDA_FATBINARY "${KITSUNE_CUDA_FATBINARY}" // Hip configuration -#cmakedefine01 KITSUNE_HIP_ENABLE - -#define KITSUNE_HIP_ENABLED KITSUNE_HIP_ENABLE +#cmakedefine01 KITSUNE_HIP_ENABLED #define KITSUNE_HIP_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_HIP_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_HIP_EXTRA_COMPILER_FLAGS "${KITSUNE_HIP_EXTRA_COMPILER_FLAGS}" @@ -56,36 +50,28 @@ #define KITSUNE_HIP_BITCODE_DIR "${KITSUNE_HIP_BITCODE_DIR}" // OpenCilk configuration -#cmakedefine01 KITSUNE_OPENCILK_ENABLE - -#define KITSUNE_OPENCILK_ENABLED KITSUNE_OPENCILK_ENABLE +#cmakedefine01 KITSUNE_OPENCILK_ENABLED #define KITSUNE_OPENCILK_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_OPENCILK_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_OPENCILK_EXTRA_COMPILER_FLAGS "${KITSUNE_OPENCILK_EXTRA_COMPILER_FLAGS}" #define KITSUNE_OPENCILK_EXTRA_LINKER_FLAGS "${KITSUNE_OPENCILK_EXTRA_LINKER_FLAGS}" // OpenMP configuration -#cmakedefine01 KITSUNE_OPENMP_ENABLE - -#define KITSUNE_OPENMP_ENABLED KITSUNE_OPENMP_ENABLE +#cmakedefine01 KITSUNE_OPENMP_ENABLED #define KITSUNE_OPENMP_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_OPENMP_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_OPENMP_EXTRA_COMPILER_FLAGS "${KITSUNE_OPENMP_EXTRA_COMPILER_FLAGS}" #define KITSUNE_OPENMP_EXTRA_LINKER_FLAGS "${KITSUNE_OPENMP_EXTRA_LINKER_FLAGS}" // Qthreads configuration -#cmakedefine01 KITSUNE_QTHREADS_ENABLE - -#define KITSUNE_QTHREADS_ENABLED KITSUNE_QTHREADS_ENABLE +#cmakedefine01 KITSUNE_QTHREADS_ENABLED #define KITSUNE_QTHREADS_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_QTHREADS_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_QTHREADS_EXTRA_COMPILER_FLAGS "${KITSUNE_QTHREADS_EXTRA_COMPILER_FLAGS}" #define KITSUNE_QTHREADS_EXTRA_LINKER_FLAGS "${KITSUNE_QTHREADS_EXTRA_LINKER_FLAGS}" // Realm configuration -#cmakedefine01 KITSUNE_REALM_ENABLE - -#define KITSUNE_REALM_ENABLED KITSUNE_REALM_ENABLE +#cmakedefine01 KITSUNE_REALM_ENABLED #define KITSUNE_REALM_EXTRA_PREPROCESSOR_FLAGS "${KITSUNE_REALM_EXTRA_PREPROCESSOR_FLAGS}" #define KITSUNE_REALM_EXTRA_COMPILER_FLAGS "${KITSUNE_REALM_EXTRA_COMPILER_FLAGS}" diff --git a/kitsune/runtime/CMakeLists.txt b/kitsune/runtime/CMakeLists.txt index 9f60d2c80709dd..91f580974dc02a 100644 --- a/kitsune/runtime/CMakeLists.txt +++ b/kitsune/runtime/CMakeLists.txt @@ -84,7 +84,7 @@ target_link_libraries(${KITRT} # The KITSUNE_CUDA_* variables are defined in ../CMakeLists.txt (i.e. in # kitsune/CMakeLists.txt). They are passed in via CMake because the Kitsune # runtime is treated as an "ExternalProject". -if (KITSUNE_CUDA_ENABLE) +if (KITSUNE_CUDA_ENABLED) list(APPEND KITRT_HDRS cuda/kitcuda.h cuda/kitcuda_dylib.h) @@ -130,7 +130,7 @@ endif() # targets are actually intended for the language and not runtime libraries. # Unfortunately, these details seem to be a moving target with ecah release # of rocm/hip... -if (KITSUNE_HIP_ENABLE) +if (KITSUNE_HIP_ENABLED) list(APPEND KITRT_HDRS hip/kithip.h hip/kithip_dylib.h) diff --git a/kitsune/test/CMakeLists.txt b/kitsune/test/CMakeLists.txt index 1866137b8e3c5a..96c1e32665f1d7 100644 --- a/kitsune/test/CMakeLists.txt +++ b/kitsune/test/CMakeLists.txt @@ -2,13 +2,13 @@ # for use by Lit, and delegates to LLVM's lit test handlers. llvm_canonicalize_cmake_booleans( - KITSUNE_KOKKOS_ENABLE - KITSUNE_CUDA_ENABLE - KITSUNE_HIP_ENABLE - KITSUNE_OPENCILK_ENABLE - KITSUNE_OPENMP_ENABLE - KITSUNE_QTHREADS_ENABLE - KITSUNE_REALM_ENABLE + KITSUNE_KOKKOS_ENABLED + KITSUNE_CUDA_ENABLED + KITSUNE_HIP_ENABLED + KITSUNE_OPENCILK_ENABLED + KITSUNE_OPENMP_ENABLED + KITSUNE_QTHREADS_ENABLED + KITSUNE_REALM_ENABLED ) configure_lit_site_cfg( diff --git a/kitsune/test/cuda/config.cpp b/kitsune/test/cuda/config.cpp index 3da23b997a858f..f09a25731af05a 100644 --- a/kitsune/test/cuda/config.cpp +++ b/kitsune/test/cuda/config.cpp @@ -18,7 +18,11 @@ // CHECK-CUSTOM-SAME: "-D_tapir_cuda_target" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" // CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK-CUSTOM: "-some_linker_flag" // CHECK-CUSTOM-SAME: -lkitrt // CHECK-CUSTOM-SAME: -lcudart // CHECK-CUSTOM-SAME: -lcuda diff --git a/kitsune/test/cuda/default-args.cpp b/kitsune/test/cuda/default-args.cpp index ba5434b55b523a..6acbb1a06013ca 100644 --- a/kitsune/test/cuda/default-args.cpp +++ b/kitsune/test/cuda/default-args.cpp @@ -3,10 +3,9 @@ // CHECK: "-cc1" // CHECK-SAME: "-D_tapir_cuda_target" -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lkitrt +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lkitrt // CHECK-SAME: -lcudart // CHECK-SAME: -lcuda diff --git a/kitsune/test/hip/config.cpp b/kitsune/test/hip/config.cpp index 37fcbff62c7586..48f418458b6263 100644 --- a/kitsune/test/hip/config.cpp +++ b/kitsune/test/hip/config.cpp @@ -16,7 +16,10 @@ // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-D_tapir_hip_target" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK-CUSTOM: "-some_linker_flag" // CHECK-CUSTOM-SAME: -lkitrt // CHECK-CUSTOM-SAME: "-lamdhip64" diff --git a/kitsune/test/hip/default-args.cpp b/kitsune/test/hip/default-args.cpp index bafd7bc54efb0f..6a525391de9ace 100644 --- a/kitsune/test/hip/default-args.cpp +++ b/kitsune/test/hip/default-args.cpp @@ -3,9 +3,8 @@ // CHECK: "-cc1" // CHECK-SAME: "-D_tapir_hip_target" -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lkitrt +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lkitrt // CHECK-SAME: -lamdhip64 diff --git a/kitsune/test/kokkos/config.cpp b/kitsune/test/kokkos/config.cpp index 89d32b5aea9dd9..e535340df3bb0c 100644 --- a/kitsune/test/kokkos/config.cpp +++ b/kitsune/test/kokkos/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/kitsune/test/kokkos/default-args.cpp b/kitsune/test/kokkos/default-args.cpp index c15196675aa4cf..cdb88ee5664027 100644 --- a/kitsune/test/kokkos/default-args.cpp +++ b/kitsune/test/kokkos/default-args.cpp @@ -3,9 +3,8 @@ // CHECK: "-cc1" // CHECK-SAME: -I{{[^ ]*}}/include/kokkos -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK-NEXT: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lkokkoscore +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lkokkoscore // CHECK-SAME: -lkitrt diff --git a/kitsune/test/lit.site.cfg.py.in b/kitsune/test/lit.site.cfg.py.in index fcff8568ee54a8..7f914162fffeb5 100644 --- a/kitsune/test/lit.site.cfg.py.in +++ b/kitsune/test/lit.site.cfg.py.in @@ -19,13 +19,13 @@ config.host_cxx = "@CMAKE_CXX_COMPILER@" config.host_arch = "@HOST_ARCH@" config.python_executable = "@Python3_EXECUTABLE@" config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@") -config.kitsune_kokkos_enable = @KITSUNE_KOKKOS_ENABLE@ -config.kitsune_cuda_enable = @KITSUNE_CUDA_ENABLE@ -config.kitsune_hip_enable = @KITSUNE_HIP_ENABLE@ -config.kitsune_opencilk_enable = @KITSUNE_OPENCILK_ENABLE@ -config.kitsune_openmp_enable = @KITSUNE_OPENMP_ENABLE@ -config.kitsune_qthreads_enable = @KITSUNE_QTHREADS_ENABLE@ -config.kitsune_realm_enable = @KITSUNE_REALM_ENABLE@ +config.kitsune_kokkos_enable = @KITSUNE_KOKKOS_ENABLED@ +config.kitsune_cuda_enable = @KITSUNE_CUDA_ENABLED@ +config.kitsune_hip_enable = @KITSUNE_HIP_ENABLED@ +config.kitsune_opencilk_enable = @KITSUNE_OPENCILK_ENABLED@ +config.kitsune_openmp_enable = @KITSUNE_OPENMP_ENABLED@ +config.kitsune_qthreads_enable = @KITSUNE_QTHREADS_ENABLED@ +config.kitsune_realm_enable = @KITSUNE_REALM_ENABLED@ config.kitcc = "@KITSUNE_C_FRONTEND@" config.kitxx = "@KITSUNE_CXX_FRONTEND@" diff --git a/kitsune/test/none/config.cpp b/kitsune/test/none/config.cpp index 6f345be597cc2c..0dfced607a2344 100644 --- a/kitsune/test/none/config.cpp +++ b/kitsune/test/none/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: /{{[^ ]*}}ld -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/kitsune/test/opencilk/config.cpp b/kitsune/test/opencilk/config.cpp index 30e515c0f854ae..e7c4b7f7846fc6 100644 --- a/kitsune/test/opencilk/config.cpp +++ b/kitsune/test/opencilk/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/kitsune/test/opencilk/default-args.cpp b/kitsune/test/opencilk/default-args.cpp index aff3b667e12b9b..a37294a05f80c4 100644 --- a/kitsune/test/opencilk/default-args.cpp +++ b/kitsune/test/opencilk/default-args.cpp @@ -1,8 +1,7 @@ // RUN: %kitxx -### -ftapir=opencilk %s 2>&1 | FileCheck %s -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lopencilk +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lopencilk // CHECK-SAME: -lkitrt diff --git a/kitsune/test/openmp/config.cpp b/kitsune/test/openmp/config.cpp index 0231b58063961a..3e156571da0e64 100644 --- a/kitsune/test/openmp/config.cpp +++ b/kitsune/test/openmp/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/kitsune/test/openmp/default-args.cpp b/kitsune/test/openmp/default-args.cpp index 3c2b03a1088145..f530c328370f3e 100644 --- a/kitsune/test/openmp/default-args.cpp +++ b/kitsune/test/openmp/default-args.cpp @@ -1,8 +1,7 @@ // RUN: %kitxx -### -ftapir=openmp %s 2>&1 | FileCheck %s -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lomp +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK: -lomp // CHECK-SAME: -lkitrt diff --git a/kitsune/test/qthreads/config.cpp b/kitsune/test/qthreads/config.cpp index 583522e1dafc2f..59df17b020e2e5 100644 --- a/kitsune/test/qthreads/config.cpp +++ b/kitsune/test/qthreads/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. // CHECK-CUSTOM-SAME: "-some_linker_flag" diff --git a/kitsune/test/qthreads/default-args.cpp b/kitsune/test/qthreads/default-args.cpp index 06c7f7bec789ef..4a17a9c0c7cd88 100644 --- a/kitsune/test/qthreads/default-args.cpp +++ b/kitsune/test/qthreads/default-args.cpp @@ -1,8 +1,7 @@ // RUN: %kitxx -### -ftapir=qthreads %s 2>&1 | FileCheck %s -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lqthreads +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lqthreads // CHECK-SAME: -lkitrt diff --git a/kitsune/test/realm/config.cpp b/kitsune/test/realm/config.cpp index 8864e0566ac903..611c9c296b67a6 100644 --- a/kitsune/test/realm/config.cpp +++ b/kitsune/test/realm/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/kitsune/test/realm/default-args.cpp b/kitsune/test/realm/default-args.cpp index 51a524523500f7..0fa62e404e6c3e 100644 --- a/kitsune/test/realm/default-args.cpp +++ b/kitsune/test/realm/default-args.cpp @@ -1,9 +1,8 @@ // RUN: %kitxx -### -ftapir=realm %s 2>&1 | FileCheck %s -// The link line may have some optional space at the start of the line followed -// by the absolute path to the linker in quotes. The linker name itself could -// be lld, but we also allow matches to ld.gold, ld.bfd etc. -// CHECK: {{^[ ]*"[^"]+/[l]?}}ld{{[.]?[^ ]*}}" -// CHECK-SAME: -lrealm +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flags. +// CHECK: -lrealm // CHECK-SAME: -lrealm-abi // CHECK-SAME: -lkitrt diff --git a/kitsune/test/serial/config.cpp b/kitsune/test/serial/config.cpp index 71a59a39db7cc7..12c502955a09a7 100644 --- a/kitsune/test/serial/config.cpp +++ b/kitsune/test/serial/config.cpp @@ -15,5 +15,8 @@ // CHECK-CUSTOM: "-cc1" // CHECK-CUSTOM-SAME: "-D" "some_preprocessor_flag" // CHECK-CUSTOM-SAME: "-Wsome_compiler_flag" -// CHECK-CUSTOM: /{{[^ ]*}}ld -// CHECK-CUSTOM-SAME: "-some_linker_flag" + +// It is a pain to check for the actual linker executable. There are far too +// many options depending on the platform, so just check the next line for the +// expected linker flag. +// CHECK-CUSTOM: "-some_linker_flag" diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 203c5d90bee8c4..1c2068c595248d 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -253,12 +253,60 @@ if (NOT "kitsune" IN_LIST LLVM_ENABLE_PROJECTS) list(APPEND LLVM_ENABLE_PROJECTS "lld") endif () - message(STATUS "New LLVM_ENABLE_PROJECTS: ${LLVM_ENABLE_PROJECTS}") - # Currently, flang is not required, but if it is, MLIR should be enabled as # well. + + message(STATUS "Updated LLVM_ENABLE_PROJECTS: ${LLVM_ENABLE_PROJECTS}") endif () +# Ideally, this should be left in kitsune/CMakeLists.txt, but we need these to +# conditionally compile the tapir targets that are enabled. The kitsune/ +# directory is only processed after the subdirectories of llvm/, but that is +# too late. It would be nice to find a way to set these in kitsune/ so the +# footprint in this file is reduced. +# +# The Kokkos option does not need to be moved here (for now) because that only +# affects clang. And we have ensured that kitsune is configured before clang. +# +set(KITSUNE_CUDA_ENABLED OFF CACHE INTERNAL "Enable the cuda tapir target" FORCE) +set(KITSUNE_HIP_ENABLED OFF CACHE INTERNAL "Enable the hip tapir target" FORCE) +set(KITSUNE_OPENCILK_ENABLED OFF CACHE INTERNAL "Enable the opencilk tapir target" FORCE) +set(KITSUNE_OPENMP_ENABLED OFF CACHE INTERNAL "Enable the openmp tapir target" FORCE) +set(KITSUNE_QTHREADS_ENABLED OFF CACHE INTERNAL "Enable the qthreads tapir target" FORCE) +set(KITSUNE_REALM_ENABLED OFF CACHE INTERNAL "Enable the realm tapir target" FORCE) + +# TODO: Need to update the openmp, qthreads and realm targets and add them +# back into this list. These targets have not been tested in a while and have +# probably bit-rotted. Enabling them will raise a configure-time error. +set(KITSUNE_ALL_TAPIR_TARGETS + "cuda;hip;opencilk" + CACHE STRING + "All known Tapir targets.") + +set(KITSUNE_DEFAULT_TAPIR_TARGETS + "cuda;hip;opencilk" + CACHE STRING + "The Tapir targets that are built by default if targets are not explicitly specified.") + +set(KITSUNE_ENABLE_TAPIR_TARGETS + "${KITSUNE_DEFAULT_TAPIR_TARGETS}" + CACHE STRING + "Semicolon-separated list of runtime targets to build (or \"all\".)") + +if (NOT KITSUNE_ENABLE_TAPIR_TARGETS) + message(FATAL_ERROR "At least one runtime target must be built") +endif () + +foreach(target IN LISTS KITSUNE_ENABLE_TAPIR_TARGETS) + if (target IN_LIST KITSUNE_ALL_TAPIR_TARGETS) + message(STATUS "${target} tapir target enabled") + string(TOUPPER "${target}" upper_target) + set(KITSUNE_${upper_target}_ENABLED ON CACHE INTERNAL "Enable the ${target} tapir target" FORCE) + else () + message(FATAL_ERROR "Unknown Tapir target: ${target}") + endif() +endforeach() + # We always want libLLVM to be build because we link to it in Kitsune's runtime, # libkitrt set(LLVM_BUILD_LLVM_DYLIB ON) diff --git a/llvm/lib/Transforms/Tapir/CMakeLists.txt b/llvm/lib/Transforms/Tapir/CMakeLists.txt index 2979f8d0d6f5e3..ab7b21bf1041a7 100644 --- a/llvm/lib/Transforms/Tapir/CMakeLists.txt +++ b/llvm/lib/Transforms/Tapir/CMakeLists.txt @@ -1,27 +1,60 @@ find_package(CUDAToolkit) -add_llvm_component_library(LLVMTapirOpts - CudaABI.cpp +set(SOURCES DRFScopedNoAliasAA.cpp - HipABI.cpp LambdaABI.cpp LoopSpawningTI.cpp LoopStripMine.cpp LoopStripMinePass.cpp LoweringUtils.cpp OMPTaskABI.cpp - OpenCilkABI.cpp - OpenMPABI.cpp Outline.cpp - QthreadsABI.cpp - RealmABI.cpp GPUABI.cpp - SerialABI.cpp SerializeSmallTasks.cpp Tapir.cpp TapirGPUUtils.cpp TapirToTarget.cpp TapirLoopInfo.cpp +) + +if (KITSUNE_CUDA_ENABLED) + list(APPEND SOURCES CudaABI.cpp) +endif () + +if (KITSUNE_HIP_ENABLED) + list(APPEND SOURCES HipABI.cpp) +endif () + +if (KITSUNE_OPENCILK_ENABLED) + list(APPEND SOURCES OpenCilkABI.cpp) +endif () + +if (KITSUNE_OPENMP_ENABLED) + list(APPEND SOURCES OpenMPABI.cpp) +endif () + +if (KITSUNE_QTHREADS_ENABLED) + list(APPEND SOURCES QthreadsABI.cpp) +endif () + +if (KITSUNE_REALM_ENABLED) + list(APPEND SOURCES RealmABI.cpp) +endif () + +# Some ABI targets are always enabled. +list(APPEND SOURCES SerialABI.cpp) + +# TODO: Perhaps we need to do the same with LambdaABI and OMPTaskABI. + +add_llvm_component_library(LLVMTapirOpts + ${SOURCES} + + # LLVM discourages the use of this, but we definitely don't want to build + # ABI targets unnecessarily (besides which, getting them to compile can be + # fairly difficult without target-specific headers such as those from a Cuda + # installation which may be in a non-standard location). Plus, they use them + # in certain places anyway. + PARTIAL_SOURCES_INTENDED ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms @@ -46,7 +79,7 @@ add_llvm_component_library(LLVMTapirOpts TransformUtils Vectorize Passes - ) +) if (CUDAToolkit_FOUND) message(STATUS "Tapir ABI has CUDA version info: ${CUDAToolkit_VERSION}") diff --git a/llvm/lib/Transforms/Tapir/LoweringUtils.cpp b/llvm/lib/Transforms/Tapir/LoweringUtils.cpp index b8705d5ee1ebc4..31889e48fa2190 100644 --- a/llvm/lib/Transforms/Tapir/LoweringUtils.cpp +++ b/llvm/lib/Transforms/Tapir/LoweringUtils.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "kitsune/Config/config.h" #include "llvm/Analysis/TapirTaskInfo.h" #include "llvm/Demangle/Demangle.h" #include "llvm/IR/Dominators.h" @@ -44,27 +45,50 @@ static const char TimerGroupName[] = DEBUG_TYPE; static const char TimerGroupDescription[] = "Tapir lowering"; TapirTarget *llvm::getTapirTargetFromID(Module &M, TapirTargetID ID) { + // Yes, this is absolutely hideous. We should try to find a nicer way than + // this horrendous conditionally compiled mess! switch (ID) { case TapirTargetID::None: return nullptr; case TapirTargetID::Serial: return new SerialABI(M); + +#if KITSUNE_CUDA_ENABLED case TapirTargetID::Cuda: return new CudaABI(M); +#endif // KITSUNE_CUDA_ENABLED + +#if KITSUNE_HIP_ENABLED case TapirTargetID::Hip: return new HipABI(M); +#endif // KITSUNE_HIP_ENABLED + + // For now, these targets are always built, but that might change. case TapirTargetID::Lambda: return new LambdaABI(M); case TapirTargetID::OMPTask: return new OMPTaskABI(M); + +#if KITSUNE_OPENCILK_ENABLED case TapirTargetID::OpenCilk: return new OpenCilkABI(M); +#endif // KITSUNE_OPENCILK_ENABLED + +#if KITSUNE_OPENMP_ENABLED case TapirTargetID::OpenMP: llvm_unreachable("OpenMP ABI is out of date"); +#endif // KITSUNE_OPENMP_ENABLED + +#if KITSUNE_QTHREADS_ENABLED case TapirTargetID::Qthreads: return new QthreadsABI(M); +#endif // KITSUNE_QTHREADS_ENABLED + +#if KITSUNE_REALM_ENABLED case TapirTargetID::Realm: return new RealmABI(M); +#endif // KITSUNE_REALM_ENABLED + default: llvm_unreachable("Invalid TapirTargetID"); } @@ -696,18 +720,18 @@ Function *llvm::createHelperForTask(Function &F, Task *T, ValueSet &Args, NamedRegionTimer NRT("CreateHelper", "Create helper function", TimerGroupName, TimerGroupDescription, TimePassesIsEnabled); - Module* M = F.getParent(); + Module *M = F.getParent(); CloneFunctionChangeType Changes = M == DestM ? CloneFunctionChangeType::GlobalChanges : CloneFunctionChangeType::DifferentModule; std::unique_ptr Mat = std::make_unique( dyn_cast(DI->getSyncRegion())); - Helper = CreateHelper( - Args, Outputs, TaskBlocks, Header, Entry, DI->getContinue(), VMap, - DestM, Changes, Returns, NameSuffix.str(), - &ReattachBlocks, &TaskResumeBlocks, &SharedEHEntries, nullptr, - &UnreachableExits, ReturnType, nullptr, nullptr, Mat.get()); + Helper = CreateHelper(Args, Outputs, TaskBlocks, Header, Entry, + DI->getContinue(), VMap, DestM, Changes, Returns, + NameSuffix.str(), &ReattachBlocks, &TaskResumeBlocks, + &SharedEHEntries, nullptr, &UnreachableExits, + ReturnType, nullptr, nullptr, Mat.get()); } assert(Returns.empty() && "Returns cloned when cloning detached CFG."); @@ -921,17 +945,17 @@ Function *llvm::createHelperForTaskFrame(Function &F, Spindle *TF, NamedRegionTimer NRT("CreateHelper", "Create helper function", TimerGroupName, TimerGroupDescription, TimePassesIsEnabled); - Module* M = F.getParent(); + Module *M = F.getParent(); CloneFunctionChangeType Changes = M == DestM ? CloneFunctionChangeType::GlobalChanges : CloneFunctionChangeType::DifferentModule; std::unique_ptr Mat = std::make_unique(); - Helper = CreateHelper(Args, Outputs, TaskBlocks, Header, Entry, Continue, - VMap, DestM, Changes, Returns, - NameSuffix.str(), &TFEndBlocks, &TFResumeBlocks, - &SharedEHEntries, nullptr, nullptr, ReturnType, - nullptr, nullptr, Mat.get()); + Helper = + CreateHelper(Args, Outputs, TaskBlocks, Header, Entry, Continue, VMap, + DestM, Changes, Returns, NameSuffix.str(), &TFEndBlocks, + &TFResumeBlocks, &SharedEHEntries, nullptr, nullptr, + ReturnType, nullptr, nullptr, Mat.get()); } // end timed region assert(Returns.empty() && "Returns cloned when cloning detached CFG."); @@ -1121,8 +1145,8 @@ TaskOutlineInfo llvm::outlineTask(Task *T, ValueSet &Inputs, Target->setupTaskOutlineArgs(F, HelperArgs, HelperInputs, TaskHelperArgs); // Clone the blocks into a helper function. - Function *Helper = createHelperForTask(F, T, HelperArgs, DestM, VMap, - ReturnType, OA); + Function *Helper = + createHelperForTask(F, T, HelperArgs, DestM, VMap, ReturnType, OA); Value *ClonedTFCreate = TFCreate ? VMap[TFCreate] : nullptr; return TaskOutlineInfo( Helper, T->getEntry(), dyn_cast_or_null(VMap[DI]),