20 int id = -1, first = -1, next = -1;
22 CRegion(
int m_id) : id(m_id) {};
23 CRegion(
int m_id,
int idx) : id(m_id), first(idx), next(idx) {}
24 auto operator<=>(
const CRegion& o)
const {
return id <=> o.id; }
25 auto operator==(
const CRegion& o)
const {
return id == o.id; }
26 auto operator<=>(
const int& i)
const {
return id <=> i; }
27 auto operator==(
const int& i)
const {
return id == i; }
28 bool valid()
const {
return id >= 0 && first >= 0 && next >= 0; }
29 bool empty()
const {
return valid() && first == next; }
30 bool fresh()
const {
return empty() && first == 0; }
31 std::string str()
const {
32 return "Region " + std::to_string(
id) +
" [" + std::to_string(first) +
"," +
33 std::to_string(next) +
")";
38 CommLog(MPI_Comm& c,
int m_max_regions = 2);
39 CommLog(MPI_Comm& c, std::istream& i);
40 void serialize(std::ostream& o);
45 int active_region = 0;
47 std::map<int, RankLog> rank_logs;
48 std::vector<TaskT> tasks;
50 std::vector<CRegion> regions;
51 std::set<CollectiveLogHolder, std::less<>> collectives;
54 int completed_collective_all = -1;
56 int completed_collective_any = -1;
60 RankLog& operator[](
int r) {
return logs(r); }
65 void progress_through(
TaskT t);
68 int send(
const void* b,
int n, MPI_Datatype d,
int dst,
int t) {
69 return logs(dst).send(b, n, d, t);
71 int irecv(
void* b,
int n, MPI_Datatype d,
int src,
int t, MPI_Request* r) {
72 return logs(src).irecv(b, n, d, t, r);
76 using CollectiveResult =
77 std::pair<int, std::reference_wrapper<const CollectiveLogHolder>>;
80 template <
auto MPIFunction,
typename... Args>
81 int begin(Args... args) {
82 using LogT = mpi_log_t<MPIFunction>;
84 if (!region().valid()) append_region({active_region, 0});
86 CollectiveLogHolder::template create<LogT>(args..., region().next++)
90 void fenix_pre_recovery();
91 void reset_consistency(
int checkpoint_id);
93 void begin_region(
int region);
94 CRegion& region() {
return regions.back(); }
95 const CRegion& region()
const {
return regions.back(); }
97 std::string str(
bool with_region =
false)
const {
98 return "Rank " + std::to_string(m_rank) +
99 " (active=" + std::to_string(active_region) +
")" +
100 (with_region ?
" " + region().str() :
"");
105 void detect_incoming_consistency_request();
106 TaskT form_consistency();
107 void replay_collectives(
int start_idx);
108 void append_region(
const CRegion& r);
109 void erase_logs(
const CRegion& r);
111 std::vector<CRegion>::iterator begin, std::vector<CRegion>::iterator end