Skip to content

Commit

Permalink
Merge pull request #260 from devreal/make_executable_sync
Browse files Browse the repository at this point in the history
Synchronize on make_graph_executable
  • Loading branch information
therault authored Jun 23, 2023
2 parents 90b546c + a7dc7fb commit d59730e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ttg/ttg/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ namespace ttg {
template <typename... TTBasePtrs>
inline std::enable_if_t<(std::is_convertible_v<decltype(*(std::declval<TTBasePtrs>())), TTBase &> && ...), bool>
make_graph_executable(TTBasePtrs &&...tts) {
return ttg::make_traverse([](auto &&x) { std::forward<decltype(x)>(x)->make_executable(); })(
std::forward<TTBasePtrs>(tts)...);
auto traverse = ttg::make_traverse([](auto &&x) { std::forward<decltype(x)>(x)->make_executable(); });
auto ret = traverse(std::forward<TTBasePtrs>(tts)...);
// make sure everyone has traversed the TT
auto world = [&](auto&& tt0, auto&&... tts) { return tt0->get_world(); }(std::forward<TTBasePtrs>(tts)...);
TTG_IMPL_NS::make_executable_hook(world);
return ret;
}

/// \brief Connect output terminal to successor input terminal
Expand Down
2 changes: 2 additions & 0 deletions ttg/ttg/madness/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace ttg_madness {

class WorldImpl;

inline void make_executable_hook(ttg::World&);

inline void ttg_initialize(int argc, char **argv, int num_threads = -1);

inline void ttg_finalize();
Expand Down
2 changes: 2 additions & 0 deletions ttg/ttg/madness/ttg.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ namespace ttg_madness {
#endif
};

inline void make_executable_hook(ttg::World& world) { }

inline void ttg_initialize(int argc, char **argv, int num_threads) {
if (num_threads < 1) num_threads = ttg::detail::num_threads();
::madness::World &madworld = ::madness::initialize(argc, argv, num_threads, /* quiet = */ true);
Expand Down
2 changes: 2 additions & 0 deletions ttg/ttg/parsec/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace ttg_parsec {

class WorldImpl;

inline void make_executable_hook(ttg::World&);

inline void ttg_initialize(int argc, char **argv, int num_threads = -1, parsec_context_s * = nullptr);

inline void ttg_finalize();
Expand Down
6 changes: 5 additions & 1 deletion ttg/ttg/parsec/ttg.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ namespace ttg_parsec {
#endif
};

static void unregister_parsec_tags(void *_)
inline void unregister_parsec_tags(void *_)
{
if(NULL != parsec_ce.tag_unregister) {
parsec_ce.tag_unregister(WorldImpl::parsec_ttg_tag());
Expand Down Expand Up @@ -1035,6 +1035,10 @@ namespace ttg_parsec {
value = result;
}

inline void make_executable_hook(ttg::World& world) {
MPI_Barrier(world.impl().comm());
}

/// broadcast
/// @tparam T a serializable type
template <typename T>
Expand Down

0 comments on commit d59730e

Please sign in to comment.