Skip to content

Commit

Permalink
Merge pull request #269 from TESSEorg/ttg-device-support-master-coro-…
Browse files Browse the repository at this point in the history
…with-stream-tasks

coroutine-based device task support
  • Loading branch information
evaleev authored Feb 27, 2024
2 parents d366852 + f10a44e commit 1cf37d5
Show file tree
Hide file tree
Showing 110 changed files with 12,036 additions and 2,038 deletions.
40 changes: 13 additions & 27 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ jobs:
fail-fast: false
matrix:
build_type : [ Release, Debug ]
os : [ macos-latest, ubuntu-20.04 ]
os : [ macos-latest, ubuntu-22.04 ]
include:
- os: ubuntu-20.04
cxx: /usr/bin/g++-9
- os: ubuntu-22.04
cc: /usr/bin/gcc-12
cxx: /usr/bin/g++-12
- os: macos-latest
cc: clang
cxx: clang++

name: "${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
Expand All @@ -36,6 +38,7 @@ jobs:
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
-DTTG_EXAMPLES=ON
-DCMAKE_CXX_STANDARD=20
steps:
- uses: actions/checkout@v2
Expand All @@ -45,37 +48,19 @@ jobs:
run: brew install ninja gcc@10 boost eigen open-mpi bison ccache

- name: Install prerequisites Ubuntu packages
if: ${{ matrix.os == 'ubuntu-20.04' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
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++-9 liblapack-dev libboost-dev libboost-serialization-dev libeigen3-dev openmpi-bin libopenmpi-dev libtbb-dev ccache flex bison cmake
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
# We'll use this as our working directory for all subsequent commands
run: |
cmake -E make_directory ${{github.workspace}}/build
- name: Install doxygen for Release test
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
if [ "${{matrix.build_type}}" = "Release" ]; then
sudo apt-get -y install libclang1-9 libclang-cpp9 graphviz fonts-liberation
cd ${{github.workspace}}/build
# If we fail getting doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz from sourceforge,
# use EFV's gdrive mirror of 1.9.2 to work around the unreliable sourceforge
# the sharing link: https://drive.google.com/file/d/16GXpH4YOEUxGXQrXOKdAIibhdfzATY0d/view?usp=sharing
wget https://downloads.sourceforge.net/project/doxygen/rel-${DOXYGEN_VERSION}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz || wget -4 --no-check-certificate -O doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz "https://drive.google.com/uc?export=download&id=16GXpH4YOEUxGXQrXOKdAIibhdfzATY0d"
tar xzf ./doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
export DOXYGEN_DIR=${{github.workspace}}/build/doxygen-${DOXYGEN_VERSION}
${DOXYGEN_DIR}/bin/doxygen --version
# doxygen should be in PATH in subsequent steps
echo "${DOXYGEN_DIR}/bin" >> $GITHUB_PATH
fi
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
Expand All @@ -99,7 +84,8 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $BUILD_CONFIG
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $BUILD_CONFIG || (cat CMakeFiles/CMakeOutput.log && cat CMakeFiles/CMakeError.log)
- name: Build
working-directory: ${{github.workspace}}/build
Expand All @@ -124,7 +110,7 @@ jobs:
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake -S $GITHUB_WORKSPACE/doc/dox/dev/devsamp/main -B test_install_devsamp -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
cmake -S $GITHUB_WORKSPACE/doc/dox/dev/devsamp/main -B test_install_devsamp -DCMAKE_PREFIX_PATH=${{github.workspace}}/install || (cat test_install_devsamp/CMakeFiles/CMakeOutput.log && cat test_install_devsamp/CMakeFiles/CMakeError.log)
cmake --build test_install_devsamp
cmake -E make_directory test_install_userexamples
cat > test_install_userexamples/CMakeLists.txt <<EOF
Expand All @@ -136,11 +122,11 @@ jobs:
add_ttg_executable(iterative $GITHUB_WORKSPACE/doc/dox/user/examples/iterative.cc NOT_EXCLUDE_FROM_ALL)
add_ttg_executable(distributed $GITHUB_WORKSPACE/doc/dox/user/examples/distributed.cc NOT_EXCLUDE_FROM_ALL)
EOF
cmake -S test_install_userexamples -B test_install_userexamples/build -DCMAKE_PREFIX_PATH=${{github.workspace}}/install
cmake -S test_install_userexamples -B test_install_userexamples/build -DCMAKE_PREFIX_PATH=${{github.workspace}}/install || (cat test_install_userexamples/CMakeFiles/CMakeOutput.log && cat test_install_userexamples/CMakeFiles/CMakeError.log)
cmake --build test_install_userexamples/build
- name: Build+Deploy Dox
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.build_type == 'Release' && github.ref == 'refs/heads/master' }}
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.build_type == 'Release' && github.ref == 'refs/heads/master' }}
working-directory: ${{github.workspace}}/build
shell: bash
run: |
Expand Down
124 changes: 107 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required (VERSION 3.14) # supports FetchContent_MakeAvailable
cmake_policy(SET CMP0104 OLD)

# Set TTG version =======================================================

Expand Down Expand Up @@ -29,7 +30,14 @@ project(ttg
LANGUAGES CXX
HOMEPAGE_URL "https://tesseorg.github.io/ttg/")

set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD "20" CACHE STRING "The C++ standard")
elseif (${CMAKE_CXX_STANDARD} LESS 20)
message(FATAL_ERROR "TTG requires C++ compiler with C++20, but CMAKE_CXX_STANDARD is set to ${CMAKE_CXX_STANDARD}; bump up CMAKE_CXX_STANDARD to 20 or above")
endif()
if (NOT CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "The C++ standard extensions allowed?")
endif()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules/")
include(GNUInstallDirs)
Expand All @@ -45,21 +53,31 @@ 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_ENABLE_HIP "Whether to TTG will look for HIP" OFF)
option(TTG_ENABLE_LEVEL_ZERO "Whether to TTG will look for Intel oneAPI Level Zero" OFF)
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)
if (FORCE_COLORED_OUTPUT)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
add_compile_options ($<$<COMPILE_LANGUAGE:CXX,C>:-fdiagnostics-color=always>)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
add_compile_options ($<$<COMPILE_LANGUAGE:CXX,C>:-fcolor-diagnostics>)
endif ()
endif (FORCE_COLORED_OUTPUT)

if (TTG_ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif (TTG_ENABLE_ASAN)

set(TTG_HIP_PLATFORM "__HIP_PLATFORM_AMD__" CACHE STRING "Which platform to use when compiling HIP-related code (default: __HIP_PLATFORM_AMD__)")
##########################
#### prerequisites
##########################
Expand All @@ -75,9 +93,73 @@ endif (BUILD_TESTING)
#### optional prerequisites
###########################
# Boost
include(FindOrFetchBoost)
# Cereal
#include(FindOrFetchCereal)
include("${PROJECT_SOURCE_DIR}/cmake/modules/FindOrFetchBoost.cmake")
# C++ coroutines
find_package(CXXStdCoroutine MODULE REQUIRED COMPONENTS Final Experimental)


##########################
#### CUDA: must come before PaRSEC
##########################
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")

find_package(CUDAToolkit)
if (TARGET CUDA::cudart)
set(TTG_HAVE_CUDART True CACHE BOOL "TTG supports execution on CUDA devices")
endif()
endif(TTG_ENABLE_CUDA)

if (TTG_ENABLE_HIP)
# HIP LANGUAGE introduced in 3.21
cmake_minimum_required(VERSION 3.21)
include(CheckLanguage)
check_language(HIP)
if(CMAKE_HIP_COMPILER)
enable_language(HIP)
endif(CMAKE_HIP_COMPILER)
set(TTG_HAVE_HIP ${CMAKE_HIP_COMPILER} CACHE BOOL "True if TTG supports compiling .hip files")

find_package(hipblas)
if (TARGET roc::hipblas)
set(TTG_HAVE_HIPBLAS True CACHE BOOL "TTG detected support for hipBLAS")
endif()

find_package(hipsolver)
if (TARGET roc::hipsolver)
set(TTG_HAVE_HIPSOLVER True CACHE BOOL "TTG detected support for hipSolver")
endif()
add_compile_definitions(${TTG_HIP_PLATFORM})
endif(TTG_ENABLE_HIP)

if (TTG_ENABLE_LEVEL_ZERO)
find_package(level-zero)
set(TTG_HAVE_LEVEL_ZERO ${LEVEL_ZERO_FOUND} CACHE BOOL "True if TTG provide support for Intel Level Zero")
if(TTG_HAVE_LEVEL_ZERO)
include_directories("${LEVEL_ZERO_INCLUDE_DIR}/level_zero/")
find_package(DPCPP)
if(DPCPP_EXECUTABLE)
set(TTG_HAVE_DPCPP TRUE CACHE BOOL "True if TTG knows how to compile DPCPP code")
message(STATUS "Found Intel level-zero ${LEVEL_ZERO_VERSION} in -I${LEVEL_ZERO_INCLUDE_DIR} / -L${LEVEL_ZERO_LIBRARY_DIR}")
message(STATUS "Found dpcpp in ${DPCPP_EXECUTABLE}")

find_package(MKL)
else(DPCPP_EXECUTABLE)
set(TTG_HAVE_DPCPP FALSE CACHE BOOL "True if TTG knows how to compile DPCPP code")
endif(DPCPP_EXECUTABLE)
endif(TTG_HAVE_LEVEL_ZERO)
endif(TTG_ENABLE_LEVEL_ZERO)

set(_ttg_have_device FALSE)
if (TTG_HAVE_CUDA OR TTG_HAVE_HIP OR TTG_HAVE_LEVEL_ZERO)
set(_ttg_have_device TRUE)
endif()
set(TTG_HAVE_DEVICE ${_ttg_have_device} CACHE BOOL "True if TTG has support for any device programming model")

##########################
#### prerequisite runtimes
Expand All @@ -93,21 +175,28 @@ if (TARGET MADworld)
message(STATUS "MADNESS_FOUND=1")
endif(TARGET MADworld)

####################################################
#### Check for MPIX_Query_[cuda|rocm]_support
#### Open MPI provides mpi-ext.h for such extensions
#### so check for that first.
####################################################
find_package(MPI)
set(TTG_HAVE_MPI MPI_FOUND)
if (MPI_FOUND)
include(CheckIncludeFiles)
set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_DIRS})
check_include_files("mpi-ext.h" TTG_HAVE_MPIEXT)
else(MPI_FOUND)
set(TTG_HAVE_MPIEXT $<BOOL:false>)
endif(MPI_FOUND)

##########################
#### Examples
##########################
# N.B. discover last so that we do not affect core dependencies
if (TTG_EXAMPLES)
# sparse tensor algorithms need Eigen
find_package(Eigen3)
message (STATUS "EIGEN3_FOUND=${EIGEN3_FOUND}")
if (EIGEN3_FOUND)
add_library(eigen3 INTERFACE IMPORTED)
set_property(TARGET eigen3 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIR})
endif (EIGEN3_FOUND)
# BTAS brings in linear algebra (BLAS++/LAPACK++)
include(FindOrFetchBTAS)
# TiledArray brings in BTAS AND linear algebra (BLAS++/LAPACK++)
include(FindOrFetchTiledArray)
# OpenMP may also be used by some examples
find_package(OpenMP COMPONENTS CXX)
# std::execution may also be used by some examples
Expand Down Expand Up @@ -154,6 +243,7 @@ configure_package_config_file(cmake/ttg-config.cmake.in
install(FILES
"${PROJECT_SOURCE_DIR}/cmake/modules/AddTTGExecutable.cmake"
"${PROJECT_SOURCE_DIR}/cmake/modules/AddTTGTestExecutable.cmake"
"${PROJECT_SOURCE_DIR}/cmake/modules/FindCXXStdCoroutine.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}/modules"
COMPONENT ttg-config)

Expand Down
Loading

0 comments on commit 1cf37d5

Please sign in to comment.