Fenix @develop
 
Loading...
Searching...
No Matches
policy_imr.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_DATA_POLICY_IN_MEMORY_RAID_H__
58#define __FENIX_DATA_POLICY_IN_MEMORY_RAID_H__
59
60#include <mpi.h>
61#include <map>
62#include <memory>
63#include <deque>
64#include <cassert>
65#include <string>
66#include "fenix/data/group.hpp"
67#include "fenix/data/util/buffer.hpp"
68#include "fenix/data/subset.hpp"
69#include "fenix/data/snapshot.hpp"
70#include "fenix/tasks/task.hpp"
71
72namespace fenix::data::imr {
73
75 IMRSnapshot(int size, int max_count);
76
77 //IMR-specific partner data as a second DataSnapshot
78 DataSnapshot partner;
79
80 //Accessor for partner snapshot
81 DataSnapshot& partner_snapshot() { return partner; }
82
83 // Override to also initialize partner's cohort
84 void init_cohort(MPI_Comm cohort_comm) override;
85 void reinit_cohort(MPI_Comm cohort_comm) override;
86};
87
88struct IMRGroup;
89
90struct BuddyMember : public DataMember {
91 BuddyMember(DataMember&& member, IMRGroup& group);
92 void repair() override;
93 tasks::Task<int> iprotect() override;
94
95 std::unique_ptr<DataSnapshot> create_snapshot(int size, int count) override {
96 return std::make_unique<imr::IMRSnapshot>(size, count);
97 }
98
99 util::DataBuffer& send_buf;
100 util::DataBuffer& recv_buf;
101};
102
103struct ParityMember : public DataMember {
104 ParityMember(DataMember&& member, IMRGroup& group);
105 void repair() override;
106 tasks::Task<int> iprotect() override;
107
108 // Ensures snapshot sized appropriately.
109 // Returns vector of parity bytes for each cohort member, including self.
110 std::vector<int> prepare_for_parity(IMRSnapshot& snap);
111
112 std::unique_ptr<DataSnapshot> create_snapshot(int size, int count) override {
113 return std::make_unique<imr::IMRSnapshot>(size, count);
114 }
115
116 util::DataBuffer& send_buf;
117 util::DataBuffer& recv_buf;
118};
119
120struct IMRGroup : public DataGroup {
121 IMRGroup(int id, MPI_Comm comm, int timestart, int depth, int* policy);
122
123 // Helpers to extract mode and rank_separation from policy_vals
124 static int get_mode(int* policy_vals);
125 static int get_rank_sep(int* policy_vals, MPI_Comm comm);
126
127 MPI_Group create_cohort() override;
128 void init() override;
129
130 int mode;
131 int rank_separation;
132 int set_size_policy; // For mode 5, the set_size from policy_vals
133
134 util::DataBuffer send_buf, recv_buf;
135
136 void emplace_member(DataMember&& member) override;
137 void get_redundant_policy(int* name, void* value) override;
138
139 void commit() override;
140
141 void member_repair(int member_id) override;
142 void member_restore_from_rank(
143 int member_id, void* buffer, int max, int timestamp, int source_rank
144 ) override;
145};
146
147} // namespace fenix::data::imr
148
149#endif //__FENIX_DATA_POLICY_IN_MEMORY_RAID_H__
Definition member.hpp:76
Definition snapshot.hpp:17
Definition buffer.hpp:68
Definition task.hpp:15
Definition group.hpp:78
Definition policy_imr.hpp:90
Definition policy_imr.hpp:120
Definition policy_imr.hpp:74
Definition policy_imr.hpp:103