32 std::optional<i32> _max_tag = std::nullopt;
34 std::string _mpi_process_name;
44 __attribute__((no_sanitize_address))
void fetch_mpi_process_name() {
45 char hn[MPI_MAX_PROCESSOR_NAME];
48 MPICHECK(MPI_Get_processor_name(hn, &hn_len));
50 _mpi_process_name = std::string(hn,
size_t(hn_len));
53 void set_callstack_process_identifier() {
54 std::optional<u32> local_rank = node_local_rank();
56 shambase::set_callstack_process_identifier(
58 "{} (world rank: {}, local rank: {})",
61 (local_rank) ? std::to_string(*local_rank) :
"Unknown"));
66 MPICHECK(MPI_Comm_size(MPI_COMM_WORLD, &_world_size));
67 MPICHECK(MPI_Comm_rank(MPI_COMM_WORLD, &_world_rank));
69 fetch_mpi_process_name();
70 set_callstack_process_identifier();
76 MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &max_tag, &flag);
78 _max_tag = *(
int *) max_tag;
82 shamcomm::mpi::Barrier(MPI_COMM_WORLD);
84 shambase::profiling::chrome::set_time_offset(shambase::details::get_wtime());
86 shambase::profiling::chrome::set_chrome_pid(
world_rank());
std::int32_t i32
32 bit integer
Functions related to the MPI communicator.
Utility functions for MPI error checking.
#define MPICHECK(mpicall)
Shortcut macro to check MPI return codes.
Use this header to include MPI properly.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for communication related stuff
void fetch_world_info()
Gets the information about the MPI communicator.
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
i32 world_size()
Gives the size of the MPI communicator.
i32 mpi_max_tag_value()
Gets the maximum value of the MPI tag.
bool is_mpi_initialized()
Check if MPI is initialized.
std::string mpi_process_name()
Gets the name of the MPI process.
This file contains the definition for the stacktrace related functionality.
Functions related to the MPI communicator.