Skip to content

Commit

Permalink
#1456: runtime: Switch to runtime check for throwing an exception on …
Browse files Browse the repository at this point in the history
…vtAbort(..)
  • Loading branch information
JacobDomagala committed May 27, 2021
1 parent 817fd16 commit 5f8ad53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/vt/collective/collective_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@ void CollectiveAnyOps<instance>::abort(
myrt->theTrace->cleanupTracesFile();
#endif
myrt->abort(str, code);
} else if (vt::debug::preConfig()->vt_throw_on_abort) {
// Special case when preConfig has 'vt_throw_on_abort' option set
// This is meant to be used by nompi unit tests
throw std::runtime_error(str);
} else {
std::_Exit(code);
}

}

template <runtime::RuntimeInstType instance>
Expand Down
32 changes: 14 additions & 18 deletions src/vt/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@

#include <checkpoint/checkpoint.h>

#if vt_check_enabled(throw_on_abort)
#include <stdexcept>
#endif
#include <memory>
#include <iostream>
#include <functional>
Expand Down Expand Up @@ -518,24 +516,22 @@ void Runtime::reset() {
}

void Runtime::abort(std::string const abort_str, ErrorCodeType const code) {
#if !vt_check_enabled(throw_on_abort)
aborted_ = true;
#endif
output(abort_str,code,true,true,false);

#if vt_check_enabled(throw_on_abort)
throw std::runtime_error(abort_str);
#else
std::raise( SIGTRAP );
if (theContext) {
auto const comm = theContext->getComm();
MPI_Abort(comm, 129);
output(abort_str, code, true, true, false);

if (theConfig()->vt_throw_on_abort) {
throw std::runtime_error(abort_str);
} else {
std::_Exit(code);
// @todo: why will this not compile with clang!!?
//quick_exit(code);
aborted_ = true;
std::raise(SIGTRAP);
if (theContext) {
auto const comm = theContext->getComm();
MPI_Abort(comm, 129);
} else {
std::_Exit(code);
// @todo: why will this not compile with clang!!?
//quick_exit(code);
}
}
#endif
}

void Runtime::output(
Expand Down

0 comments on commit 5f8ad53

Please sign in to comment.