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#include "fenix/mpixx/group.hpp"
72
73namespace fenix {
74
75// Fenix's global settings, configurable before initialization
76struct Settings {
77 RecoveryMode recovery = REPAIR;
78 // Defaults to JUMP if a jump_buf provided, else THROW
80 CallbackExceptionMode cb_exception = SQUASH;
81 UnhandledMode unhandled = ABORT;
82 MlogRecoveryMode mlog_recovery = MANUAL;
83 SpareWaitMode spare_wait = YIELD;
84 SpareFinalizeMode spare_finalize = EXIT;
85};
86
87// Configurations before init change this
88inline Settings fenix_default_settings;
89
90struct fenix_t {
91 using Group = mpixx::Group;
92 using Comm = mpixx::Comm;
93
94 // Global Fenix settings
95 Settings settings;
96
97 jmp_buf* recover_environment; // for FENIX_RESUME_JUMP
98
99 int mpi_fail_code = MPI_SUCCESS;
100 int repair_result = FENIX_SUCCESS; // Result of MPI comm repair
101 int role = FENIX_ROLE_INITIAL_RANK;
102
103 int fenix_init_flag = false;
104 int finalized = false;
105
106 //Save the pointer to role and error of Fenix_Init
107 int* ret_role = &role;
108 int* ret_error = &repair_result;
109
110 std::unordered_map<CallbackLocation, std::vector<FenixCallbackFunc>>
111 callbacks;
112 fenix_debug_opt_t options; // This is reserved to store the user options
113
114 // All processes managed by Fenix, including dead ones
115 Group procs;
116 // Categorized procs - non-intersecting and union to universe_procs
117 Group user_procs, spare_procs, dead_procs;
118 // Conversions from a given pid (rank in universe_procs) to a given rank
119 // assignment (rank the proc is representing in the originally constructed
120 // active_procs) and back.
121 // pid_to_rank maintains mappings from a dead pid to whatever rank it was
122 // assigned to when it died, so ranks may be represented multiple times
123 // rank_to_pid maintains its original size when user_world shrinks, so some
124 // ranks will be MPI_UNDEFINED to indicate that they are no longer available
125 std::vector<int> pid_to_rank;
126 std::vector<int> rank_to_pid;
127
128 // Categorize procs based on most recent recovery operation
129 Group fail_procs, recovered_procs, survivor_procs;
130 // Rank of fail_procs in user_world from before most recent recovery
131 std::vector<int> fail_ranks;
132
133 Comm world; // Duplicate of comm provided by user
134 Comm user_world; // User-facing comm with repaired ranks and no spares
135 Comm new_world; // Internal duplicate of user_world
136
137 MPI_Comm* user_world_ptr = nullptr; // Pointer to application's MPI_Comm
138
139 //Values used for Fenix_Process_detect_failures
140 int dummy_recv_buffer;
141 MPI_Request check_failures_req;
142
143 MPI_Errhandler mpi_errhandler; // Our custom error handler
144
145 fenix::data::DataComponent* data_recovery = nullptr;
146
147 // -------------------------
148 // Message logging variables
149 // -------------------------
150
151 // All loggers indexed by ID
152 std::unordered_map<int, std::shared_ptr<logging::CommLog>> mlogs;
153 // Order of creation of all existing mlogs
154 std::vector<int> mlog_order;
155 // Active log (if any)
156 std::shared_ptr<logging::CommLog> active_mlog;
157 int active_mlog_id = FENIX_MLOG_NONE;
158
159 // Maps of UID to MPI internal types for logging
160 std::map<int, MPI_Datatype> mpi_types;
161 std::map<int, MPI_Op> mpi_ops;
162
163 static inline bool mpi_overloads_linked = false;
164};
165
166inline fenix::fenix_t fenix_rt;
167} // namespace fenix
168#endif // __FENIX_EXT_H__
Definition component.hpp:12
Definition comm.hpp:16
Definition group.hpp:21
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:277
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:322
Fenix_Resume_mode
Options for passing control back to application after recovery.
Definition fenix.h:250
Fenix_Recovery_mode
Options for recovering after a failed rank is detected.
Definition fenix.h:208
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:293
Fenix_Callback_exception_mode
Options for dealing with CommExceptions generated in callbacks.
Definition fenix.h:308
Fenix_Mlog_recovery_mode
Definition fenix.h:226
@ FENIX_RESUME_MODE_MAXCODE
Not a valid option.
Definition fenix.h:271
@ FENIX_ROLE_INITIAL_RANK
No failures have occurred yet.
Definition fenix.h:171
Definition fenix_opt.hpp:133
Definition fenix_ext.hpp:76
Definition fenix_ext.hpp:90