diff --git a/CMakeLists.txt b/CMakeLists.txt index 19400f63ed..520898704d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,10 +130,8 @@ add_feature_info(TBB ENABLE_TBB "Intel Thread-Building Blocks (TBB) supports pro option(ENABLE_CUDA "Enable use of CUDA with TiledArray" OFF) add_feature_info(CUDA ENABLE_CUDA "NVIDIA CUDA support for GPU") -if(ENABLE_CUDA) - option(ENABLE_CUDA_ERROR_CHECK "TiledArray will always check errors in CUDA calls" ON) - add_feature_info(CUDA_ERROR_CHECK ENABLE_CUDA_ERROR_CHECK "Checks CUDA Error") -endif() +option(ENABLE_HIP "Enable use of HIP with TiledArray" OFF) +add_feature_info(HIP ENABLE_HIP "AMD HIP/ROCm support for GPU") option(ENABLE_GPERFTOOLS "Enable linking with Gperftools" OFF) add_feature_info(GPERFTOOLS ENABLE_GPERFTOOLS "Google Performance Tools provide fast memory allocation and performance profiling") @@ -306,10 +304,13 @@ include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) add_custom_target(External-tiledarray) # required deps: -# 1. CUDA first since others may depend on it +# 1. derive runtime (CUDA/HIP/...) first since others may depend on it if(ENABLE_CUDA) include(external/cuda.cmake) endif() +if(ENABLE_HIP) + include(external/hip.cmake) +endif() if (TA_TTG) include(${PROJECT_SOURCE_DIR}/cmake/modules/FindOrFetchTTG.cmake) endif(TA_TTG) diff --git a/INSTALL.md b/INSTALL.md index f265676d6a..1aabcf0a5f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -329,7 +329,7 @@ Support for execution on CUDA-enabled hardware is controlled by the following va * `ENABLE_CUDA` -- Set to `ON` to turn on CUDA support. [Default=OFF]. * `CMAKE_CUDA_HOST_COMPILER` -- Set to the path to the host C++ compiler to be used by CUDA compiler. CUDA compilers used to be notorious for only being able to use specific C++ host compilers, but support for more recent C++ host compilers has improved. The default is determined by the CUDA compiler and the user environment variables (`PATH` etc.). -* `ENABLE_CUDA_ERROR_CHECK` -- Set to `ON` to turn on assertions for successful completion of calls to CUDA runtime and libraries. [Default=OFF]. +* `ENABLE_HIP` -- Set to `ON` to turn on HIP support. [Default=OFF]. * `LIBRETT_INSTALL_DIR` -- the installation prefix of the pre-installed LibreTT library. This should not be normally needed; it is strongly recommended to let TiledArray build and install LibreTT. * `UMPIRE_INSTALL_DIR` -- the installation prefix of the pre-installed Umpire library. This should not be normally needed; it is strongly recommended to let TiledArray build and install Umpire. diff --git a/external/cuda.cmake b/external/cuda.cmake index 49f2cbc558..dd8bef0dee 100644 --- a/external/cuda.cmake +++ b/external/cuda.cmake @@ -16,10 +16,7 @@ enable_language(CUDA) set(CUDA_FOUND TRUE) set(TILEDARRAY_HAS_CUDA 1 CACHE BOOL "Whether TiledArray has CUDA support") - -if(ENABLE_CUDA_ERROR_CHECK) - set (TILEDARRAY_CHECK_CUDA_ERROR 1) -endif(ENABLE_CUDA_ERROR_CHECK) +set(TILEDARRAY_CHECK_CUDA_ERROR 1 CACHE BOOL "Whether TiledArray will check CUDA errors") # find CUDA toolkit # NB CUDAToolkit does NOT have COMPONENTS diff --git a/external/hip.cmake b/external/hip.cmake new file mode 100644 index 0000000000..53a28a4caa --- /dev/null +++ b/external/hip.cmake @@ -0,0 +1,36 @@ +# cmake 3.21 introduced HIP language support +cmake_minimum_required(VERSION 3.21.0) +set(CMAKE_HIP_STANDARD 17) +set(CMAKE_HIP_EXTENSIONS OFF) +set(CMAKE_HIP_STANDARD_REQUIRED ON) +# N.B. need relaxed constexpr for std::complex +# see https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#constexpr-functions%5B/url%5D: +if (DEFINED CMAKE_HIP_FLAGS) + set(CMAKE_HIP_FLAGS "--expt-relaxed-constexpr ${CMAKE_HIPE_FLAGS}") +else() + set(CMAKE_HIP_FLAGS "--expt-relaxed-constexpr") +endif() +enable_language(HIP) + +set(HIP_FOUND TRUE) +set(TILEDARRAY_HAS_HIP 1 CACHE BOOL "Whether TiledArray has HIP support") +set(TILEDARRAY_CHECK_HIP_ERROR 1 CACHE BOOL "Whether TiledArray will check HIP errors") + +# find HIP components +find_package(hipblas REQUIRED) + +foreach (library hipblas) + if (NOT TARGET roc::${library}) + message(FATAL_ERROR "roc::${library} not found") + endif() +endforeach() + +## +## Umpire +## +include(external/umpire.cmake) + +## +## LibreTT +## +include(external/librett.cmake)