Fenix @develop
 
Loading...
Searching...
No Matches
fenix_ext.hpp
1/*
2//@HEADER
3// ************************************************************************
4//
5//
6// _|_|_|_| _|_|_|_| _| _| _|_|_| _| _|
7// _| _| _|_| _| _| _| _|
8// _|_|_| _|_|_| _| _| _| _| _|
9// _| _| _| _|_| _| _| _|
10// _| _|_|_|_| _| _| _|_|_| _| _|
11//
12//
13//
14//
15// Copyright (C) 2016 Rutgers University and Sandia Corporation
16//
17// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18// the U.S. Government retains certain rights in this software.
19//
20// Redistribution and use in source and binary forms, with or without
21// modification, are permitted provided that the following conditions are
22// met:
23//
24// 1. Redistributions of source code must retain the above copyright
25// notice, this list of conditions and the following disclaimer.
26//
27// 2. Redistributions in binary form must reproduce the above copyright
28// notice, this list of conditions and the following disclaimer in the
29// documentation and/or other materials provided with the distribution.
30//
31// 3. Neither the name of the Corporation nor the names of the
32// contributors may be used to endorse or promote products derived from
33// this software without specific prior written permission.
34//
35// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
36// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
39// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46//
47// Author Marc Gamell, Eric Valenzuela, Keita Teranishi, Manish Parashar,
48// Michael Heroux, and Matthew Whitlock
49//
50// Questions? Contact Keita Teranishi (knteran@sandia.gov) and
51// Marc Gamell (mgamell@cac.rutgers.edu)
52//
53// ************************************************************************
54//@HEADER
55*/
56
57#ifndef __FENIX_EXT_H__
58#define __FENIX_EXT_H__
59
60#include <mpi.h>
61#include <vector>
62#include <unordered_map>
63#include <map>
64#include "fenix.h"
65#include "fenix.hpp"
66#include "fenix_opt.hpp"
67#include "fenix/data/group.hpp"
68#include "fenix/data/component.hpp"
69#include "fenix/logging/comm_log.h"
70#include "fenix/mpixx/comm.hpp"
71
72namespace fenix {
73
74// Fenix's global settings, configurable before initialization
75struct Settings {
76 RecoveryMode recovery = REPAIR;
77 // Defaults to JUMP if a jump_buf provided, else THROW
79 CallbackExceptionMode cb_exception = SQUASH;
80 UnhandledMode unhandled = ABORT;
81 MlogRecoveryMode mlog_recovery = MANUAL;
82 SpareWaitMode spare_wait = YIELD;
83 SpareFinalizeMode spare_finalize = EXIT;
84};
85
86// Configurations before init change this
87inline Settings fenix_default_settings;
88
89struct fenix_t {
90 // Global Fenix settings
91 Settings settings;
92
93 int num_initial_ranks;
94 int num_survivor_ranks = 0; // As of last failure
95 int num_recovered_ranks = 0; // As of last failure
96 int spare_ranks; // Spare ranks entered by user
97
98 jmp_buf* recover_environment; // for FENIX_RESUME_JUMP
99
100 int mpi_fail_code = MPI_SUCCESS;
101 int repair_result = FENIX_SUCCESS; // Result of MPI comm repair
102 int role = FENIX_ROLE_INITIAL_RANK;
103
104 int fenix_init_flag = false;
105 int finalized = false;
106
107 int fail_world_size = 0;
108 int* fail_world = nullptr;
109
110 //Save the pointer to role and error of Fenix_Init
111 int* ret_role = &role;
112 int* ret_error = &repair_result;
113
114 std::unordered_map<CallbackLocation, std::vector<FenixCallbackFunc>>
115 callbacks;
116 fenix_debug_opt_t options; // This is reserved to store the user options
117
118 mpixx::Comm world; // Duplicate of comm provided by user
119 mpixx::Comm user_world; // User-facing comm with repaired ranks and no spares
120 MPI_Comm* user_world_ptr = nullptr; // Pointer to application's MPI_Comm
121 mpixx::Comm new_world; // Internal duplicate of user_world
122
123 //Values used for Fenix_Process_detect_failures
124 int dummy_recv_buffer;
125 MPI_Request check_failures_req;
126
127 MPI_Op agree_op; // Global agreement call for data recovery API
128 MPI_Errhandler mpi_errhandler; // Our custom error handler
129
130 fenix::data::DataComponent* data_recovery = nullptr;
131
132 // -------------------------
133 // Message logging variables
134 // -------------------------
135
136 // All loggers indexed by ID
137 std::unordered_map<int, std::shared_ptr<logging::CommLog>> mlogs;
138 // Order of creation of all existing mlogs
139 std::vector<int> mlog_order;
140 // Active log (if any)
141 std::shared_ptr<logging::CommLog> active_mlog;
142 int active_mlog_id = FENIX_MLOG_NONE;
143
144 // Maps of UID to MPI internal types for logging
145 std::map<int, MPI_Datatype> mpi_types;
146 std::map<int, MPI_Op> mpi_ops;
147
148 static inline bool mpi_overloads_linked = false;
149};
150
151inline fenix::fenix_t fenix_rt;
152} // namespace fenix
153#endif // __FENIX_EXT_H__
Definition component.hpp:12
Definition comm.hpp:15
Contains all API function calls and Fenix types. This is the only header file a user should include.
Fenix_Unhandled_mode
Options for dealing with 'unhandled' errors, e.g. invalid rank IDs.
Definition fenix.h:274
Fenix_Spare_finalize_mode
Options for what spare ranks should do when Fenix_Finalize is called. Must be set before Fenix_Init t...
Definition fenix.h:319
Fenix_Resume_mode
Options for passing control back to application after recovery.
Definition fenix.h:247
Fenix_Recovery_mode
Options for recovering after a failed rank is detected.
Definition fenix.h:205
Fenix_Spare_wait_mode
Options for how spare ranks wait to be needed. Must be set before Fenix_Init to take effect.
Definition fenix.h:290
Fenix_Callback_exception_mode
Options for dealing with CommExceptions generated in callbacks.
Definition fenix.h:305
Fenix_Mlog_recovery_mode
Definition fenix.h:223
@ FENIX_RESUME_MODE_MAXCODE
Not a valid option.
Definition fenix.h:268
@ FENIX_ROLE_INITIAL_RANK
No failures have occurred yet.
Definition fenix.h:170
Definition fenix_opt.hpp:133
Definition fenix_ext.hpp:75
Definition fenix_ext.hpp:89