Skip to content

Commit

Permalink
Merge branch 'ttg-device-support-master-coro-with-stream-tasks' of gi…
Browse files Browse the repository at this point in the history
…thub.com:devreal/ttg into ttg-device-support-master-coro-with-stream-tasks
  • Loading branch information
devreal committed Feb 2, 2024
2 parents 4416f3b + 3dad2c1 commit 8fd7be9
Show file tree
Hide file tree
Showing 12 changed files with 491 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
sudo apt-get update
sudo apt-get -y install ninja-build g++-12 liblapack-dev libboost-dev libboost-serialization-dev libeigen3-dev openmpi-bin libopenmpi-dev libtbb-dev ccache flex bison cmake doxygen
sudo apt-get -y install ninja-build g++-12 liblapack-dev libboost-dev libboost-serialization-dev libboost-random-dev libeigen3-dev openmpi-bin libopenmpi-dev libtbb-dev ccache flex bison cmake doxygen
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ option(TTG_EXAMPLES "Whether to build examples" OFF)
option(TTG_ENABLE_ASAN "Whether to enable address sanitizer" OFF)

option(TTG_FETCH_BOOST "Whether to fetch+build Boost, if missing" OFF)
option(TTG_IGNORE_BUNDLED_EXTERNALS "Whether to skip installation and use of bundled external depenedencies (Boost.CallableTraits)" OFF)
option(TTG_IGNORE_BUNDLED_EXTERNALS "Whether to skip installation and use of bundled external dependencies (Boost.CallableTraits)" OFF)
option(TTG_ENABLE_TRACE "Whether to enable ttg::trace() output" OFF)
# See https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE)
Expand Down Expand Up @@ -91,7 +91,7 @@ endif (BUILD_TESTING)
#### optional prerequisites
###########################
# Boost
include(FindOrFetchBoost)
include("${PROJECT_SOURCE_DIR}/cmake/modules/FindOrFetchBoost.cmake")
# Cereal
#include(FindOrFetchCereal)
# C++ coroutines
Expand Down
7 changes: 4 additions & 3 deletions cmake/modules/ExternalDependenciesVersions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

# need Boost.CallableTraits (header only, part of Boost 1.66 released in Dec 2017) for wrap.h to work
set(TTG_TRACKED_BOOST_VERSION 1.66)
set(TTG_TRACKED_VG_CMAKE_KIT_TAG 7ea2d4d3f8854b9e417f297fd74d6fc49aa13fd5) # used to provide "real" FindOrFetchBoost
set(TTG_TRACKED_CATCH2_VERSION 3.5.0)
set(TTG_TRACKED_CEREAL_VERSION 1.3.0)
set(TTG_TRACKED_MADNESS_TAG cb195817d7807c4aead10ba200cd20649036cbae)
set(TTG_TRACKED_MADNESS_TAG 2eb3bcf0138127ee2dbc651f1aabd3e9b0def4e3)
#set(TTG_TRACKED_PARSEC_TAG 25d1931e863b6741e453112d2117d85ad32e7fba)
set(TTG_TRACKED_PARSEC_TAG 8ed7cdf02ad607051c130a6deeb8f12c84f2e4d3)
set(TTG_TRACKED_BTAS_TAG a02be0d29fb4a788ecef43de711dcd6d6f1cb6b8)
set(TTG_TRACKED_TILEDARRAY_TAG f0115e9e4a3f988224afbfb3c241e92171e916b8)
set(TTG_TRACKED_BTAS_TAG 4e8f5233aa7881dccdfcc37ce07128833926d3c2)
set(TTG_TRACKED_TILEDARRAY_TAG 493c109379a1b64ddd5ef59f7e33b95633b68d73)
108 changes: 63 additions & 45 deletions cmake/modules/FindOrFetchBoost.cmake
Original file line number Diff line number Diff line change
@@ -1,50 +1,68 @@
if (NOT TARGET Boost::boost)
find_package(Boost ${TTG_TRACKED_BOOST_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS serialization)
endif(NOT TARGET Boost::boost)

if (TARGET Boost::boost)
set(_msg "Found Boost at ${Boost_CONFIG}")
if (TARGET Boost::serialization)
list(APPEND _msg " includes Boost::serialization")
endif(TARGET Boost::serialization)
message(STATUS "${_msg}")

# Boost::* targets by default are not GLOBAL, so to allow users of TTG to safely use them we need to make them global
# more discussion here: https://gitlab.kitware.com/cmake/cmake/-/issues/17256
foreach(tgt boost;headers;${Boost_BTAS_DEPS_LIBRARIES})
if (TARGET Boost::${tgt})
get_target_property(_boost_tgt_${tgt}_is_imported_global Boost::${tgt} IMPORTED_GLOBAL)
if (NOT _boost_tgt_${tgt}_is_imported_global)
set_target_properties(Boost::${tgt} PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
unset(_boost_tgt_${tgt}_is_imported_global)
endif()
endforeach()

elseif (TTG_FETCH_BOOST)
# Boost can be discovered by every (sub)package but only the top package can *build* it ...
# in either case must declare the components used by TTG
set(required_components
headers
callable_traits
)
set(optional_components
)
if (TTG_PARSEC_USE_BOOST_SERIALIZATION)
list(APPEND optional_components
serialization
iostreams
)
endif()

FetchContent_Declare(
CMAKEBOOST
GIT_REPOSITORY https://github.com/Orphis/boost-cmake
)
FetchContent_MakeAvailable(CMAKEBOOST)
FetchContent_GetProperties(CMAKEBOOST
SOURCE_DIR CMAKEBOOST_SOURCE_DIR
BINARY_DIR CMAKEBOOST_BINARY_DIR
)
# if not allowed to fetch Boost make all Boost optional
if (NOT DEFINED Boost_FETCH_IF_MISSING AND TTG_FETCH_BOOST)
set(Boost_FETCH_IF_MISSING 1)
endif()
if (NOT Boost_FETCH_IF_MISSING)
foreach(__component IN LISTS required_components)
list(APPEND optional_components
${__component}
)
endforeach()
set(required_components )
endif()

# current boost-cmake/master does not install boost correctly, so warn that installed TTG will not be usable
# boost-cmake/install_rules https://github.com/Orphis/boost-cmake/pull/45 is supposed to fix it but is inactive
message(WARNING "Building Boost from source makes TTG unusable from the install location! Install Boost using package manager or manually and reconfigure/reinstall TTG to fix this")
if (DEFINED Boost_REQUIRED_COMPONENTS)
list(APPEND Boost_REQUIRED_COMPONENTS
${required_components})
list(REMOVE_DUPLICATES Boost_REQUIRED_COMPONENTS)
else()
set(Boost_REQUIRED_COMPONENTS "${required_components}" CACHE STRING "Components of Boost to discovered or built")
endif()
if (DEFINED Boost_OPTIONAL_COMPONENTS)
list(APPEND Boost_OPTIONAL_COMPONENTS
${optional_components}
)
list(REMOVE_DUPLICATES Boost_OPTIONAL_COMPONENTS)
else()
set(Boost_OPTIONAL_COMPONENTS "${optional_components}" CACHE STRING "Optional components of Boost to discovered or built")
endif()

if (TARGET Boost::serialization AND TARGET Boost_serialization)
install(TARGETS Boost_serialization EXPORT boost)
export(EXPORT boost
FILE "${PROJECT_BINARY_DIR}/boost-targets.cmake")
install(EXPORT boost
FILE "boost-targets.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
COMPONENT boost-libs)
endif()
# Bring ValeevGroup cmake toolkit, if not yet available
if (NOT DEFINED vg_cmake_kit_SOURCE_DIR)
include(FetchContent)
if (DEFINED PROJECT_BINARY_DIR)
set(VG_CMAKE_KIT_PREFIX_DIR PROJECT_BINARY_DIR)
else ()
set(VG_CMAKE_KIT_PREFIX_DIR CMAKE_CURRENT_BINARY_DIR)
endif()
FetchContent_Declare(
vg_cmake_kit
QUIET
GIT_REPOSITORY https://github.com/ValeevGroup/kit-cmake.git
GIT_TAG ${TTG_TRACKED_VG_CMAKE_KIT_TAG}
SOURCE_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg
BINARY_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-build
SUBBUILD_DIR ${${VG_CMAKE_KIT_PREFIX_DIR}}/cmake/vg-subbuild
)
FetchContent_MakeAvailable(vg_cmake_kit)
endif()
include(${vg_cmake_kit_SOURCE_DIR}/modules/FindOrFetchBoost.cmake)

if (TARGET Boost::headers)
set(TTG_HAS_BOOST 1)
endif()
2 changes: 1 addition & 1 deletion cmake/modules/FindOrFetchMADNESS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (NOT TARGET MADworld)
set(MADNESS_TASK_BACKEND PaRSEC CACHE STRING "The task backend to use for MADNESS tasks")
FetchContent_Declare(
MADNESS
GIT_REPOSITORY https://github.com/therault/madness.git
GIT_REPOSITORY https://github.com/m-a-d-n-e-s-s/madness.git
GIT_TAG ${TTG_TRACKED_MADNESS_TAG}
)
FetchContent_MakeAvailable(MADNESS)
Expand Down
22 changes: 5 additions & 17 deletions cmake/ttg-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ set(TTG_EXT_VERSION "@TTG_EXT_VERSION@")

set(PaRSEC_CONFIG "@PaRSEC_CONFIG@")
set(MADNESS_CONFIG "@MADNESS_CONFIG@")
set(Boost_CONFIG "@Boost_CONFIG@")
set(CXX_COROUTINE_COMPONENT "@CXX_COROUTINE_COMPONENT@")

set(TTG_TRACKED_BOOST_VERSION "@TTG_TRACKED_BOOST_VERSION@")

set(TTG_HAS_BOOST @TTG_HAS_BOOST@)
set(TTG_IGNORE_BUNDLED_EXTERNALS @TTG_IGNORE_BUNDLED_EXTERNALS@)

# make TTG CMake modules discoverable + load AddTTGExecutable by default
Expand All @@ -19,6 +18,10 @@ include(AddTTGExecutable)

@PACKAGE_INIT@

if (TTG_HAS_BOOST)
@Boost_CONFIG_FILE_CONTENTS@
endif(TTG_HAS_BOOST)

if (NOT TARGET MADworld AND MADNESS_CONFIG)
get_filename_component(MADNESS_CONFIG_DIR "${MADNESS_CONFIG}" DIRECTORY)
find_package(MADNESS 0.10.1 CONFIG QUIET REQUIRED COMPONENTS world PATHS "${MADNESS_CONFIG_DIR}" NO_DEFAULT_PATH)
Expand All @@ -29,12 +32,6 @@ if (NOT TARGET PaRSEC::parsec AND PaRSEC_CONFIG)
find_package(PaRSEC CONFIG QUIET REQUIRED COMPONENTS parsec PATHS "${PaRSEC_CONFIG_DIR}" NO_DEFAULT_PATH)
endif()

# if Boost was discovered and used at TTG configure time discover Boost at the same path
if (NOT TARGET Boost::boost AND Boost_CONFIG)
get_filename_component(Boost_CONFIG_DIR "${Boost_CONFIG}" DIRECTORY)
find_package(Boost ${TTG_TRACKED_BOOST_VERSION} CONFIG QUIET REQUIRED OPTIONAL_COMPONENTS serialization PATHS "${Boost_CONFIG_DIR}" NO_DEFAULT_PATH)
endif()

# if C++ coroutines were used discover same version of them
if (NOT TARGET std::coroutine AND CXX_COROUTINE_COMPONENT)
find_package(CXXStdCoroutine MODULE QUIET REQUIRED COMPONENTS "${CXX_COROUTINE_COMPONENT}")
Expand All @@ -48,13 +45,4 @@ if(NOT TARGET ttg)
endif()
endif()

# if don't have Boost, use bundled Boost.CallableTraits
if (NOT TARGET Boost::boost)
if (TTG_IGNORE_BUNDLED_EXTERNALS)
find_package(Boost ${TTG_TRACKED_BOOST_VERSION} QUIET REQUIRED)
else()
target_compile_definitions(ttg INTERFACE TTG_USE_BUNDLED_BOOST_CALLABLE_TRAITS=1)
endif()
endif()

set(TTG_FOUND TRUE)
8 changes: 4 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (TARGET tiledarray)
add_ttg_executable(spmm spmm/spmm.cc LINK_LIBRARIES TiledArray_Eigen)
# 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)
add_ttg_executable(bspmm spmm/spmm.cc LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2)

add_ttg_executable(testing_dpotrf potrf/testing_dpotrf.cc LINK_LIBRARIES tiledarray lapackpp)
add_ttg_executable(testing_dtrtri potrf/testing_dtrtri.cc LINK_LIBRARIES tiledarray lapackpp)
Expand All @@ -19,7 +19,7 @@ if (TARGET tiledarray)

if (TARGET CUDA::cublas)
add_ttg_executable(bspmm-cuda spmm/spmm_cuda.cc
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS Boost::boost CUDA::cublas
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS CUDA::cublas
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2
RUNTIMES "parsec")

Expand All @@ -31,7 +31,7 @@ if (TARGET tiledarray)
endif(TARGET CUDA::cusolver)
elseif (TARGET roc::hipblas)
add_ttg_executable(bspmm-hip spmm/spmm_cuda.cc
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS Boost::boost roc::hipblas
LINK_LIBRARIES tiledarray TiledArray_Eigen roc::hipblas
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2
RUNTIMES "parsec")
if (TARGET roc::hipsolver)
Expand All @@ -42,7 +42,7 @@ if (TARGET tiledarray)
endif(TARGET roc::hipsolver)
elseif (TARGET MKL::MKL_DPCPP)
add_ttg_executable(bspmm-lz spmm/spmm_cuda.cc
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS Boost::boost MKL::MKL_DPCPP level_zero::ze_loader m
LINK_LIBRARIES tiledarray TiledArray_Eigen BTAS MKL::MKL_DPCPP level_zero::ze_loader m
COMPILE_DEFINITIONS BLOCK_SPARSE_GEMM=1;BTAS_TARGET_MAX_INDEX_RANK=2
RUNTIMES "parsec")
endif()
Expand Down
Loading

0 comments on commit 8fd7be9

Please sign in to comment.