1 #ifndef DUNE_UGGRID_PARALLEL_DDD_DDDTYPES_IMPL_HH 2 #define DUNE_UGGRID_PARALLEL_DDD_DDDTYPES_IMPL_HH 1 3 4 #include <memory> 5 #include <vector> 6 7 #include <dune/uggrid/parallel/ppif/ppiftypes.hh> 8 9 #include "dddconstants.hh" 10 #include "dddtypes.hh" 11 12 namespace DDD { 13 14 /** options for DDD_SetOption */ 15 enum DDD_OPTION { 16 OPT_IDENTIFY_MODE=0, ///< one of the IDMODE_xxx constants 17 18 OPT_WARNING_VARSIZE_OBJ=8, ///< warning on differing obj sizes 19 OPT_WARNING_SMALLSIZE, ///< warning on obj sizes smaller than declared 20 OPT_WARNING_PRIOCHANGE, ///< warning on inconsistency in prio-change 21 OPT_WARNING_DESTRUCT_HDR, ///< warning on inconsistency in HdrDestructor 22 OPT_WARNING_REF_COLLISION, ///< warning on collision in reference-localize 23 OPT_WARNING_OLDSTYLE, ///< warning on usage of old-style ddd-funcs 24 25 OPT_QUIET_CONSCHECK=16, ///< do ConsCheck in a quiet manner 26 OPT_DEBUG_XFERMESGS, ///< print debug info for xfer messages 27 OPT_INFO_XFER, ///< display some statistical info during xfer 28 OPT_INFO_JOIN, ///< display some statistical info during join 29 OPT_INFO_IF_WITH_ATTR, ///< display interfaces detailed (with attrs) 30 31 OPT_XFER_PRUNE_DELETE, ///< prune del-cmd in del/xfercopy-combination 32 33 OPT_IF_REUSE_BUFFERS, ///< reuse interface buffs as long as possible 34 OPT_IF_CREATE_EXPLICIT, ///< dont (re-)create interfaces automatically 35 36 OPT_CPLMGR_USE_FREELIST, ///< use freelist for coupling-memory (default) 37 38 OPT_END 39 }; 40 41 /** 42 * \brief DDD object header, include this into all parallel object structures 43 * 44 * Some remarks: 45 * 46 * - don't touch the member elements of DDD_HEADER in the 47 * application program, they will be changed in further 48 * DDD versions! 49 * 50 * - use DDD functional interface for accessing the header fields; 51 * elements which are not accessible via the DDD functional interface 52 * should not be accessed by the application program anyway, 53 */ 54 struct DDD_HEADER 55 { 56 /* control word elements */ 57 unsigned char typ; 58 unsigned char prio; 59 unsigned char attr; 60 unsigned char flags; 61 62 /** global object array index */ 63 unsigned int myIndex; 64 65 /** global id */ 66 DDD_GID gid; 67 68 /* 4 unused bytes in current impl. */ 69 char empty[4]; 70 }; 71 72 73 /** 74 * \brief record for coupling of local object with foreign objects 75 */ 76 struct COUPLING 77 { 78 COUPLING* _next; 79 unsigned short _proc; 80 unsigned char prio; 81 unsigned char _flags; 82 DDD_HDR obj; 83 }; 84 85 /** 86 * \brief description of one element in DDD object structure description 87 * 88 * \todo in CPP_FRONTEND only one of the versions for C_FRONTEND and 89 * F_FRONTEND is needed, depending on setting of desc->storage. 90 * this should be a union for memory efficiency reasons. 91 */ 92 struct ELEM_DESC 93 { 94 /** element offset from object address */ 95 int offset; 96 97 /** gbits array, if type==EL_GBITS */ 98 std::unique_ptr<unsigned char[]> gbits; 99 100 /** size of this element */ 101 std::size_t size; 102 103 /** type of element, one of EL_xxx */ 104 int type; 105 106 /* if type==EL_OBJPTR, the following entries will be used: */ 107 108 /** DDD_TYPE of ref. destination */ 109 DDD_TYPE _reftype; 110 111 /* if reftype==DDD_TYPE_BY_HANDLER, we must use a handler for 112 * determining the reftype on-the-fly (additional parameter during 113 * TypeDefine with EL_OBJPTR) 114 */ 115 HandlerGetRefType reftypeHandler; 116 }; 117 118 119 /** 120 * \brief single DDD object structure description 121 */ 122 struct TYPE_DESC 123 { 124 /** current TypeMode (DECLARE/DEFINE) */ 125 int mode; 126 127 /** textual object description */ 128 const char* name; 129 130 /** number of current call to TypeDefine */ 131 int currTypeDefCall; 132 133 /* if C_FRONTEND or (CPP_FRONTEND and storage==STORAGE_STRUCT): */ 134 135 /** flag: real ddd type (with header)? */ 136 bool hasHeader; 137 138 /** offset of header from begin of obj */ 139 int offsetHeader; 140 141 /** max. number of elements per TYPE_DESC */ 142 static const int MAX_ELEMDESC = 64; 143 144 /** element description array */ 145 ELEM_DESC element[MAX_ELEMDESC]; 146 147 /** number of elements in object */ 148 int nElements; 149 150 /** size of object, correctly aligned */ 151 std::size_t size; 152 153 /* pointer to handler functions: */ 154 155 HandlerLDATACONSTRUCTOR handlerLDATACONSTRUCTOR; 156 HandlerDESTRUCTOR handlerDESTRUCTOR; 157 HandlerDELETE handlerDELETE; 158 HandlerUPDATE handlerUPDATE; 159 HandlerOBJMKCONS handlerOBJMKCONS; 160 HandlerSETPRIORITY handlerSETPRIORITY; 161 HandlerXFERCOPY handlerXFERCOPY; 162 HandlerXFERDELETE handlerXFERDELETE; 163 HandlerXFERGATHER handlerXFERGATHER; 164 HandlerXFERSCATTER handlerXFERSCATTER; 165 HandlerXFERGATHERX handlerXFERGATHERX; 166 HandlerXFERSCATTERX handlerXFERSCATTERX; 167 HandlerXFERCOPYMANIP handlerXFERCOPYMANIP; 168 169 170 /** 2D matrix for comparing priorities */ 171 std::unique_ptr<DDD_PRIO[]> prioMatrix; 172 173 /** default mode for PrioMerge */ 174 int prioDefault; 175 176 /* redundancy for efficiency: */ 177 178 /** number of outside references */ 179 int nPointers; 180 181 /** mask for fast type-dependent copy */ 182 std::unique_ptr<unsigned char[]> cmask; 183 }; 184 185 namespace Basic { 186 187 struct NOTIFY_DESC 188 { 189 DDD_PROC proc; 190 size_t size; 191 }; 192 193 enum class NotifyTypes : unsigned short 194 { 195 MYSELF, 196 KNOWN, 197 DUMMY, 198 UNKNOWN 199 }; 200 201 struct NOTIFY_INFO { 202 short from, to; /* source and destination processor */ 203 NotifyTypes flag; /* one of NotifyTypes */ 204 size_t size; /* message size */ 205 }; 206 207 } /* namespace Basic */ 208 209 namespace If { 210 211 using IFObjPtr = DDD_OBJ; 212 213 /** 214 * single part of interface, all couplings have same attr 215 */ 216 struct IF_ATTR 217 { 218 IF_ATTR* next = nullptr; 219 220 /* note: the cplXX resp. objXX arrays are NOT contiguous in memory */ 221 COUPLING **cplAB = nullptr, **cplBA = nullptr, **cplABA = nullptr; 222 /* object shortcut */ 223 IFObjPtr *objAB, *objBA, *objABA; 224 int nItems = 0; 225 int nAB = 0; 226 int nBA = 0; 227 int nABA = 0; 228 DDD_ATTR attr; 229 IF_ATTRDDD::If::IF_ATTR230 explicit IF_ATTR(DDD_ATTR attr) 231 : attr(attr) 232 { /* Nothing */ } 233 }; 234 235 /** 236 * descriptor of message and its contents/buffers for IF-communic. 237 */ 238 struct IF_PROC 239 { 240 IF_PROC* next; 241 IF_ATTR *ifAttr; 242 int nAttrs; 243 244 /* note: the cplXX resp. objXX arrays ARE contiguous in memory */ 245 COUPLING **cpl, **cplAB = nullptr, **cplBA = nullptr, **cplABA = nullptr; 246 /* object shortcut */ 247 IFObjPtr *obj = nullptr, *objAB, *objBA, *objABA; 248 int nItems = 0, nAB = 0, nBA = 0, nABA = 0; 249 DDD_PROC proc; 250 251 PPIF::VChannelPtr vc; 252 PPIF::msgid msgIn; 253 PPIF::msgid msgOut; 254 std::vector<char> bufIn; 255 std::vector<char> bufOut; 256 }; 257 258 /** 259 * descriptor for one single interface 260 */ 261 struct IF_DEF 262 { 263 IF_PROC *ifHead = nullptr; 264 265 /** list of couplings belonging to interface */ 266 COUPLING **cpl = nullptr; 267 268 /** overall number of items in this interface */ 269 int nItems = 0; 270 271 /** shortcut: list of object addresses in interf */ 272 IFObjPtr *obj = nullptr; 273 274 /* flag: is obj-table valid? */ 275 bool objValid = false; 276 277 int nIfHeads = 0; 278 279 int nObjStruct; 280 int nPrioA; 281 int nPrioB; 282 DDD_TYPE O[16]; 283 DDD_PRIO A[16]; 284 DDD_PRIO B[16]; 285 286 /* data for efficiency tuning */ 287 int maskO; 288 289 /* data for nice user interaction */ 290 /** string for interface identification */ 291 char name[IF_NAMELEN+1]; 292 }; 293 294 } /* namespace If */ 295 296 namespace Mgr { 297 298 /** segment of Cpls */ 299 struct CplSegm 300 { 301 CplSegm *next; 302 int nItems; 303 304 COUPLING item[CPLSEGM_SIZE]; 305 }; 306 307 } /* namespace Mgr */ 308 309 } /* namespace DDD */ 310 311 #endif 312