Skip to content

Commit

Permalink
Print MPI rank if available instead of locality in exception information
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Oct 26, 2023
1 parent 5d15da8 commit 1957058
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions libs/pika/runtime/src/custom_exception_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <pika/threading_base/thread_helpers.hpp>
#include <pika/version.hpp>

#if defined(PIKA_HAVE_MPI)
# include <pika/mpi_base/mpi.hpp>
#endif

#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/printf.h>
Expand Down Expand Up @@ -85,8 +89,17 @@ namespace pika {
strm << "{stack-trace}: " << *back_trace << "\n";
}

std::uint32_t const* locality = xi.get<pika::detail::throw_locality>();
if (locality) strm << "{locality-id}: " << *locality << "\n";
#if defined(PIKA_HAVE_MPI)
int mpi_initialized = 0;
if (MPI_Initialized(&mpi_initialized) == MPI_SUCCESS && mpi_initialized)
{
int rank = 0;
if (MPI_Comm_rank(MPI_COMM_WORLD, &rank) == MPI_SUCCESS)
{
strm << "{mpi-rank}: " << rank << '\n';
}
}
#endif

std::string const* hostname_ = xi.get<pika::detail::throw_hostname>();
if (hostname_ && !hostname_->empty()) strm << "{hostname}: " << *hostname_ << "\n";
Expand Down

0 comments on commit 1957058

Please sign in to comment.