Debian Codegraph @

dune/uggrid/parallel/ddd/xfer/xfer.h

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 /****************************************************************************/
6 /* */
7 /* File: xfer.h */
8 /* */
9 /* Purpose: header file for xfer module */
10 /* */
11 /* Author: Klaus Birken */
12 /* Rechenzentrum Uni Stuttgart */
13 /* Universitaet Stuttgart */
14 /* Allmandring 30 */
15 /* 70550 Stuttgart */
16 /* internet: [email protected] */
17 /* */
18 /* */
19 /* History: 931122 kb begin */
20 /* 950404 kb copied from dddi.h */
21 /* 960718 kb introduced lowcomm-layer (sets of messages) */
22 /* */
23 /* Remarks: */
24 /* */
25 /****************************************************************************/
26
27
28
29 /****************************************************************************/
30 /* */
31 /* auto include mechanism and other include files */
32 /* */
33 /****************************************************************************/
34
35 #ifndef __XFER_H__
36 #define __XFER_H__
37
38 #include <vector>
39
40 #define DebugXfer 10 /* 0 is all, 10 is off */
41 #define DebugPack 6 /* off: 6 */
42 #define DebugUnpack 5 /* off: 5 */
43 #define DebugCmdMsg 10 /* off: 10 */
44 #define DebugCplMsg 10 /* off: 10 */
45
46
47
48
49 #include <dune/uggrid/parallel/ddd/basic/lowcomm.h>
50 #include <dune/uggrid/parallel/ddd/basic/oopp.h> /* for object-orientated style via preprocessor */
51 #include "sll.h" /* TODO: remove this in future versions */
52
53 START_UGDIM_NAMESPACE
54
55 #define SUPPORT_RESENT_FLAG
56
57
58 /* define this to use as small types as possible. for debugging, try it
59 without this define */
60 #define SMALL_TYPES_BY_CASTS
61
62
63 /****************************************************************************/
64 /* */
65 /* defines in the following order */
66 /* */
67 /* compile time constants defining static data size (i.e. arrays) */
68 /* other constants */
69 /* macros */
70 /* */
71 /****************************************************************************/
72
73 /* some macros for customizing oopp */
74 #define _NEWPARAMS
75 #define _NEWPARAMS_OR_VOID void
76
77 #define __INDENT(n) { int i; for(i=0; i<n; i++) fputs(" ",fp);}
78 #define _PRINTPARAMS , int indent, FILE *fp
79 #define _PRINTPARAMS_DEFAULT ,0,stdout
80 #define _INDENT __INDENT(indent)
81 #define _INDENT1 __INDENT(indent+1)
82 #define _INDENT2 __INDENT(indent+2)
83 #define _PRINTNEXT , indent+1, fp
84 #define _PRINTSAME , indent, fp
85
86 /* map memory allocation calls */
87 #define OO_Allocate std::malloc
88 #define OO_Free std::free
89
90
91 /* extra prefix for all xfer-related data structures and/or typedefs */
92 /*#define ClassPrefix*/
93
94
95 /* types of 'newness' of incoming object (for xferunpack.c) */
96 enum XferNewType {
97 NOTNEW = 0x00, /* object is not new */
98 PARTNEW = 0x01, /* object has been updated partially */
99 PRUNEDNEW = 0x02, /* object is new due to PruneDel (see cmdmsg.c)*/
100 TOTALNEW = 0x04, /* object has been updated completely */
101 OTHERMSG = 0x08, /* object is taken from another message */
102 THISMSG = 0x10 /* object is taken from this msg, temp setting */
103 };
104
105 END_UGDIM_NAMESPACE
106 namespace DDD {
107 namespace Xfer {
108
109 /* overall mode of transfer */
110 enum class XferMode : unsigned char
111 {
112 XMODE_IDLE = 0, /* waiting for next DDD_XferBegin() */
113 XMODE_CMDS, /* after DDD_XferBegin(), before DDD_XferEnd() */
114 XMODE_BUSY /* during DDD_XferEnd() */
115 };
116
117 } /* namespace Xfer */
118 } /* namespace DDD */
119 START_UGDIM_NAMESPACE
120
121 using DDD::Xfer::XferMode;
122
123 END_UGDIM_NAMESPACE
124
125 /****************************************************************************/
126
127 #ifdef SMALL_TYPES_BY_CASTS
128 #define DDD_PRIO_SMALL unsigned char
129 #define DDD_TYPE_SMALL unsigned char
130 #else
131 #define DDD_PRIO_SMALL DDD_PRIO
132 #define DDD_TYPE_SMALL DDD_TYPE
133 #endif
134
135
136 /****************************************************************************/
137 /* */
138 /* data structures exported by the corresponding source file */
139 /* */
140 /****************************************************************************/
141
142 namespace DDD {
143 namespace Xfer {
144
145 /****************************************************************************/
146 /* XFERADDDATA: description of additional data on sender side */
147 /****************************************************************************/
148
149 struct XFERADDDATA {
150 int addCnt;
151 DDD_TYPE addTyp;
152 int addLen; /* length of additional data */
153 int addNPointers;
154 int *sizes;
155
156 XFERADDDATA* next;
157 };
158
159
160 /****************************************************************************/
161 /* XICopyObj: */
162 /****************************************************************************/
163
164 struct XICopyObj
165 {
166 DDD_HDR hdr; /* local obj for which a copy should be created */
167 DDD_GID gid; /* gid of local object */
168 DDD_PROC dest; /* proc involved with operation, me -> proc */
169 DDD_PRIO prio; /* priority for new object copy */
170 size_t size; /* V1.2: needed for variable-sized objects */
171
172 int addLen;
173 XFERADDDATA *add; /* additional data items */
174
175 int flags;
176 };
177
178 } /* namespace Xfer */
179 } /* namespace DDD */
180
181 START_UGDIM_NAMESPACE
182
183 using DDD::Xfer::XFERADDDATA;
184 using DDD::Xfer::XICopyObj;
185
186 #define ClassName XICopyObj
187 void Method(Print) (DefThis _PRINTPARAMS);
188 int Method(Compare) (ClassPtr, ClassPtr, const DDD::DDDContext* context);
189 #undef ClassName
190
191
192 /* define container class */
193 #ifndef SetOf /* necessary for inline documentation only */
194 #define SetOf XICopyObj
195 #define Set_SegmSize 256
196 #define Set_BTreeOrder 32
197 #endif
198 #include <dune/uggrid/parallel/ddd/basic/ooppcc.h>
199
200
201 /* usage of flags in XICopyObj */
202 /* usage of 0x01 while PruneXIDelCpl, temporarily */
203 #define MASK_CO_SELF 0x00000001
204 #define CO_SELF(c) (((int)((c)->flags))&MASK_CO_SELF)
205 #define SET_CO_SELF(c,d) ((c)->flags) = \
206 ((((c)->flags)&(~MASK_CO_SELF)) | ((d)&MASK_CO_SELF))
207
208 /* usage of 0x02 for new_owner:
209 did destination proc know the object's gid before? */
210 #define MASK_CO_NEWOWNER 0x00000002
211 #define CO_NEWOWNER(c) (((int)((c)->flags))&MASK_CO_NEWOWNER)
212 #define SET_CO_NEWOWNER(c) ((c)->flags) = (((c)->flags) | MASK_CO_NEWOWNER)
213 #define CLEAR_CO_NEWOWNER(c) ((c)->flags) = (((c)->flags)&(~MASK_CO_NEWOWNER))
214
215
216
217 /****************************************************************************/
218 /* XIDelObj: */
219 /****************************************************************************/
220
221 /* XIDelCmd represents a XferDeleteObj-cmd by the application program */
222 struct XIDelCmd
223 {
224 SLL_INFO_WITH_COUNTER(XIDelCmd);
225 DDD_HDR hdr;
226 };
227
228 /* include template */
229 #define T XIDelCmd
230 #define SLL_WithOrigOrder
231 #include "sll.ht"
232 #undef T
233
234
235 struct XIDelCpl;
236
237 /* XIDelObj represents an object-delete-action (cf. XferRegisterDelete()) */
238 struct XIDelObj
239 {
240 SLL_INFO(XIDelObj);
241 DDD_GID gid; /* gid of local object */
242
243 /* hdr is explicitly not stored here, because object may be deleted
244 when this XIDelObj-item is evaluated. */
245
246 XIDelCpl *delcpls; /* couplings of deleted object */
247
248 };
249
250 /* include template */
251 #define T XIDelObj
252 #include "sll.ht"
253 #undef T
254
255
256
257 /****************************************************************************/
258 /* XISetPrio: */
259 /****************************************************************************/
260
261 #define ClassName XISetPrio
262 Class_Data_Begin
263 DDD_HDR hdr; /* local obj for which prio should be set */
264 DDD_GID gid; /* gid of local object */
265 DDD_PRIO prio; /* new priority */
266
267 int is_valid; /* invalid iff there's a DelObj for same gid */
268 Class_Data_End
269 void Method(Print) (DefThis _PRINTPARAMS);
270 int Method(Compare) (ClassPtr, ClassPtr, const DDD::DDDContext*);
271
272 #undef ClassName
273
274
275 /* define container class */
276 #ifndef SetOf /* necessary for inline documentation only */
277 #define SetOf XISetPrio
278 #define Set_SegmSize 256
279 #define Set_BTreeOrder 32
280 #endif
281 #include <dune/uggrid/parallel/ddd/basic/ooppcc.h>
282
283
284 /****************************************************************************/
285 /* XINewCpl: */
286 /****************************************************************************/
287
288 struct TENewCpl
289 {
290 DDD_GID _gid; /* obj-gid for which new copy will be created */
291 DDD_PROC _dest; /* destination of new object copy */
292
293 DDD_PRIO_SMALL _prio; /* priority of new object copy */
294 DDD_TYPE_SMALL _type; /* ddd-type of gid for PriorityMerge on receiver*/
295 };
296
297 #define NewCpl_GetGid(i) ((i)._gid)
298 #define NewCpl_SetGid(i,d) ((i)._gid = (d))
299 #define NewCpl_GetDest(i) ((i)._dest)
300 #define NewCpl_SetDest(i,d) ((i)._dest = (d))
301
302 #ifdef SMALL_TYPES_BY_CASTS
303 #define NewCpl_GetPrio(i) ((DDD_PRIO)(i)._prio)
304 #define NewCpl_SetPrio(i,d) ((i)._prio = (DDD_PRIO_SMALL)(d))
305 #define NewCpl_GetType(i) ((DDD_TYPE)(i)._type)
306 #define NewCpl_SetType(i,d) ((i)._type = (DDD_TYPE_SMALL)(d))
307 #else
308 #define NewCpl_GetPrio(i) ((i)._prio)
309 #define NewCpl_SetPrio(i,d) ((i)._prio = (d))
310 #define NewCpl_GetType(i) ((i)._type)
311 #define NewCpl_SetType(i,d) ((i)._type = (d))
312 #endif
313
314
315 struct XINewCpl
316 {
317 SLL_INFO(XINewCpl);
318 DDD_PROC to; /* receiver of this item */
319 TENewCpl te; /* table entry (for message) */
320
321 };
322
323 /* include template */
324 #define T XINewCpl
325 #include "sll.ht"
326 #undef T
327
328
329
330 /****************************************************************************/
331 /* XIOldCpl: */
332 /****************************************************************************/
333
334 struct TEOldCpl
335 {
336 DDD_GID gid; /* obj-gid of local copy */
337 DDD_PROC proc; /* owner of that local object */
338 DDD_PRIO prio; /* priority of that local object */
339 };
340
341
342 struct XIOldCpl
343 {
344 SLL_INFO(XIOldCpl);
345 DDD_PROC to; /* receiver of this item */
346 TEOldCpl te; /* table entry (for message) */
347 };
348
349 /* include template */
350 #define T XIOldCpl
351 #include "sll.ht"
352 #undef T
353
354
355 /****************************************************************************/
356 /* XIAddCpl: */
357 /****************************************************************************/
358
359 struct TEAddCpl
360 {
361 DDD_GID gid; /* obj-gid of new local object */
362 DDD_PROC proc; /* owner of new object copy */
363 DDD_PRIO prio; /* priority of new local object */
364 };
365
366
367 struct XIAddCpl
368 {
369 SLL_INFO(XIAddCpl);
370 DDD_PROC to; /* receiver of this item */
371 TEAddCpl te; /* table entry (for message) */
372
373 };
374
375 /* include template */
376 #define T XIAddCpl
377 #include "sll.ht"
378 #undef T
379
380
381
382 /****************************************************************************/
383 /* XIDelCpl: */
384 /****************************************************************************/
385
386 struct TEDelCpl
387 {
388 DDD_GID gid; /* obj-gid of deleted local object */
389 };
390
391
392 struct XIDelCpl
393 {
394 SLL_INFO(XIDelCpl);
395 DDD_PROC to; /* receiver of this item */
396 TEDelCpl te; /* table entry (for message) */
397
398 DDD_PRIO prio; /* prio of deleted coupling */
399 XIDelCpl* next; /* linked list of XIDelCpls */
400 };
401
402 /* include template */
403 #define T XIDelCpl
404 #include "sll.ht"
405 #undef T
406
407
408
409
410 /****************************************************************************/
411 /* XIModCpl: */
412 /****************************************************************************/
413
414 struct TEModCpl
415 {
416 DDD_GID gid; /* obj-gid of corresponding object */
417 DDD_PRIO prio; /* new priority for this obj on sending proc */
418 };
419
420
421 struct XIModCpl
422 {
423 SLL_INFO(XIModCpl);
424 DDD_PROC to; /* receiver of this item */
425 TEModCpl te; /* table entry (for message) */
426
427 DDD_TYPE typ; /* type of corresponding object */
428 };
429
430 /* include template */
431 #define T XIModCpl
432 #include "sll.ht"
433 #undef T
434
435
436 /****************************************************************************/
437 /* XFERMSG: complete description about message on sender side */
438 /****************************************************************************/
439
440 struct XFERMSG
441 {
442 DDD_PROC proc; /* receiver of message */
443 size_t size; /* size of message data */
444
445 XFERMSG* next;
446
447
448 XICopyObjPtr *xferObjArray;
449 int nObjItems;
450
451 XINewCpl **xferNewCpl;
452 int nNewCpl;
453
454 XIOldCpl **xferOldCpl;
455 int nOldCpl;
456
457 int nPointers;
458 int nObjects;
459
460
461 /* lowcomm message handle */
462 LC_MSGHANDLE msg_h;
463 };
464
465
466
467
468 /****************************************************************************/
469 /* SYMTAB_ENTRY: single entry of symbol table inside message */
470 /****************************************************************************/
471
472
473 struct SYMTAB_ENTRY
474 {
475 DDD_GID gid;
476
477 union {
478 DDD_HDR hdr; /* used on receiver side only */
479 DDD_OBJ *ref; /* used on sender side only */
480 } adr; /* undefined during transfer */
481 };
482
483
484
485 /****************************************************************************/
486 /* OBJTAB_ENTRY: single entry of object table inside message */
487 /****************************************************************************/
488
489 struct OBJTAB_ENTRY
490 {
491
492 int h_offset; /* header offset from beginObjMem */
493
494 int addLen; /* length of additional data */
495 size_t size; /* size of object, ==desc->len for
496 fixed-sized objects */
497
498 DDD_HDR hdr; /* TODO this is probably not used on sender side */
499
500 /* TODO: the following data is only used on receiver side */
501 char is_new;
502 char oldprio;
503 };
504
505
506
507 /* NOTE: the following macros require the DDD_HEADER being copied
508 directly into the message! (with its LDATA!) */
509
510 #define OTE_HDR(objmem,ote) ((DDD_HDR)(((char *)(objmem))+((ote)->h_offset)))
511 #define OTE_OBJ(context, objmem,ote) OBJ_OBJ(context, OTE_HDR(objmem,ote))
512 #define OTE_GID(objmem,ote) OBJ_GID(OTE_HDR(objmem,ote))
513 #define OTE_PRIO(objmem,ote) OBJ_PRIO(OTE_HDR(objmem,ote))
514 #define OTE_TYPE(objmem,ote) OBJ_TYPE(OTE_HDR(objmem,ote))
515 #define OTE_ATTR(objmem,ote) OBJ_ATTR(OTE_HDR(objmem,ote))
516
517 #define OTE_GID_FMT OBJ_GID_FMT
518
519
520
521 /****************************************************************************/
522 /* DELTAB_ENTRY: single entry of deletion table inside message */
523 /****************************************************************************/
524
525 struct DELTAB_ENTRY {
526 DDD_GID gid;
527 DDD_PROC proc;
528 };
529
530
531 /****************************************************************************/
532 /* XFER_PER_PROC: data needed on a per-proc basis during xfer */
533 /****************************************************************************/
534
535 struct XFER_PER_PROC
536 {
537 int dummy; /* not used yet */
538 };
539
540
541 /****************************************************************************/
542 /* */
543 /* function declarations */
544 /* */
545 /****************************************************************************/
546
547
548 /* supp.c */
549 XFERADDDATA *NewXIAddData(DDD::DDDContext& context);
550 void FreeAllXIAddData(DDD::DDDContext& context);
551 int *AddDataAllocSizes(DDD::DDDContext& context, int);
552 /* and others, via template mechanism */
553
554
555
556 /* cplmsg.c */
557 void CommunicateCplMsgs (DDD::DDDContext& context,
558 XIDelCpl **, int,
559 XIModCpl **, int, XIAddCpl **, int, DDD_HDR *, int);
560 void CplMsgInit(DDD::DDDContext& context);
561 void CplMsgExit(DDD::DDDContext& context);
562
563
564 /* cmdmsg.c */
565 int PruneXIDelCmd (DDD::DDDContext& context, XIDelCmd **, int, const std::vector<XICopyObj*>&);
566 void CmdMsgInit(DDD::DDDContext& context);
567 void CmdMsgExit(DDD::DDDContext& context);
568
569
570 /* xfer.c, used only by cmds.c */
571 XICopyObj **CplClosureEstimate(DDD::DDDContext& context, const std::vector<XICopyObj*>&, int *);
572 int PrepareObjMsgs(DDD::DDDContext& context,
573 std::vector<XICopyObj*>&, XINewCpl **, int,
574 XIOldCpl **, int, XFERMSG **, size_t *);
575 void ExecLocalXIDelCmd(DDD::DDDContext& context, XIDelCmd **, int);
576 void ExecLocalXISetPrio(DDD::DDDContext& context, const std::vector<XISetPrio*>&, XIDelObj **,int, XICopyObj **,int);
577 void ExecLocalXIDelObj(DDD::DDDContext& context, XIDelObj **, int, XICopyObj **,int);
578 void PropagateCplInfos(DDD::DDDContext& context,
579 XISetPrio **, int, XIDelObj **, int,
580 TENewCpl *, int);
581 enum XferMode XferMode (const DDD::DDDContext& context);
582 int XferStepMode(DDD::DDDContext& context, enum XferMode);
583
584
585 /* pack.c, used only by cmds.c */
586 RETCODE XferPackMsgs (DDD::DDDContext& context, XFERMSG *);
587
588
589 /* unpack.c, used only by cmds.c */
590 void XferUnpack (DDD::DDDContext& context, LC_MSGHANDLE *, int, const DDD_HDR *, int,
591 std::vector<XISetPrio*>&, XIDelObj **, int,
592 const std::vector<XICopyObj*>&, XICopyObj **, int);
593
594
595 /* ctrl.c */
596 void XferDisplayMsg(DDD::DDDContext& context, const char *comment, LC_MSGHANDLE);
597
598 END_UGDIM_NAMESPACE
599
600 #endif