Skip to content

Commit

Permalink
Merge pull request #238 from therault/potrf-composition2
Browse files Browse the repository at this point in the history
TTG composition, example of POINV, and a few fixes to parsec profiling
  • Loading branch information
devreal authored Oct 21, 2022
2 parents 93043ed + bc6abdd commit 22f0b82
Show file tree
Hide file tree
Showing 62 changed files with 4,677 additions and 1,938 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
if [ "${{matrix.build_type}}" = "Release" ]; then
sudo apt-get -y install libclang1-9 libclang-cpp9 graphviz fonts-liberation
cd ${{github.workspace}}/build
# wget https://downloads.sourceforge.net/project/doxygen/rel-${DOXYGEN_VERSION}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
wget https://downloads.sourceforge.net/project/doxygen/rel-${DOXYGEN_VERSION}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
# using 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 -4 --no-check-certificate -O doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz "https://drive.google.com/uc?export=download&id=16GXpH4YOEUxGXQrXOKdAIibhdfzATY0d"
Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ cmake_minimum_required (VERSION 3.14) # supports FetchContent_MakeAvailable
# Set TTG version =======================================================

# see https://semver.org/
set(TTG_MAJOR_VERSION 0)
set(TTG_MINOR_VERSION 1)
set(TTG_MAJOR_VERSION 1)
set(TTG_MINOR_VERSION 0)
set(TTG_MICRO_VERSION 0)
set(TTG_PRERELEASE_ID )
set(TTG_PRERELEASE_ID alpha)

set(TTG_VERSION "${TTG_MAJOR_VERSION}.${TTG_MINOR_VERSION}.${TTG_MICRO_VERSION}")
if (TTG_PRERELEASE_ID)
Expand All @@ -15,10 +15,17 @@ else(TTG_PRERELEASE_ID)
set(TTG_EXT_VERSION "${TTG_VERSION}")
endif(TTG_PRERELEASE_ID)

# CMake defaults to address key pain points =========================

# safety net for dev workflow: accidental install will not affect FindOrFetch*
if (NOT DEFINED CACHE{CMAKE_FIND_NO_INSTALL_PREFIX})
set(CMAKE_FIND_NO_INSTALL_PREFIX ON CACHE BOOL "Whether find_* commands will search CMAKE_INSTALL_PREFIX and CMAKE_STAGING_PREFIX; see https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_NO_INSTALL_PREFIX.html#variable:CMAKE_FIND_NO_INSTALL_PREFIX")
endif()

# Declare TTG =======================================================
project(ttg
VERSION ${TTG_VERSION}
DESCRIPTION "Template Task Graph: flowgraph programming model"
DESCRIPTION "Template Task Graph: flowgraph programming model for distributed-memory computing"
LANGUAGES CXX
HOMEPAGE_URL "https://tesseorg.github.io/ttg/")

Expand Down
1 change: 1 addition & 0 deletions cmake/modules/AddTTGLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ macro(add_ttg_library)

target_include_directories(${_library} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # look in binary dir also for files preprocessed by configure_file
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

Expand Down
6 changes: 3 additions & 3 deletions cmake/modules/ExternalDependenciesVersions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
set(TTG_TRACKED_BOOST_VERSION 1.66)
set(TTG_TRACKED_CATCH2_VERSION 2.13.1)
set(TTG_TRACKED_CEREAL_VERSION 1.3.0)
set(TTG_TRACKED_MADNESS_TAG 977747a327b9d1281af8e7f2a7b6f69cb5945776)
set(TTG_TRACKED_PARSEC_TAG 13f3d84982ec7a62477fb380aae97aa4552b2ac1)
set(TTG_TRACKED_BTAS_TAG 1dc111d3efd6d6a4ba6f3b8cbc239315d0392121)
set(TTG_TRACKED_MADNESS_TAG 687ac4f5308c82de04ea0f803f57417fa92713d5)
set(TTG_TRACKED_PARSEC_TAG cb9322046c1f856fbca5804a9f96b83bbe2e676b)
set(TTG_TRACKED_BTAS_TAG ab866a760b72ff23053266bf46b87f19d3df44b7)
13 changes: 13 additions & 0 deletions cmake/modules/FindOrFetchBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ if (TARGET Boost::boost)
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)

FetchContent_Declare(
Expand Down
83 changes: 83 additions & 0 deletions cmake/modules/GetGitMetadata.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# SPDX-FileCopyrightText: 2022 Eduard Valeyev <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
#

#
# vgkit_cmake_git_revision() defines variable ${PROJECT_NAME_UPPER}_GIT_REVISION,
# where ${PROJECT_NAME_UPPER} is the upper-case version of ${PROJECT_NAME}, to
# the "long-form" GIT revision produced by `git rev-parse -q HEAD` command.
# N.B. If the variable is already defined will print a warning message but not change the value of
# ${PROJECT_NAME_UPPER}_GIT_REVISION
#
macro(vgkit_cmake_git_revision)
string(TOUPPER "${PROJECT_NAME}_GIT_REVISION" vgkit_cmake_git_revision_result)
if (DEFINED ${vgkit_cmake_git_revision_result})
message(WARNING "vgkit_cmake_git_revision() called for project ${PROJECT_NAME} but the result variable ${vgkit_cmake_git_revision_result} already defined; will not change its value")
else()
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
find_package(Git REQUIRED)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse -q HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE vgkit_cmake_git_revision_errcod
OUTPUT_VARIABLE ${vgkit_cmake_git_revision_result}
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT vgkit_cmake_git_revision_errcod EQUAL 0)
set(${vgkit_cmake_git_revision_result} "unknown")
endif()
unset(vgkit_cmake_git_revision_errcod)
else()
set(${vgkit_cmake_git_revision_result} "unknown")
endif()
else()
set(${vgkit_cmake_git_revision_result} "unknown")
endif()
endif()
unset(vgkit_cmake_git_revision_result)
endmacro()

#
# vgkit_cmake_git_description() defines variable ${PROJECT_NAME_UPPER}_GIT_DESCRIPTION,
# where ${PROJECT_NAME_UPPER} is the upper-case version of ${PROJECT_NAME}, to
# the human-readable form produced by `git describe --dirty` command.
# If the variable is already defined will print a warning message but not change the value of
# ${PROJECT_NAME_UPPER}_GIT_DESCRIPTION
#
macro(vgkit_cmake_git_description)
string(TOUPPER "${PROJECT_NAME}_GIT_DESCRIPTION" vgkit_cmake_git_description_result)
if (DEFINED ${vgkit_cmake_git_description_result})
message(WARNING "vgkit_cmake_git_description() called for project ${PROJECT_NAME} but the result variable ${vgkit_cmake_git_description_result} already defined; will not change its value")
else()
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
find_package(Git REQUIRED)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --dirty
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE vgkit_cmake_git_description_errcod
OUTPUT_VARIABLE ${vgkit_cmake_git_description_result}
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT vgkit_cmake_git_description_errcod EQUAL 0)
set(${vgkit_cmake_git_description_errcod} "unknown")
endif()
unset(vgkit_cmake_git_description_errcod)
else()
set(${vgkit_cmake_git_description_errcod} "unknown")
endif()
else()
set(${vgkit_cmake_git_description_errcod} "unknown")
endif()
endif()
unset(vgkit_cmake_git_description_errcod)
endmacro()

#
# vgkit_cmake_git_metadata() invokes vgkit_cmake_git_revision and vgkit_cmake_git_description
#
macro(vgkit_cmake_git_metadata)
vgkit_cmake_git_revision()
vgkit_cmake_git_description()
endmacro()
7 changes: 4 additions & 3 deletions doc/dox/user/examples/distributed.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <ttg.h>
#include <ttg/serialization/std/pair.h>
#include <ttg/util/hash/std/pair.h>

const double threshold = 100.0;
using Key2 = std::pair<int, int>;
Expand Down Expand Up @@ -35,7 +36,7 @@ int main(int argc, char **argv) {
ttg::Edge<int, double> C_A("C(k)->A(k)");

auto wc(ttg::make_tt(c, ttg::edges(B_C), ttg::edges(C_A), "C", {"From B"}, {"to A"}));

/**! \link TT::set_input_reducer() */wc->set_input_reducer/**! \endlink */<0>([](double &a, const double &b) { a += b; });

auto wa(ttg::make_tt([&](const int &k, const double &input, std::tuple<ttg::Out<Key2, double>> &out) {
Expand Down Expand Up @@ -67,8 +68,8 @@ int main(int argc, char **argv) {
/**
* \example distributed.cc
* This is the iterative diamond DAG with variable number of inputs using the reducing
* terminals of Template Task Graph, adapted to run in distributed: iteratively, a reducing
* diamond of data-dependent width is run, until the amount of data gathered at the bottom
* terminals of Template Task Graph, adapted to run in distributed: iteratively, a reducing
* diamond of data-dependent width is run, until the amount of data gathered at the bottom
* of the diamond exceeds a given threshold. First and last tasks of each diamond are run
* on rank 0, while the tasks inside the diamond are distributed between the ranks in a
* round-robin fashion.
Expand Down
17 changes: 8 additions & 9 deletions doc/dox/user/examples/iterative.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <ttg.h>
#include <ttg/serialization/std/pair.h>
#include <ttg/util/hash/std/pair.h>

const double threshold = 100.0;
using Key2 = std::pair<int, int>;
Expand All @@ -13,26 +14,23 @@ namespace std {

static void a(const int &k, const double &input, std::tuple<ttg::Out<Key2, double>> &out) {
ttg::print("Called task A(", k, ")");
/**! \link ttg::send() */ ttg::send/**! \endlink */<0>(Key2{k, 0}, 1.0 + input, out);
/**! \link ttg::send() */ ttg::send/**! \endlink */<0>(Key2{k, 1}, 2.0 + input, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(Key2{k, 0}, 1.0 + input, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(Key2{k, 1}, 2.0 + input, out);
}

static void b(const Key2 &key, const double &input, std::tuple<ttg::Out<int, double>, ttg::Out<int, double>> &out) {
ttg::print("Called task B(", key, ") with input data ", input);
if (std::get<1>(key) == 0)
/**! \link ttg::send() */
ttg::send/**! \endlink */<0>(std::get<0>(key), input + 1.0, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(std::get<0>(key), input + 1.0, out);
else
/**! \link ttg::send() */
ttg::send/**! \endlink */<1>(std::get<0>(key), input + 1.0, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<1>(std::get<0>(key), input + 1.0, out);
}

static void c(const int &k, const double &b0, const double &b1, std::tuple<ttg::Out<int, double>> &out) {
ttg::print("Called task C(", k, ") with inputs ", b0, " from B(", k, " 0) and ", b1, " from B(", k, " 1)");
if (b0 + b1 < threshold) {
ttg::print(" ", b0, "+", b1, "<", threshold, " so continuing to iterate");
/**! \link ttg::send() */
ttg::send/**! \endlink */<0>(k + 1, b0 + b1, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(k + 1, b0 + b1, out);
} else {
ttg::print(" ", b0, "+", b1, ">=", threshold, " so stopping the iterations");
}
Expand All @@ -47,7 +45,8 @@ int main(int argc, char **argv) {
ttg::Edge<int, double> C_A("C(k)->A(k)");

auto wa(ttg::make_tt(a, ttg::edges(C_A), ttg::edges(A_B), "A", {"from C"}, {"to B"}));
auto wb(ttg::make_tt(b, ttg::edges(A_B), ttg::edges(B_C0, B_C1), "B", {"from A"}, {"to 1st input of C", "to 2nd input of C"}));
auto wb(ttg::make_tt(b, ttg::edges(A_B), ttg::edges(B_C0, B_C1), "B", {"from A"},
{"to 1st input of C", "to 2nd input of C"}));
auto wc(ttg::make_tt(c, ttg::edges(B_C0, B_C1), ttg::edges(C_A), "C", {"From B", "From B"}, {"to A"}));

ttg::make_graph_executable(wa);
Expand Down
31 changes: 17 additions & 14 deletions doc/dox/user/examples/reducing.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <ttg.h>
#include <ttg/serialization/std/pair.h>
#include <ttg/util/hash/std/pair.h>

const double threshold = 100.0;
using Key2 = std::pair<int, int>;
Expand All @@ -13,15 +14,14 @@ namespace std {

static void b(const Key2 &key, const double &input, std::tuple<ttg::Out<int, double>> &out) {
ttg::print("Called task B(", key, ") with input data ", input);
/**! \link ttg::send() */ ttg::send/**! \endlink */<0>(std::get<0>(key), input + 1.0, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(std::get<0>(key), input + 1.0, out);
}

static void c(const int &k, const double &sum, std::tuple<ttg::Out<int, double>> &out) {
ttg::print("Called task C(", k, ") with input ", sum);
if (sum < threshold) {
ttg::print(" ", sum, "<", threshold, " so continuing to iterate");
/**! \link ttg::send() */
ttg::send/**! \endlink */<0>(k + 1, sum, out);
/**! \link ttg::send() */ ttg::send /**! \endlink */<0>(k + 1, sum, out);
} else {
ttg::print(" ", sum, ">=", threshold, " so stopping the iterations");
}
Expand All @@ -35,17 +35,20 @@ int main(int argc, char **argv) {
ttg::Edge<int, double> C_A("C(k)->A(k)");

auto wc(ttg::make_tt(c, ttg::edges(B_C), ttg::edges(C_A), "C", {"From B"}, {"to A"}));

/**! \link TT::set_input_reducer() */wc->set_input_reducer/**! \endlink */<0>([](double &a, const double &b) { a += b; });

auto wa(ttg::make_tt([&](const int &k, const double &input, std::tuple<ttg::Out<Key2, double>> &out) {
ttg::print("Called task A(", k, ")");
wc->set_argstream_size<0>(k, k+1);
for(int i = 0; i < k+1; i++) {
/**! \link ttg::send() */
ttg::send/**! \endlink */<0>(Key2{k, i}, 1.0 + k + input, out);
}
}, ttg::edges(C_A), ttg::edges(A_B), "A", {"from C"}, {"to B"}));
/**! \link TT::set_input_reducer() */ wc->set_input_reducer /**! \endlink */<0>(
[](double &a, const double &b) { a += b; });

auto wa(ttg::make_tt(
[&](const int &k, const double &input, std::tuple<ttg::Out<Key2, double>> &out) {
ttg::print("Called task A(", k, ")");
wc->set_argstream_size<0>(k, k + 1);
for (int i = 0; i < k + 1; i++) {
/**! \link ttg::send() */
ttg::send /**! \endlink */<0>(Key2{k, i}, 1.0 + k + input, out);
}
},
ttg::edges(C_A), ttg::edges(A_B), "A", {"from C"}, {"to B"}));

auto wb(ttg::make_tt(b, ttg::edges(A_B), ttg::edges(B_C), "B", {"from A"}, {"to C"}));

Expand All @@ -64,6 +67,6 @@ int main(int argc, char **argv) {
* \example reducing.cc
* This is the iterative diamond DAG with variable number of inputs using the reducing
* terminals of Template Task Graph: iteratively, a reducing diamond of data-dependent
* width is run, until the amount of data gathered at the bottom of the diamond exceeds
* width is run, until the amount of data gathered at the bottom of the diamond exceeds
* a given threshold.
*/
16 changes: 13 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ add_ttg_executable(helloworld helloworld/helloworld.cpp)
add_ttg_executable(simplegenerator simplegenerator/simplegenerator.cc RUNTIMES "mad")

if(TARGET DPLASMA::dplasma)
add_ttg_executable(potrf potrf/potrf_pdc.cc LINK_LIBRARIES lapackpp DPLASMA::dplasma MADworld)
# add_executable(potrf-pdc-parsec potrf/potrf_pdc.cc)
# target_link_libraries(potrf-pdc-parsec PRIVATE blaspp lapackpp DPLASMA::dplasma MADworld ttg-parsec)
add_ttg_executable(testing_dpotrf potrf/testing_dpotrf.cc LINK_LIBRARIES lapackpp DPLASMA::dplasma MADworld)
add_ttg_executable(testing_dtrtri potrf/testing_dtrtri.cc LINK_LIBRARIES lapackpp DPLASMA::dplasma MADworld)
add_ttg_executable(testing_dlauum potrf/testing_dlauum.cc LINK_LIBRARIES lapackpp DPLASMA::dplasma MADworld)
add_ttg_executable(testing_dpoinv potrf/testing_dpoinv.cc LINK_LIBRARIES lapackpp DPLASMA::dplasma MADworld)
target_compile_definitions(testing_dpotrf PRIVATE USE_DPLASMA=1)
target_compile_definitions(testing_dtrtri PRIVATE USE_DPLASMA=1)
target_compile_definitions(testing_dlauum PRIVATE USE_DPLASMA=1)
target_compile_definitions(testing_dpoinv PRIVATE USE_DPLASMA=1)
else(TARGET DPLSAMA::dplasma)
add_ttg_executable(testing_dpotrf potrf/testing_dpotrf.cc LINK_LIBRARIES lapackpp MADworld)
add_ttg_executable(testing_dtrtri potrf/testing_dtrtri.cc LINK_LIBRARIES lapackpp MADworld)
add_ttg_executable(testing_dlauum potrf/testing_dlauum.cc LINK_LIBRARIES lapackpp MADworld)
add_ttg_executable(testing_dpoinv potrf/testing_dpoinv.cc LINK_LIBRARIES lapackpp MADworld)
endif(TARGET DPLASMA::dplasma)


Expand Down
Loading

0 comments on commit 22f0b82

Please sign in to comment.