diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 0d6c89867d..a611335688 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -439,7 +439,15 @@ bool Runtime::finalize(bool const force_now) { } void Runtime::sync() { - MPI_Barrier(communicator_); + MPI_Comm comm = communicator_; + if (comm == MPI_COMM_NULL and theContext != nullptr) { + comm = theContext->getComm(); + } + if (comm == MPI_COMM_NULL) { + vtAbort("Trying to sync runtime while the communicator is not available"); + } else { + MPI_Barrier(comm); + } } void Runtime::runScheduler() {