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

[kitsune] Fixes to support building only a subset of targets #58

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
69 changes: 18 additions & 51 deletions kitsune/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion kitsune/cmake/caches/kitsune-dev-darwin-aarch64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion kitsune/cmake/caches/kitsune-dev-darwin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion kitsune/cmake/caches/kitsune-dev-desktop.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
14 changes: 7 additions & 7 deletions kitsune/configs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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()
Expand Down
22 changes: 11 additions & 11 deletions kitsune/experiments/inc/config.mk.cmake
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions kitsune/experiments/inc/cuda.mk
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

6 changes: 3 additions & 3 deletions kitsune/experiments/inc/hip.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ifneq ($(KITSUNE_HIP_ENABLE),)
ifneq ($(KITSUNE_HIP_ENABLED),)
AMDGPU_ARCH?=gfx90a
$(info hip: amdgpu arch: $(AMDGPU_ARCH))

Expand All @@ -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

28 changes: 7 additions & 21 deletions kitsune/include/kitsune/Config/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down
Loading