Skip to content

Commit

Permalink
Make sure spmd_init finishes before returning
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Nov 20, 2020
1 parent 0f7a8d5 commit 209877f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions flecsi/execution/hpx/runtime_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
/*! @file */

#include <hpx/modules/execution_base.hpp> // yield_while
#include <hpx/modules/runtime_local.hpp> // get_thread_manager

#include <cstddef>
#include <cstdint>

Expand All @@ -27,6 +30,17 @@ clog_register_tag(runtime_driver);
namespace flecsi {
namespace execution {

void
termination_detection() {
auto & tm = hpx::threads::get_thread_manager();
hpx::util::yield_while(
[&tm]() -> bool {
return tm.get_thread_count() >
std::int64_t(1) + tm.get_background_thread_count();
},
"termination_detection");
}

//----------------------------------------------------------------------------//
// Implementation of FleCSI runtime driver task.
//----------------------------------------------------------------------------//
Expand Down Expand Up @@ -97,6 +111,9 @@ hpx_runtime_driver(int argc, char ** argv) {
// Execute the specialization driver.
specialization_tlt_init(argc, argv);
annotation::end<annotation::spl_tlt_init>();

// make sure all activity has ceased
termination_detection();
#endif // FLECSI_ENABLE_SPECIALIZATION_TLT_INIT

remap_shared_entities();
Expand Down Expand Up @@ -149,6 +166,9 @@ hpx_runtime_driver(int argc, char ** argv) {
annotation::begin<annotation::spl_spmd_init>();
specialization_spmd_init(argc, argv);
annotation::end<annotation::spl_spmd_init>();

// make sure all activity has ceased
termination_detection();
#endif // FLECSI_ENABLE_SPECIALIZATION_SPMD_INIT

context_.advance_state();
Expand Down

0 comments on commit 209877f

Please sign in to comment.