| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: ctrl.c */ |
| 8 |
/* */ |
| 9 |
/* Purpose: controls and displays messages, for debugging only */ |
| 10 |
/* */ |
| 11 |
/* Author: Klaus Birken */ |
| 12 |
/* Rechenzentrum Uni Stuttgart */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Allmandring 30 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* internet: [email protected] */ |
| 17 |
/* */ |
| 18 |
/* History: 94/02/16 kb begin */ |
| 19 |
/* 960718 kb introduced lowcomm-layer (sets of messages) */ |
| 20 |
/* */ |
| 21 |
/* Remarks: */ |
| 22 |
/* */ |
| 23 |
/****************************************************************************/ |
| 24 |
|
| 25 |
/****************************************************************************/ |
| 26 |
/* */ |
| 27 |
/* include files */ |
| 28 |
/* system include files */ |
| 29 |
/* application include files */ |
| 30 |
/* */ |
| 31 |
/****************************************************************************/ |
| 32 |
|
| 33 |
/* standard C library */ |
| 34 |
#include <config.h> |
| 35 |
#include <cstdlib> |
| 36 |
#include <cstdio> |
| 37 |
#include <sstream> |
| 38 |
|
| 39 |
#include <iomanip> |
| 40 |
#include <iostream> |
| 41 |
|
| 42 |
#include <dune/uggrid/parallel/ddd/dddi.h> |
| 43 |
#include "xfer.h" |
| 44 |
|
| 45 |
using namespace PPIF; |
| 46 |
|
| 47 |
START_UGDIM_NAMESPACE |
| 48 |
|
| 49 |
/* #define DebugAllPointers */ |
| 50 |
|
| 51 |
|
| 52 |
/****************************************************************************/ |
| 53 |
/* */ |
| 54 |
/* definition of static variables */ |
| 55 |
/* */ |
| 56 |
/****************************************************************************/ |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
/****************************************************************************/ |
| 62 |
/* */ |
| 63 |
/* routines */ |
| 64 |
/* */ |
| 65 |
/****************************************************************************/ |
| 66 |
|
| 67 |
|
| 68 |
#ifdef DebugAllPointers |
| 69 |
|
| 70 |
static void XferPtr (DDD::DDDContext& context, LC_MSGHANDLE xm, const std::string& prefix, std::ostream& out) |
| 71 |
{ |
| 72 |
SYMTAB_ENTRY *theSymTab; |
| 73 |
OBJTAB_ENTRY *theObjTab; |
| 74 |
char *theObjects; |
| 75 |
int i; |
| 76 |
int lenSymTab = (int) LC_GetTableLen(xm, ctx.symtab_id); |
| 77 |
int lenObjTab = (int) LC_GetTableLen(xm, ctx.objtab_id); |
| 78 |
|
| 79 |
|
| 80 |
/* get table addresses inside message buffer */ |
| 81 |
theSymTab = (SYMTAB_ENTRY *) LC_GetPtr(xm, ctx.symtab_id); |
| 82 |
theObjTab = (OBJTAB_ENTRY *) LC_GetPtr(xm, ctx.objtab_id); |
| 83 |
theObjects = (char *) LC_GetPtr(xm, ctx.objmem_id); |
| 84 |
|
| 85 |
|
| 86 |
/* build symbol table */ |
| 87 |
for(i=0; i<lenObjTab; i++) /* for all objects in message */ |
| 88 |
{ |
| 89 |
DDD_HDR hdr = (DDD_HDR)(theObjects+theObjTab[i].offset); |
| 90 |
const TYPE_DESC& desc = context.typeDefs()[OBJ_TYPE(hdr)]; |
| 91 |
DDD_OBJ obj = HDR2OBJ(hdr, &desc); |
| 92 |
const ELEM_DESC* theElem = desc.element; |
| 93 |
|
| 94 |
/* loop over all pointers inside of object with DDD_HEADER hdr */ |
| 95 |
for(int e=0; e < desc.nElements; ++e, ++theElem) |
| 96 |
{ |
| 97 |
if (theElem->type != EL_OBJPTR) |
| 98 |
continue; |
| 99 |
|
| 100 |
for(int l=0; l<theElem->size; l+=sizeof(void *)) |
| 101 |
{ |
| 102 |
/* ref points to a reference inside objmem */ |
| 103 |
DDD_OBJ *ref = (DDD_OBJ *)(((char *)obj)+theElem->offset+l); |
| 104 |
|
| 105 |
/* reference had been replaced by SymTab-index */ |
| 106 |
INT stIdx = ((int)*ref)-1; |
| 107 |
|
| 108 |
if (stIdx < 0) |
| 109 |
continue; |
| 110 |
|
| 111 |
/* get corresponding symtab entry */ |
| 112 |
const SYMTAB_ENTRY *st = &(theSymTab[stIdx]); |
| 113 |
|
| 114 |
using std::dec; |
| 115 |
using std::hex; |
| 116 |
using std::setw; |
| 117 |
out << prefix << " 20 " |
| 118 |
<< " obj=" << setw(3) << theObjTab[i].offset << " " << setw(3) << stIdx |
| 119 |
<< hex |
| 120 |
<< " st=" << setw(8) << st << " gid=" << setw(8) << st->gid |
| 121 |
<< "(" << setw(x) << st->adr.hdr << "==" |
| 122 |
<< setw(8) << st->adr.ref << ")\n" |
| 123 |
<< dec; |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
#endif |
| 129 |
|
| 130 |
|
| 131 |
void XferDisplayMsg (DDD::DDDContext& context, const char *comment, LC_MSGHANDLE xm) |
| 132 |
{ |
| 133 |
using std::setw; |
| 134 |
|
| 135 |
std::ostream& out = std::cout; |
| 136 |
auto& ctx = context.xferContext(); |
| 137 |
SYMTAB_ENTRY *theSymTab; |
| 138 |
OBJTAB_ENTRY *theObjTab; |
| 139 |
TENewCpl *theNewCpl; |
| 140 |
TEOldCpl *theOldCpl; |
| 141 |
char *theObjects; |
| 142 |
int i, proc = LC_MsgGetProc(xm); |
| 143 |
int lenSymTab = (int) LC_GetTableLen(xm, ctx.symtab_id); |
| 144 |
int lenObjTab = (int) LC_GetTableLen(xm, ctx.objtab_id); |
| 145 |
int lenNewCpl = (int) LC_GetTableLen(xm, ctx.newcpl_id); |
| 146 |
int lenOldCpl = (int) LC_GetTableLen(xm, ctx.oldcpl_id); |
| 147 |
|
| 148 |
std::ostringstream prefixStream; |
| 149 |
prefixStream << " " << setw(3) << context.me() << "-" << comment |
| 150 |
<< "-" << setw(3) << proc << " "; |
| 151 |
const std::string& prefix = prefixStream.str(); |
| 152 |
|
| 153 |
/* get table addresses inside message */ |
| 154 |
theSymTab = (SYMTAB_ENTRY *)LC_GetPtr(xm, ctx.symtab_id); |
| 155 |
theObjTab = (OBJTAB_ENTRY *)LC_GetPtr(xm, ctx.objtab_id); |
| 156 |
theNewCpl = (TENewCpl *) LC_GetPtr(xm, ctx.newcpl_id); |
| 157 |
theOldCpl = (TEOldCpl *) LC_GetPtr(xm, ctx.oldcpl_id); |
| 158 |
theObjects= (char *)LC_GetPtr(xm, ctx.objmem_id); |
| 159 |
|
| 160 |
|
| 161 |
/* because of LC layer, this data can't be accessed anymore. KB 960718 |
| 162 |
sprintf(cBuffer, "%s 00 MsgBuf=%08x\n", buf, xmdata); |
| 163 |
DDD_PrintDebug(cBuffer); |
| 164 |
sprintf(cBuffer, "%s 00 SymTab %04d\n", buf, theHeader->beginSymTab); |
| 165 |
DDD_PrintDebug(cBuffer); |
| 166 |
sprintf(cBuffer, "%s 01 ObjTab %04d\n", buf, theHeader->beginObjTab); |
| 167 |
DDD_PrintDebug(cBuffer); |
| 168 |
sprintf(cBuffer, "%s 02 CplTab %04d\n", buf, theHeader->beginCplTab); |
| 169 |
DDD_PrintDebug(cBuffer); |
| 170 |
sprintf(cBuffer, "%s 03 DelTab %04d\n", buf, theHeader->beginDelTab); |
| 171 |
DDD_PrintDebug(cBuffer); |
| 172 |
sprintf(cBuffer, "%s 04 ObjMem %04d\n", buf, theHeader->beginObjMem); |
| 173 |
DDD_PrintDebug(cBuffer); |
| 174 |
*/ |
| 175 |
|
| 176 |
|
| 177 |
out << prefix << " 05 ObjTab.size=" << setw(5) << lenObjTab << "\n"; |
| 178 |
out << prefix << " 06 SymTab.size=" << setw(5) << lenSymTab << "\n"; |
| 179 |
out << prefix << " 07 NewCpl.size=" << setw(5) << lenNewCpl << "\n"; |
| 180 |
out << prefix << " 08 OldCpl.size=" << setw(5) << lenOldCpl << "\n"; |
| 181 |
|
| 182 |
for(i=0; i<lenObjTab; i++) |
| 183 |
{ |
| 184 |
DDD_OBJ obj = OTE_OBJ(context, theObjects, &(theObjTab[i])); |
| 185 |
|
| 186 |
out << prefix << " 10 objtab " << setw(6) << (((char *)obj)-theObjects) |
| 187 |
<< " typ=" << OTE_TYPE(theObjects,&(theObjTab[i])) |
| 188 |
<< " gid=" << OTE_GID(theObjects,&(theObjTab[i])) |
| 189 |
<< " hdr=" << theObjTab[i].hdr << " size=" << setw(5) << theObjTab[i].size |
| 190 |
<< " add=" << setw(5) << theObjTab[i].addLen << "\n"; |
| 191 |
} |
| 192 |
|
| 193 |
for(i=0; i<lenSymTab; i++) |
| 194 |
out << prefix << " 11 symtab " << setw(4) << i << " - " << theSymTab[i].gid |
| 195 |
<< " (" << setw(8) << theSymTab[i].adr.hdr << "==" |
| 196 |
<< theSymTab[i].adr.ref << ")\n"; |
| 197 |
|
| 198 |
for(i=0; i<lenNewCpl; i++) |
| 199 |
out << prefix << " 12 newcpl " << setw(4) << i << " - " |
| 200 |
<< NewCpl_GetGid(theNewCpl[i]) |
| 201 |
<< " " << setw(4) << NewCpl_GetDest(theNewCpl[i]) |
| 202 |
<< " " << setw(4) << NewCpl_GetPrio(theNewCpl[i]) << "\n"; |
| 203 |
|
| 204 |
for(i=0; i<lenOldCpl; i++) |
| 205 |
out << prefix << " 13 oldcpl " << setw(4) << i << " - " |
| 206 |
<< theOldCpl[i].gid |
| 207 |
<< " " << setw(4) << theOldCpl[i].proc |
| 208 |
<< " " << setw(4) << theOldCpl[i].prio << "\n"; |
| 209 |
|
| 210 |
# ifdef DebugAllPointers |
| 211 |
XferPtr(context, xm, prefix, out); |
| 212 |
# endif |
| 213 |
} |
| 214 |
|
| 215 |
END_UGDIM_NAMESPACE |