Debian Codegraph @

dune/uggrid/parallel/ddd/dddcontext.hh

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 #ifndef DUNE_UGGRID_PARALLEL_DDD_DDDCONTEXT_HH
4 #define DUNE_UGGRID_PARALLEL_DDD_DDDCONTEXT_HH 1
5
6 #include <memory>
7 #include <vector>
8 #include <array>
9
10 #include <dune/uggrid/parallel/ddd/dddconstants.hh>
11 #include <dune/uggrid/parallel/ddd/dddtypes.hh>
12 #include <dune/uggrid/parallel/ddd/dddtypes_impl.hh>
13 #include <dune/uggrid/parallel/ppif/ppiftypes.hh>
14
15 namespace DDD {
16
17 namespace Basic {
18
19 struct LowCommContext
20 {
21 MSG_TYPE *MsgTypes = nullptr;
22 MSG_DESC *SendQueue = nullptr;
23 MSG_DESC *RecvQueue = nullptr;
24 int nSends = 0;
25 int nRecvs = 0;
26 char *theRecvBuffer;
27 LC_MSGHANDLE *theRecvArray = nullptr;
28 MSG_DESC *FreeMsgDescs = nullptr;
29
30 AllocFunc DefaultAlloc, SendAlloc, RecvAlloc;
31 FreeFunc DefaultFree, SendFree, RecvFree;
32 };
33
34 struct NotifyContext
35 {
36 std::vector<NOTIFY_INFO> allInfoBuffer;
37 std::vector<NOTIFY_DESC> theDescs;
38 std::vector<int> theRouting;
39 int maxInfos;
40 int lastInfo;
41 int nSendDescs;
42 };
43
44 struct TopoContext
45 {
46 std::vector<PPIF::VChannelPtr> theTopology;
47 std::vector<DDD_PROC> theProcArray;
48 };
49
50 } /* namespace Basic */
51
52 namespace Ctrl {
53
54 struct ConsContext
55 {
56 Basic::LC_MSGTYPE consmsg_t;
57 Basic::LC_MSGCOMP constab_id;
58 };
59
60 } /* namespace Ctrl */
61
62 namespace Ident {
63
64 struct IdentContext
65 {
66 ID_PLIST* thePLists;
67 int cntIdents;
68 int nPLists;
69 IdentMode identMode;
70 };
71
72 } /* namespace Ident */
73
74 namespace If {
75
76 struct IfCreateContext
77 {
78 IF_DEF theIf[MAX_IF];
79 int nIfs;
80 };
81
82 struct IfUseContext
83 {
84 int send_mesgs;
85 };
86
87 } /* namespace If */
88
89 namespace Join {
90
91 struct JoinContext
92 {
93 /** mode of join module */
94 JoinMode joinMode;
95
96 /* description for phase1 message */
97 Basic::LC_MSGTYPE phase1msg_t;
98 Basic::LC_MSGCOMP jointab_id;
99
100 /* description for phase2 message */
101 Basic::LC_MSGTYPE phase2msg_t;
102 Basic::LC_MSGCOMP addtab_id;
103
104 /* description for phase3 message */
105 Basic::LC_MSGTYPE phase3msg_t;
106 Basic::LC_MSGCOMP cpltab_id;
107
108 /* entry points for global sets */
109 JIJoinSet *setJIJoin;
110 JIAddCplSet *setJIAddCpl2;
111 JIAddCplSet *setJIAddCpl3;
112 };
113
114 } /* namespace Join */
115
116 namespace Mgr {
117
118 struct CplmgrContext
119 {
120 CplSegm *segmCpl = nullptr;
121 COUPLING *memlistCpl = nullptr;
122 int *localIBuffer;
123 int nCplSegms;
124 };
125
126 struct ObjmgrContext
127 {
128 DDD_GID theIdCount;
129 };
130
131 struct TypemgrContext
132 {
133 int nDescr;
134 };
135
136 } /* namespace Mgr */
137
138 namespace Prio {
139
140 struct PrioContext
141 {
142 PrioMode prioMode;
143 };
144
145 } /* namespace Prio */
146
147 namespace Xfer {
148
149 struct CmdmsgContext
150 {
151 Basic::LC_MSGTYPE cmdmsg_t;
152 Basic::LC_MSGCOMP undelete_id;
153 };
154
155 struct CplmsgContext
156 {
157 Basic::LC_MSGTYPE cplmsg_t;
158 Basic::LC_MSGCOMP delcpl_id;
159 Basic::LC_MSGCOMP modcpl_id;
160 Basic::LC_MSGCOMP addcpl_id;
161 };
162
163 /**
164 * global data for xfer module
165 */
166 struct XferContext
167 {
168 /** mode of xfer module */
169 XferMode xferMode;
170
171 /* description for object message */
172 Basic::LC_MSGTYPE objmsg_t;
173 Basic::LC_MSGCOMP symtab_id, objtab_id;
174 Basic::LC_MSGCOMP newcpl_id, oldcpl_id;
175 Basic::LC_MSGCOMP objmem_id;
176
177
178 /* entry points for global sets */
179 XICopyObjSet *setXICopyObj;
180 XISetPrioSet *setXISetPrio;
181
182 XICopyObj* theXIAddData;
183
184 AddDataSegm* segmAddData = nullptr;
185 SizesSegm* segmSizes = nullptr;
186
187 #define SLL_MEMBERS(T) Segm##T* segms##T; T* list##T; int n##T;
188 SLL_MEMBERS(XIDelCmd)
189 SLL_MEMBERS(XIDelObj)
190 SLL_MEMBERS(XINewCpl)
191 SLL_MEMBERS(XIOldCpl)
192 SLL_MEMBERS(XIAddCpl)
193 SLL_MEMBERS(XIDelCpl)
194 SLL_MEMBERS(XIModCpl)
195 #undef SLL_MEMBERS
196 };
197
198 } /* namespace Xfer */
199
200 struct CouplingContext
201 {
202 std::vector<COUPLING*> cplTable;
203 std::vector<short> nCplTable;
204
205 /** number of coupling lists */
206 int nCpls;
207
208 /* number of couplings */
209 int nCplItems;
210 };
211
212 class DDDContext {
213 public:
214 DDDContext(const std::shared_ptr<PPIF::PPIFContext>& ppifContext, const std::shared_ptr<void>& data);
215
216 const PPIF::PPIFContext& ppifContext() const
217 { return *ppifContext_; }
218
219 PPIF::PPIFContext& ppifContext()
220 { return *ppifContext_; }
221
222 /**
223 * \see PPIF::PPIFContext::me()
224 */
225 int me() const;
226
227 /**
228 * \see PPIF::PPIFContext::procs()
229 */
230 int procs() const;
231
232 /**
233 * \see PPIF::PPIFContext::isMaster()
234 */
235 bool isMaster() const;
236
237 /**
238 * return pointer to user data
239 */
240 void* data()
241 { return data_.get(); }
242
243 /**
244 * return const pointer to user data
245 */
246 const void* data() const
247 { return data_.get(); }
248
249 Basic::LowCommContext& lowCommContext()
250 { return lowCommContext_; }
251
252 const Basic::LowCommContext& lowCommContext() const
253 { return lowCommContext_; }
254
255 Basic::NotifyContext& notifyContext()
256 { return notifyContext_; }
257
258 Basic::TopoContext& topoContext()
259 { return topoContext_; }
260
261 const Basic::TopoContext& topoContext() const
262 { return topoContext_; }
263
264 Ctrl::ConsContext& consContext()
265 { return consContext_; }
266
267 Ident::IdentContext& identContext()
268 { return identContext_; }
269
270 const Ident::IdentContext& identContext() const
271 { return identContext_; }
272
273 If::IfCreateContext& ifCreateContext()
274 { return ifCreateContext_; }
275
276 const If::IfCreateContext& ifCreateContext() const
277 { return ifCreateContext_; }
278
279 If::IfUseContext& ifUseContext()
280 { return ifUseContext_; }
281
282 Join::JoinContext& joinContext()
283 { return joinContext_; }
284
285 const Join::JoinContext& joinContext() const
286 { return joinContext_; }
287
288 Mgr::CplmgrContext& cplmgrContext()
289 { return cplmgrContext_; }
290
291 const Mgr::CplmgrContext& cplmgrContext() const
292 { return cplmgrContext_; }
293
294 Mgr::ObjmgrContext& objmgrContext()
295 { return objmgrContext_; }
296
297 Mgr::TypemgrContext& typemgrContext()
298 { return typemgrContext_; }
299
300 const Mgr::TypemgrContext& typemgrContext() const
301 { return typemgrContext_; }
302
303 Prio::PrioContext& prioContext()
304 { return prioContext_; }
305
306 const Prio::PrioContext& prioContext() const
307 { return prioContext_; }
308
309 Xfer::CmdmsgContext& cmdmsgContext()
310 { return cmdmsgContext_; }
311
312 const Xfer::CmdmsgContext& cmdmsgContext() const
313 { return cmdmsgContext_; }
314
315 Xfer::CplmsgContext& cplmsgContext()
316 { return cplmsgContext_; }
317
318 const Xfer::CplmsgContext& cplmsgContext() const
319 { return cplmsgContext_; }
320
321 Xfer::XferContext& xferContext()
322 { return xferContext_; }
323
324 const Xfer::XferContext& xferContext() const
325 { return xferContext_; }
326
327 CouplingContext& couplingContext()
328 { return couplingContext_; }
329
330 const CouplingContext& couplingContext() const
331 { return couplingContext_; }
332
333 const std::vector<DDD_HDR>& objTable() const
334 { return objTable_; }
335
336 std::vector<DDD_HDR>& objTable()
337 { return objTable_; }
338
339 int nObjs() const
340 { return nObjs_; }
341
342 void nObjs(int n)
343 { nObjs_ = n; }
344
345 std::array<TYPE_DESC, MAX_TYPEDESC>& typeDefs()
346 { return typeDefs_; }
347
348 const std::array<TYPE_DESC, MAX_TYPEDESC>& typeDefs() const
349 { return typeDefs_; }
350
351 std::array<int, OPT_END>& options()
352 { return options_; }
353
354 const std::array<int, OPT_END>& options() const
355 { return options_; }
356
357 protected:
358 std::shared_ptr<PPIF::PPIFContext> ppifContext_;
359 std::shared_ptr<void> data_;
360 Basic::LowCommContext lowCommContext_;
361 Basic::NotifyContext notifyContext_;
362 Basic::TopoContext topoContext_;
363 Ctrl::ConsContext consContext_;
364 Ident::IdentContext identContext_;
365 If::IfCreateContext ifCreateContext_;
366 If::IfUseContext ifUseContext_;
367 Join::JoinContext joinContext_;
368 Mgr::CplmgrContext cplmgrContext_;
369 Mgr::ObjmgrContext objmgrContext_;
370 Mgr::TypemgrContext typemgrContext_;
371 Prio::PrioContext prioContext_;
372 CouplingContext couplingContext_;
373 Xfer::CmdmsgContext cmdmsgContext_;
374 Xfer::CplmsgContext cplmsgContext_;
375 Xfer::XferContext xferContext_;
376
377 std::vector<DDD_HDR> objTable_;
378 int nObjs_;
379
380 std::array<TYPE_DESC, MAX_TYPEDESC> typeDefs_;
381
382 std::array<int, OPT_END> options_;
383 };
384
385 } /* namespace DDD */
386
387 #endif