Skip to content

Commit 8d502b5

Browse files
Rename some options for better encapsulation, add minor conveniences
1 parent 18c7fad commit 8d502b5

File tree

6 files changed

+61
-37
lines changed

6 files changed

+61
-37
lines changed

include/fenix.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,23 @@ typedef enum {
145145
*/
146146
typedef enum {
147147
//!Return to Fenix_Init via longjmp (default)
148-
JUMP,
148+
FENIX_RESUME_JUMP,
149149
//!Return the error code inline
150-
RETURN,
150+
FENIX_RESUME_RETURN,
151151
//!Throw a Fenix::CommException
152-
THROW
152+
FENIX_RESUME_THROW
153153
} Fenix_Resume_mode;
154154

155155
/**
156156
* @brief Options for dealing with 'unhandled' errors, e.g. invalid rank IDs
157157
*/
158158
typedef enum {
159159
//!Ignore unhandled errors
160-
SILENT,
160+
FENIX_UNHANDLED_SILENT,
161161
//!Print error and continue without handling
162-
PRINT,
162+
FENIX_UNHANDLED_PRINT,
163163
//!Print error and abort Fenix's world (default)
164-
ABORT
164+
FENIX_UNHANDLED_ABORT
165165
} Fenix_Unhandled_mode;
166166

167167
/**
@@ -363,6 +363,8 @@ int Fenix_Finalize();
363363
#define FENIX_DATA_POLICY_IN_MEMORY_RAID 13
364364
#define FENIX_DATA_POLICY_IMR FENIX_DATA_POLICY_IN_MEMORY_RAID
365365

366+
#define FENIX_TIME_STAMP_IGNORE NULL
367+
366368
/**
367369
* @unimplemented As MPI_Request, but for Fenix asynchronous data recovery calls
368370
*/
@@ -393,6 +395,7 @@ extern const Fenix_Data_subset FENIX_DATA_SUBSET_FULL;
393395
//!@brief A standin for checkpointing/recovering none of the available data in a member.
394396
extern const Fenix_Data_subset FENIX_DATA_SUBSET_EMPTY;
395397

398+
extern Fenix_Data_subset* FENIX_DATA_SUBSET_IGNORE;
396399

397400
/**
398401
* @brief Create a Data Group

include/fenix.hpp

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,33 @@ int Fenix_Callback_register(std::function<void(MPI_Comm, int)> callback);
7575

7676
namespace Fenix {
7777

78+
using Role = Fenix_Rank_role;
79+
constexpr Role INITIAL_RANK = FENIX_ROLE_INITIAL_RANK;
80+
constexpr Role RECOVERED_RANK = FENIX_ROLE_RECOVERED_RANK;
81+
constexpr Role SURVIVOR_RANK = FENIX_ROLE_SURVIVOR_RANK;
82+
83+
using ResumeMode = Fenix_Resume_mode;
84+
constexpr ResumeMode JUMP = FENIX_RESUME_JUMP;
85+
constexpr ResumeMode RETURN = FENIX_RESUME_RETURN;
86+
constexpr ResumeMode THROW = FENIX_RESUME_THROW;
87+
88+
using UnhandledMode = Fenix_Unhandled_mode;
89+
constexpr UnhandledMode SILENT = FENIX_UNHANDLED_SILENT;
90+
constexpr UnhandledMode PRINT = FENIX_UNHANDLED_PRINT;
91+
constexpr UnhandledMode ABORT = FENIX_UNHANDLED_ABORT;
92+
7893
namespace Args {
7994
struct FenixInitArgs {
80-
int* role = nullptr;
81-
MPI_Comm in_comm = MPI_COMM_WORLD;
82-
MPI_Comm* out_comm = nullptr;
83-
int* argc = nullptr;
84-
char*** argv = nullptr;
85-
int spares = 0;
86-
int spawn = 0;
87-
Fenix_Resume_mode resume_mode = THROW;
88-
Fenix_Unhandled_mode unhandled_mode = ABORT;
89-
int* err = nullptr;
95+
int* role = nullptr;
96+
MPI_Comm in_comm = MPI_COMM_WORLD;
97+
MPI_Comm* out_comm = nullptr;
98+
int* argc = nullptr;
99+
char*** argv = nullptr;
100+
int spares = 0;
101+
int spawn = 0;
102+
ResumeMode resume_mode = THROW;
103+
UnhandledMode unhandled_mode = ABORT;
104+
int* err = nullptr;
90105
};
91106
}
92107

@@ -99,8 +114,9 @@ void throw_exception();
99114

100115
namespace Fenix::Data {
101116

102-
extern const DataSubset FENIX_SUBSET_FULL;
103-
extern const DataSubset FENIX_SUBSET_EMPTY;
117+
extern const DataSubset SUBSET_FULL;
118+
extern const DataSubset SUBSET_EMPTY;
119+
extern DataSubset SUBSET_IGNORE;
104120

105121
//!@brief Overload of #Fenix_Data_member_store
106122
int member_store(int group_id, int member_id, const DataSubset& subset);
@@ -122,13 +138,13 @@ int member_istorev(
122138

123139
//!@brief Overload of #Fenix_Data_member_restore
124140
int member_restore(
125-
int group_id, int member_id, void *target_buffer, int max_count,
141+
int group_id, int member_id, void *target_buffer, int max_length,
126142
int time_stamp, DataSubset& data_found
127143
);
128144

129145
//!@brief Overload of #Fenix_Data_member_lrestore
130146
int member_lrestore(
131-
int group_id, int member_id, void *target_buffer, int max_count,
147+
int group_id, int member_id, void *target_buffer, int max_length,
132148
int time_stamp, DataSubset& data_found
133149
);
134150

include/fenix_ext.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@
6060
#include <mpi.h>
6161
#include <vector>
6262
#include "fenix.h"
63+
#include "fenix.hpp"
6364
#include "fenix_opt.hpp"
6465
#include "fenix_process_recovery.hpp"
6566
#include "fenix_data_group.hpp"
6667

68+
namespace Fenix {
69+
6770
typedef struct {
6871
int num_inital_ranks; // Keeps the global MPI rank ID at Fenix_init
6972
int num_survivor_ranks = 0; // Keeps the global information on the number of survived MPI ranks after failure
7073
int num_recovered_ranks = 0; // Keeps the number of spare ranks brought into MPI communicator recovery
7174
int spare_ranks; // Spare ranks entered by user to repair failed ranks
7275

73-
int resume_mode = Fenix_Resume_mode::JUMP;
74-
int unhandled_mode = Fenix_Unhandled_mode::ABORT;
76+
ResumeMode resume_mode = JUMP;
77+
UnhandledMode unhandled_mode = ABORT;
7578
int ignore_errs = false; // Temporarily ignore all errors & recovery
7679
int spawn_policy; // Indicate dynamic process spawning
7780
jmp_buf *recover_environment; // Calling environment to fill the jmp_buf structure
@@ -107,5 +110,7 @@ typedef struct {
107110
Fenix::Data::fenix_data_recovery_t *data_recovery; // Global pointer for Fenix Data Recovery Data Structure
108111
} fenix_t;
109112

110-
extern fenix_t fenix;
113+
}
114+
115+
extern Fenix::fenix_t fenix;
111116
#endif // __FENIX_EXT_H__

src/fenix.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ using namespace Fenix;
6565
using namespace Fenix::Data;
6666

6767
namespace Fenix::Data {
68-
const DataSubset FENIX_SUBSET_FULL = {{0, Fenix::DataSubset::MAX}};
69-
const DataSubset FENIX_SUBSET_EMPTY = {};
68+
const DataSubset SUBSET_FULL = {{0, Fenix::DataSubset::MAX}};
69+
const DataSubset SUBSET_EMPTY = {};
70+
DataSubset SUBSET_IGNORE = SUBSET_EMPTY;
7071
}
7172

7273
const Fenix_Data_subset FENIX_DATA_SUBSET_FULL = { new DataSubset(DataSubset::MAX) };
7374
const Fenix_Data_subset FENIX_DATA_SUBSET_EMPTY = { new DataSubset() };
75+
Fenix_Data_subset* FENIX_DATA_SUBSET_IGNORE = NULL;
7476

7577
int Fenix_Callback_register(std::function<void(MPI_Comm, int)> callback){
7678
return __fenix_callback_register(callback);

src/globals.cpp renamed to src/fenix_ext.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//
1414
//
15-
// Copyright (C) 2018 Rutgers University and Sandia Corporation
15+
// Copyright (C) 2016 Rutgers University and Sandia Corporation
1616
//
1717
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
1818
// the U.S. Government retains certain rights in this software.
@@ -44,8 +44,8 @@
4444
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4545
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4646
//
47-
// Author Marc Gamell, Eric Valenzuela, Keita Teranishi, Manish Parashar
48-
// Michael Heroux, and Matthew Whitlock
47+
// Author Marc Gamell, Eric Valenzuela, Keita Teranishi, Manish Parashar,
48+
// Rob Van der Wijngaart, Michael Heroux, and Matthew Whitlock
4949
//
5050
// Questions? Contact Keita Teranishi (knteran@sandia.gov) and
5151
// Marc Gamell (mgamell@cac.rutgers.edu)
@@ -56,6 +56,4 @@
5656

5757
#include "fenix_ext.hpp"
5858

59-
fenix_t fenix = {
60-
.fenix_init_flag = 0
61-
};
59+
Fenix::fenix_t fenix;

src/fenix_process_recovery.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,22 @@ int fenix_preinit(const Args::FenixInitArgs& args, jmp_buf* jump_env){
193193

194194
Fenix_Resume_mode get_resume_mode(const std::string_view& name){
195195
if (name == "JUMP") {
196-
return Fenix_Resume_mode::JUMP;
196+
return Fenix::JUMP;
197197
} else if (name == "RETURN") {
198-
return Fenix_Resume_mode::RETURN;
198+
return Fenix::RETURN;
199199
} else if (name == "THROW") {
200-
return Fenix_Resume_mode::THROW;
200+
return Fenix::THROW;
201201
}
202202
fatal_print("Unsupported FENIX_RESUME_MODE %s", name.data());
203203
}
204204

205205
Fenix_Unhandled_mode get_unhandled_mode(const std::string_view& name){
206206
if (name == "SILENT") {
207-
return Fenix_Unhandled_mode::SILENT;
207+
return Fenix::SILENT;
208208
} else if (name == "PRINT") {
209-
return Fenix_Unhandled_mode::PRINT;
209+
return Fenix::PRINT;
210210
} else if (name == "ABORT") {
211-
return Fenix_Unhandled_mode::ABORT;
211+
return Fenix::ABORT;
212212
}
213213
fatal_print("Unsupported FENIX_UNHANDLED_MODE %s", name.data());
214214
}

0 commit comments

Comments
 (0)