Commit 1043ece1 authored by Patrick McCormick's avatar Patrick McCormick
Browse files

A pretty significant overhaul to our cmake build approach to make it more

stable, have less overhead dealing with dependencies, fix some broken bits
(e.g., building the examples), and finally fit with the new bitcode approach
used by cheetah/opencilk for runtime code.

  -- some internal renaming done w/ cmake variables to be a bit more
     consistent across the code base.
  -- kitsune components (off top-level directory) now built as a runtime
     target (as supported with llvm's build system terminology).
  -- automatic fetch of cheetah (opencilk runtime) and kokkos by the
     cmake setup.  Both rolled into the overall build. For cheetah this
     allows for compatible bitcode file generation.  For kokkos allows
     better control of feature set used and related details. No need for
     git submodules for either package.
  -- numerous bug fixes, cleanup, and in some cases an overhaul of some
     messy details (like the way the kitsune build was duct taped into
     clang).

New clang feature for the use of automatically generated configuration
files.  This is built on the base functionality provided by the
--config command line argument.  The extensions allow a config file per
"target" (e.g. kokkos, and each of supported runtime ABIs).  These files
can live in one of four places:

   1. in the same directory the compiler is being invoked from.
   2. a user-specified directory to search.
   3. a kitsune-centric directory path to search.
   4. a system-wide directory to search.

Each of the configuration files are named related to the kitsune and
tapir specific features (e.g., kokkos.cfg, opencilk.cfg, qthreads.cfg,
etc.).  The names and paths of files and directories can be configured
via the cmake build.

Overall, there is an updated cmake cache file in
kitsune/cmake/caches/kitsune-dev.cmake that has documented settings in it
that should provide a good reference and starting point for builds.

This current feature set is primarily intended for in-tree testing (vs.
installed use cases).  Some of the features used still need to be refined
and tested in installed configurations.  Most things can be overhauled
via the command line (i.e., there should be no hard errors) but there are
undoubtedly mistakes and misconfiguration lurking in many corners...

CMake updates to try and get dependencies correctly specified
due to parallel build isssues (races between dependent packages).
Haven't been able to reproduce build issues with these fixes.

Some more robust error handling for opencilk bitcode loading -- seg
faulted before if assertions were disabled.  Will now print a fatal
error message and exit.
parent ca715dac
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -29,8 +29,11 @@
#cmakedefine01 KITSUNE_ENABLE_OPENCL_TARGET
#cmakedefine01 KITSUNE_ENABLE_HIP_TARGET

/* kitsune+tapir default configuration filenames */
/* kitsune default kokkos configure (.cfg) filename */
#cmakedefine KITSUNE_KOKKOS_CFG_FILENAME "${KITSUNE_KOKKOS_CFG_FILENAME}"

/* tapir default target-specific configure (.cfg) filenames */
#cmakedefine TAPIR_NONE_TARGET_CFG_FILENAME "${TAPIR_SERIAL_TARGET_CFG_FILENAME}"
#cmakedefine TAPIR_SERIAL_TARGET_CFG_FILENAME "${TAPIR_SERIAL_TARGET_CFG_FILENAME}"
#cmakedefine TAPIR_OPENCILK_TARGET_CFG_FILENAME "${TAPIR_OPENCILK_TARGET_CFG_FILENAME}"
#cmakedefine TAPIR_CUDA_TARGET_CFG_FILENAME "${TAPIR_CUDA_TARGET_CFG_FILENAME}"
+6 −4
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public:
  /// Kitsune directory for config files.
  std::string KitsuneConfigDir;
  std::string KitsuneKokkosCfgFile;
  std::string TapirNoneCfgFile;
  std::string TapirSerialCfgFile;
  std::string TapirOpenCilkCfgFile;
  std::string TapirCudaCfgFile;
@@ -248,6 +249,7 @@ private:

  /// Name of configuration file if used.
  std::string ConfigFile;
  llvm::SmallVector<std::string, 8> ConfigFileList;

  /// Allocator for string saver.
  llvm::BumpPtrAllocator Alloc;
+60 −44
Original line number Diff line number Diff line
@@ -39,26 +39,42 @@ endif()
# within Clang.
#

# The none target (-ftapir=none) is always enabled, just provide a
# config filename and process the default .cfg.in file so it lands in
# the build/install.
set(TAPIR_NONE_TARGET_CFG_FILENAME "none.cfg"
    CACHE STRING "Default serial runtime ABI target Clang .cfg filename.")
configure_file(${CLANG_SOURCE_DIR}/kitsune/none.cfg.in
    ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_NONE_TARGET_CFG_FILENAME})

# The serial target (-ftapir=serial) is always enabled, just provide a
# config filename and process the default .cfg.in file so it lands in
# the build/install.
set(TAPIR_SERIAL_TARGET_CFG_FILENAME "serial.cfg"
    CACHE STRING "Default serial runtime ABI target Clang .cfg filename.")
configure_file(${CLANG_SOURCE_DIR}/kitsune/serial.cfg.in
    ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_SERIAL_TARGET_CFG_FILENAME})

# OpenCilk is always enabled.
set(KITSUNE_OPENCILK_TARGET_ENABLED ON CACHE BOOL "The OpenCilk runtime is always enabled -- this is a doppelganger for use in macros...")
if (NOT KITSUNE_OPENCILK_TARGET_ENABLED)
  message(WARNING "The OpenCilk runtime is always enabled, resetting it to ON.")
  set(KITSUNE_OPENCILK_TARGET_ENABLED ON BOOL FORCE)
endif()
set(KITSUNE_OPENCILK_TARGET_CFG_FILENAME "opencilk.cfg"
set(TAPIR_OPENCILK_TARGET_CFG_FILENAME "opencilk.cfg"
    CACHE STRING "Default OpenCilk runtime ABI target Clang .cfg filename.")
set(KITSUNE_OPENCILK_TARGET_EXTRA_LINK_FLAGS
    ""
    CACHE
    STRING "Additional link flags needed for the OpenCilk runtime ABI target.")
# Note that link libraries are hard-coded into Clang source for OpenCilk support.
configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_OPENCILK_TARGET_CFG_FILENAME}.in
    ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_OPENCILK_TARGET_CFG_FILENAME})
configure_file(${CLANG_SOURCE_DIR}/kitsune/opencilk.cfg.in
    ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_OPENCILK_TARGET_CFG_FILENAME})

option(KITSUNE_ENABLE_OPENMP_TARGET
    "Enable the Kitsune+Tapir OpenMP runtime codegen target." OFF)
if (KITSUNE_ENABLE_OPENMP_TARGET)
  set(KITSUNE_OPENMP_TARGET_CFG_FILENAME
  set(TAPIR_OPENMP_TARGET_CFG_FILENAME
      "openmp.cfg"
      CACHE
      STRING "Default OpenMP runtime ABI target Clang .cfg filename.")
@@ -71,14 +87,14 @@ if (KITSUNE_ENABLE_OPENMP_TARGET)
      CACHE
      STRING "Link library flags (-L, -lxxx) for the OpenMP runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_OPENMP_TARGET_CFG_FILENAME}.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_OPENMP_TARGET_CFG_FILENAME})
  configure_file(${CLANG_SOURCE_DIR}/kitsune/openmp.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_OPENMP_TARGET_CFG_FILENAME})
endif()

option(KITSUNE_ENABLE_QTHREADS_TARGET
    "Enable the Kitsune+Tapir Qthreads runtime codegen target." OFF)
if (KITSUNE_ENABLE_QTHREADS_TARGET)
  set(KITSUNE_QTHREADS_TARGET_CFG_FILENAME
  set(TAPIR_QTHREADS_TARGET_CFG_FILENAME
      "qthreads.cfg"
      CACHE
      STRING "Default Qthreads runtime ABI target Clang .cfg filename.")
@@ -91,14 +107,14 @@ if (KITSUNE_ENABLE_QTHREADS_TARGET)
      CACHE
      STRING "Link library flags (-L, -lxxx) needed for the Qthreads runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_QTHREADS_TARGET_CFG_FILENAME}.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_QTHREADS_TARGET_CFG_FILENAME})
  configure_file(${CLANG_SOURCE_DIR}/kitsune/qthreads.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_QTHREADS_TARGET_CFG_FILENAME})
endif()

option(KITSUNE_ENABLE_REALM_TARGET
    "Enable the Kitsune+Tapir Realm runtime codegen target." OFF)
if (KITSUNE_ENABLE_REALM_TARGET)
  set(KITSUNE_REALM_TARGET_CFG_FILENAME
  set(TAPIR_REALM_TARGET_CFG_FILENAME
      "realm.cfg"
      CACHE
      STRING "Default Realm runtime ABI target Clang .cfg filename.")
@@ -111,7 +127,7 @@ if (KITSUNE_ENABLE_REALM_TARGET)
      CACHE
      STRING "Link library flags (-L, -lxx) needed for the Realm runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_REALM_TARGET_CFG_FILENAME}.in
  configure_file(${CLANG_SOURCE_DIR}/kitsune/realm.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_REALM_TARGET_CFG_FILENAME})
endif()

@@ -119,7 +135,7 @@ option(KITSUNE_ENABLE_CUDATK_TARGET
    "Enable the Kitsune+Tapir CUDA Toolkit target and codegen library." OFF)
if (KITSUNE_ENABLE_CUDATK_TARGET)
  find_package(CUDAToolkit 10...11 REQUIRED)  # We may need to be a bit more specifc on minor versions here.
  set(KITSUNE_CUDATK_TARGET_CFG_FILENAME
  set(TAPIR_CUDATK_TARGET_CFG_FILENAME
      "cudatk.cfg"
      CACHE
      STRING "Default CUDA Toolkit runtime ABI target Clang .cfg filename.")
@@ -132,15 +148,15 @@ if (KITSUNE_ENABLE_CUDATK_TARGET)
      CACHE
      STRING "Link library flags (-L, -lxxx) needed for the CUDA Toolkit runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_CUDATK_TARGET_CFG_FILENAME}.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_CUDATK_TARGET_CFG_FILENAME})
  configure_file(${CLANG_SOURCE_DIR}/kitsune/cudatk.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_CUDATK_TARGET_CFG_FILENAME})
endif()

# TODO: This needs to be connected to reality... --PM
option(KITSUNE_ENABLE_HIP_TARGET
    "Enable the Kitsune+Tapir HIP target and codegen library." OFF)
if (KITSUNE_ENABLE_HIP_TARGET)
  set(KITSUNE_HIP_TARGET_CFG_FILENAME
  set(TAPIR_HIP_TARGET_CFG_FILENAME
      "hip.cfg"
      CACHE
      STRING "Default HIP runtime ABI target Clang .cfg filename.")
@@ -152,8 +168,8 @@ if (KITSUNE_ENABLE_HIP_TARGET)
      "-L${-lhip" # I made this up... --PM
      CACHE STRING "Link library flags (-L, -lxxx) needed for the for the HIP runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_HIP_TARGET_CFG_FILENAME}.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_HIP_TARGET_CFG_FILENAME})
  configure_file(${CLANG_SOURCE_DIR}/kitsune/hip.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${TAPIR_HIP_TARGET_CFG_FILENAME})
endif()

# TODO: This needs to be connected to reality... --PM
@@ -171,7 +187,7 @@ if (KITSUNE_ENABLE_OPENCL_TARGET)
      "-lopencl" # I made this up... --PM
      CACHE STRING "Additional link flags needed for OpenCL runtime ABI target.")
  #
  configure_file(${CLANG_SOURCE_DIR}/kitsune/${KITSUNE_OPENCL_TARGET_CFG_FILENAME}.in
  configure_file(${CLANG_SOURCE_DIR}/kitsune/opencl.cfg.in
      ${LLVM_BINARY_DIR}/share/kitsune/${KITSUNE_OPENCL_TARGET_CFG_FILENAME})
endif()

+7 −2
Original line number Diff line number Diff line
# Flags for the Kokkos mode (-fkokkos).
# CXX flags 
${KITSUNE_KOKKOS_CXX_FLAGS}
# Link flags and link libraries.
${KITSUNE_KOKKOS_EXTRA_LINK_FLAGS} ${KITSUNE_KOKKOS_LINK_LIBS_FLAGS}
${KITSUNE_KOKKOS_EXTRA_LINK_FLAGS} 
${KITSUNE_KOKKOS_LINK_LIBS_FLAGS}

# for in-tree use... 
-I${LLVM_BINARY_DIR}/kokkos/core/src -I${LLVM_BINARY_DIR}/kokkos/containers/src 
-I${LLVM_BINARY_DIR}/runtimes/runtimes-bins/
-L${LLVM_BINARY_DIR}/runtimes/runtimes-bins/_deps/kokkos-build/core/src/ 
+3 −0
Original line number Diff line number Diff line
# Flags for the serial 'none' ABI target.
${KITSUNE_OPENCILK_TARGET_EXTRA_LINK_FLAGS} 
Loading