Repository navigation
Expand file tree
/
Copy pathutil.hpp
More file actions
197 lines (182 loc) · 6.23 KB
/
Copy pathutil.hpp
File metadata and controls
197 lines (182 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef ALLSCALE_UTIL
#define ALLSCALE_UTIL
#include <allscale/location_info.hpp>
#include <allscale/data_item_requirement.hpp>
#include <allscale/access_mode.hpp>
namespace allscale{
template<typename Region>
Region merge(const Region& a, const Region& b) {
return Region::merge(a,b);
}
template<typename Region>
Region intersect(const Region& a, const Region& b) {
return Region::intersect(a,b);
}
template<typename Region>
Region difference(const Region& a, const Region& b) {
return Region::difference(a,b);
}
// /**
// * A class summarizing the a set of data transfer operations.
// */
// template<typename DataItemType>
// class TransferPlan {
//
// using reference_type = data_item_reference<DataItemType>;
// using region_type = typename DataItemType::region_type;
//
// public:
//
// // the different kinds of transfers may be ...
// enum class Kind {
// Replication, // < Replications, where the ownership of original data is preserved
// Migration // < Migrations, where the ownership of original data is destroyed
// };
//
//
// /**
// * A description of a single data transfer step.
// */
// struct Transfer {
//
// // the data item to be transfered
// reference_type ref;
//
// // the region to be transfered
// region_type region;
//
// // the source locality of the transfer
// hpx::id_type src;
//
// // the destination locality of the transfer
// hpx::id_type dst;
//
// // the kind of transfer
// Kind kind;
//
// friend std::ostream& operator<<(std::ostream& out, const Transfer& transfer) {
// if (transfer.kind == Kind::Migration) {
// out << "migrate ";
// } else {
// out << "replicate ";
// }
// return out << transfer.region << " from " << transfer.src << " to " << transfer.dst;
// }
//
// };
//
// private:
//
// // the list of transfer operations to be covered by this transfer plan
// std::vector<Transfer> transfers;
//
// public:
//
// void addTransfer(const reference_type& ref, const region_type& region, hpx::id_type src, hpx::id_type dst, Kind kind) {
// transfers.push_back(Transfer{ ref, region, src, dst, kind });
// }
//
// const std::vector<Transfer>& getTransfers() const {
// return transfers;
// }
//
// friend std::ostream& operator<<(std::ostream& out, const TransferPlan& plan) {
// return out << "TransferPlan {" << allscale::utils::join(",",plan.transfers) << "}";
// }
// };
//
//
//
// /**
// * A simple transfer plan generator, following a greedy heuristic.
// */
// struct SimpleTransferPlanGenerator {
//
// template<typename DataItemType>
// TransferPlan<DataItemType> operator()(const location_info<DataItemType>& info, hpx::id_type targetLocation, const data_item_requirement<DataItemType>& requirement) {
//
// TransferPlan<DataItemType> res;
//
// auto rest = requirement.region;
//
// // first, remove everything that is stored at the target node
// for(const auto& cur : info.getParts()) {
// if (cur.location == targetLocation) {
// // we do not need to transfer this data
// rest = difference(rest,cur.region);
// }
// }
//
// // if this is all, we are done
// if (rest.empty()) return res;
//
// // determine the kind of data transfer
// auto kind = (requirement.mode == access_mode::ReadOnly)
// ? TransferPlan<DataItemType>::Kind::Replication
// : TransferPlan<DataItemType>::Kind::Migration;
//
// // search for the remaining data
// for(const auto& cur : info.getParts()) {
// // check whether this is a possible contributor
// auto overlap = intersect(rest,cur.region);
// if (overlap.empty()) continue;
//
// // add this piece
// res.addTransfer(requirement.ref, overlap, cur.location, targetLocation,kind);
//
// // consider this part done
// rest = difference(rest,overlap);
// }
//
// // that's it, not more to do
// return res;
//
// }
//
// };
//
// /**
// * A utility computing a transfer plan based on a given data distribution information,
// * a target location, a region to be targeted, and a desired access mode.
// *
// * @param info a summary of the data distribution state covering the provided region
// * @param targetLocation the location where the given region should be moved to
// * @param region the region to be moved
// * @param mode the intended access mode of the targeted region after the transfer
// */
// template<typename TransferPlanGenerator = SimpleTransferPlanGenerator, typename DataItemType>
// TransferPlan<DataItemType> buildPlan(const location_info<DataItemType>& info, hpx::id_type targetLocation, const data_item_requirement<DataItemType>& requirement) {
// // use the transfer plan generator policy as requested
// return TransferPlanGenerator()(info,targetLocation,requirement);
// }
//
//
// /**
// * A base class for cost models.
// */
// template<typename V>
// struct cost_model {
// using value_type = V;
// };
//
// /**
// * A simple cost model for data transfers simply counting the number of included
// * data transfers.
// */
// struct NumberOfTransfersCostModel : public cost_model<std::size_t> {
//
// template<typename DataItemType>
// std::size_t evaluate(const TransferPlan<DataItemType>& plan) {
// return plan.getTransfers().size();
// }
//
// };
// /**
// * A generalized interface for evaluating the costs of a data transfer plan.
// */
// template<typename CostModel = NumberOfTransfersCostModel, typename DataItemType>
// typename CostModel::value_type estimateTransfereCosts(const TransferPlan<DataItemType>& plan) {
// return CostModel().evaluate(plan);
// }
}
#endif