Skip to content

Commit

Permalink
[cmake] TTG_ENABLE_CUDA to control whether PaRSEC etc. try to discove…
Browse files Browse the repository at this point in the history
…r CUDA
  • Loading branch information
evaleev committed Jul 17, 2023
1 parent de13328 commit c2cae26
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ set(CMAKE_INSTALL_CMAKEDIR "lib/cmake/ttg"
#### user-defined configuration options
########################################
option(TTG_PARSEC_USE_BOOST_SERIALIZATION "Whether to select Boost serialization methods in PaRSEC backend" ON)
option(TTG_ENABLE_CUDA "Whether to TTG will look for CUDA" OFF)
option(TTG_EXAMPLES "Whether to build examples" OFF)

option(TTG_FETCH_BOOST "Whether to fetch+build Boost, if missing" OFF)
Expand Down Expand Up @@ -91,17 +92,19 @@ find_package(CXXStdCoroutine MODULE REQUIRED COMPONENTS Final Experimental)
##########################
#### CUDA: must come before PaRSEC
##########################
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
if (TTG_ENABLE_CUDA)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
endif(CMAKE_CUDA_COMPILER)
set(TTG_HAVE_CUDA ${CMAKE_CUDA_COMPILER} CACHE BOOL "True if TTG supports compiling .cu files")
endif(CMAKE_CUDA_COMPILER)
set(TTG_HAVE_CUDA ${CMAKE_CUDA_COMPILER} CACHE BOOL "True if TTG supports compiling .cu files")

find_package(CUDAToolkit)
if (TARGET CUDA::cudart)
set(TTG_HAVE_CUDART True CACHE BOOL "True support for CUDART was found.")
endif(TARGET CUDA::cudart)
find_package(CUDAToolkit)
if (TARGET CUDA::cudart)
set(TTG_HAVE_CUDART True CACHE BOOL "TTG supports execution on CUDA devices")
endif()
endif()

##########################
#### prerequisite runtimes
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindOrFetchPARSEC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (NOT TARGET PaRSEC::parsec)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(PARSEC_WITH_DEVEL_HEADERS ON CACHE BOOL "Install PaRSEC headers")
set(BUILD_TOOLS ON CACHE BOOL "Do not build PaRSEC tools")
set(PARSEC_GPU_WITH_CUDA ${TTG_ENABLE_CUDA} CACHE BOOL "Enable CUDA support in PaRSEC runtime?")

FetchContent_Declare(
PARSEC
Expand Down
4 changes: 1 addition & 3 deletions cmake/modules/FindOrFetchTiledArray.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ if (TARGET tiledarray)
else (TARGET tiledarray)

# enable CUDA if TTG has it
if (TTG_HAVE_CUDA)
set(ENABLE_CUDA ON CACHE BOOL "Enable CUDA")
endif()
set(ENABLE_CUDA ${TTG_HAVE_CUDA} CACHE BOOL "Enable CUDA")

# update CMake cache for TA
if (DEFINED MADNESS_CMAKE_EXTRA_ARGS)
Expand Down
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ if (TARGET tiledarray)
# block-sparse needs BTAS ... it's always provided by TA
# since only need to use matrices, limit BTAS_TARGET_MAX_INDEX_RANK to 2
add_ttg_executable(bspmm spmm/spmm.cc LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS Boost::boost COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2)
if (TARGET CUDA::cublas)
if (TTG_HAVE_CUDA)
add_ttg_executable(bspmm-cuda spmm/spmm_cuda.cc
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS Boost::boost CUDA::cublas
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2
RUNTIMES "parsec")
endif (TARGET CUDA::cublas)
endif()
endif()

if (TARGET MADworld)
Expand Down
4 changes: 2 additions & 2 deletions ttg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ if (TARGET std::coroutine)
${CMAKE_CURRENT_SOURCE_DIR}/ttg/util/coroutine.h
)
endif ()
if (TARGET CUDA::cudart)
if (TTG_HAVE_CUDA)
list(APPEND ttg-sources
${CMAKE_CURRENT_SOURCE_DIR}/ttg/device/cublas_helper.cpp
)
list(APPEND ttg-deps CUDA::cudart CUDA::cublas)
endif (TARGET CUDA::cudart)
endif ()

set(ttg-public-headers ${ttg-headers};${ttg-impl-headers};${ttg-base-headers};${ttg-util-headers};${ttg_device_headers})
if (NOT TTG_IGNORE_BUNDLED_EXTERNALS)
Expand Down

0 comments on commit c2cae26

Please sign in to comment.