Skip to content

Commit

Permalink
librett.cmake: support HIP
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Sep 18, 2023
1 parent 778f3c4 commit ccce1a2
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions external/librett.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ else()

message("** Will clone LibreTT from ${LIBRETT_URL}")

# need to change the separator of list to avoid issues with ExternalProject parsing
# set(CUDA_FLAGS "${CUDA_NVCC_FLAGS}")
# string(REPLACE ";" "::" CUDA_FLAGS "${CUDA_NVCC_FLAGS}")
#message(STATUS "CUDA_FLAGS: " "${CUDA_FLAGS}")

set(LIBRETT_CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_DIR}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
Expand All @@ -62,22 +57,37 @@ else()
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}
-DCMAKE_CUDA_STANDARD=${CMAKE_CUDA_STANDARD}
-DCMAKE_CUDA_EXTENSIONS=${CMAKE_CUDA_EXTENSIONS}
-DENABLE_UMPIRE=OFF
# N.B. ThreadSafeUMDynamicPool this no longer exists!!! Must teach LibreTT to take allocate/deallocate methods
# from the user code
-DLIBRETT_USES_THIS_UMPIRE_ALLOCATOR=ThreadSafeUMDynamicPool
-DCMAKE_PREFIX_PATH=${_UMPIRE_INSTALL_DIR}
-DENABLE_NO_ALIGNED_ALLOC=ON
-DCMAKE_CUDA_HOST_COMPILER=${CMAKE_CUDA_HOST_COMPILER}
-DCUDA_TOOLKIT_ROOT_DIR=${CUDAToolkit_ROOT}
-DENABLE_CUDA=ON
)
if (DEFINED CMAKE_CUDA_ARCHITECTURES)
list(APPEND LIBRETT_CMAKE_ARGS -DCMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES})
endif(DEFINED CMAKE_CUDA_ARCHITECTURES)
if (ENABLE_CUDA)
list(APPEND LIBRETT_CMAKE_ARGS
-DENABLE_CUDA=ON
-DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}
-DCMAKE_CUDA_STANDARD=${CMAKE_CUDA_STANDARD}
-DCMAKE_CUDA_EXTENSIONS=${CMAKE_CUDA_EXTENSIONS}
-DCMAKE_CUDA_HOST_COMPILER=${CMAKE_CUDA_HOST_COMPILER}
-DCUDA_TOOLKIT_ROOT_DIR=${CUDAToolkit_ROOT}
)
if (DEFINED CMAKE_CUDA_ARCHITECTURES)
list(APPEND LIBRETT_CMAKE_ARGS -DCMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES})
endif(DEFINED CMAKE_CUDA_ARCHITECTURES)
endif()
if (ENABLE_HIP)
list(APPEND LIBRETT_CMAKE_ARGS
-DENABLE_HIP=ON
-DCMAKE_HIP_COMPILER=${CMAKE_HIP_COMPILER}
-DCMAKE_HIP_STANDARD=${CMAKE_HIP_STANDARD}
-DCMAKE_HIP_EXTENSIONS=${CMAKE_HIP_EXTENSIONS}
)
if (DEFINED CMAKE_HIP_ARCHITECTURES)
list(APPEND LIBRETT_CMAKE_ARGS -DCMAKE_HIP_ARCHITECTURES=${CMAKE_HIP_ARCHITECTURES})
endif(DEFINED CMAKE_HIP_ARCHITECTURES)
endif()
if (CMAKE_TOOLCHAIN_FILE)
set(LIBRETT_CMAKE_ARGS "${LIBRETT_CMAKE_ARGS}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
Expand Down Expand Up @@ -147,9 +157,21 @@ set_target_properties(TiledArray_LIBRETT
"$<BUILD_INTERFACE:${EXTERNAL_SOURCE_DIR}/src>;$<INSTALL_INTERFACE:${_LIBRETT_INSTALL_DIR}/include>"
INTERFACE_LINK_LIBRARIES
"$<BUILD_INTERFACE:${LIBRETT_BUILD_BYPRODUCTS}>;$<INSTALL_INTERFACE:${_LIBRETT_INSTALL_DIR}/lib/librett.${LIBRETT_DEFAULT_LIBRARY_SUFFIX}>"
INTERFACE_COMPILE_DEFINITIONS
"LIBRETT_USES_CUDA=1"
)
if (ENABLE_CUDA)
set_target_properties(TiledArray_LIBRETT
PROPERTIES
INTERFACE_COMPILE_DEFINITIONS
"LIBRETT_USES_CUDA=1"
)
endif()
if (ENABLE_HIP)
set_target_properties(TiledArray_LIBRETT
PROPERTIES
INTERFACE_COMPILE_DEFINITIONS
"LIBRETT_USES_HIP=1"
)
endif()

install(TARGETS TiledArray_LIBRETT EXPORT tiledarray COMPONENT tiledarray)

Expand Down

0 comments on commit ccce1a2

Please sign in to comment.