Commit 3010d627 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Move id field from specific header entries to enclosing struct.

* This will enable functions in pio_interface later to be written
  without regard for header specifics.
parent 4c17a0cd
......@@ -35,11 +35,11 @@ cdiPioClientStreamOpen(const char *filename, const char *filemode,
case STAGE_TIMELOOP:
filename_len = strlen(filename);
xassert(filename_len > 0 && filename_len < MAXDATAFILENAME);
header.specific.funcCall
= (struct funcCallDesc){
.funcID = STREAMOPEN,
.funcArgs.newFile = { .fnamelen = (int)filename_len,
.filetype = filetype } };
header = (struct winHeaderEntry){
.id = STREAMOPEN,
.specific.funcCall.funcArgs.newFile
= { .fnamelen = (int)filename_len,
.filetype = filetype } };
pioBufferFuncCall(header, filename, filename_len + 1);
xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS: %s, filenamesz=%zu,"
" filename=%s, filetype=%d",
......@@ -68,10 +68,9 @@ cdiPioClientStreamDefVlist_(int streamID, int vlistID)
case STAGE_DEFINITION:
break;
case STAGE_TIMELOOP:
header.specific.funcCall
= (struct funcCallDesc){
.funcID = STREAMDEFVLIST,
.funcArgs.streamChange = { streamID, vlistID } };
header = (struct winHeaderEntry){
.id = STREAMDEFVLIST,
.specific.funcCall.funcArgs.streamChange = { streamID, vlistID } };
pioBufferFuncCall(header, NULL, 0);
xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS: %s, streamID=%d,"
" vlistID=%d", funcMap[(-1 - STREAMDEFVLIST)], streamID, vlistID);
......@@ -159,10 +158,10 @@ cdiPioClientStreamClose(stream_t *streamptr, int recordBufIsToBeDeleted)
case STAGE_DEFINITION:
break;
case STAGE_TIMELOOP:
header.specific.funcCall
= (struct funcCallDesc){
.funcID = STREAMCLOSE,
.funcArgs.streamChange = { streamptr->self, CDI_UNDEFID } };
header = (struct winHeaderEntry){
.id = STREAMCLOSE,
.specific.funcCall.funcArgs.streamChange
= { streamptr->self, CDI_UNDEFID } };
pioBufferFuncCall(header, NULL, 0);
xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS: %s, streamID=%d",
funcMap[-1 - STREAMCLOSE], streamptr->self);
......@@ -189,10 +188,9 @@ cdiPioClientStreamDefTimestep_(stream_t *streamptr, int tsID)
case STAGE_TIMELOOP:
position = 0;
taxisID = vlistInqTaxis(streamptr->vlistID);
header.specific.funcCall
= (struct funcCallDesc){
.funcID = STREAMDEFTIMESTEP,
.funcArgs.streamNewTimestep = { streamptr->self, tsID } };
header = (struct winHeaderEntry){
.id = STREAMDEFTIMESTEP,
.specific.funcCall.funcArgs.streamNewTimestep = { streamptr->self, tsID } };
commCalc = commInqCommCalc();
buf_size = reshResourceGetPackSize(taxisID, &taxisOps, &commCalc);
buf = xmalloc((size_t)buf_size);
......
......@@ -480,7 +480,7 @@ modelWinEnqueue(int collID,
struct winHeaderEntry *winDict
= (struct winHeaderEntry *)txWin[collID].buffer;
int targetEntry;
if (header.specific.dataRecord.streamID > 0)
if (header.id > 0)
{
targetEntry = (txWin[collID].dictDataUsed)++;
int offset = header.offset
......@@ -489,7 +489,7 @@ modelWinEnqueue(int collID,
memcpy(txWin[collID].buffer + offset, data, size);
txWin[collID].head = txWin[collID].buffer + offset + size;
}
else if (header.specific.partDesc.partDescMarker == PARTDESCMARKER)
else if (header.id == PARTDESCMARKER)
{
targetEntry = (txWin[collID].dictDataUsed)++;
Xt_uid uid = header.specific.partDesc.uid;
......@@ -497,8 +497,7 @@ modelWinEnqueue(int collID,
/* search if same uid entry has already been enqueued */
for (int entry = 2; entry < targetEntry; entry += 2)
{
xassert(winDict[entry].specific.partDesc.partDescMarker
== PARTDESCMARKER);
xassert(winDict[entry].id == PARTDESCMARKER);
if (winDict[entry].specific.partDesc.uid == uid)
{
offset = winDict[entry].offset;
......@@ -528,14 +527,14 @@ modelWinEnqueue(int collID,
else
{
targetEntry = txWin[collID].dictSize - ++(txWin[collID].dictRPCUsed);
if (header.specific.funcCall.funcID == STREAMOPEN)
if (header.id == STREAMOPEN)
{
header.offset
= (int)(txWin[collID].head - txWin[collID].buffer);
memcpy(txWin[collID].head, data, size);
txWin[collID].head += size;
}
else if (header.specific.funcCall.funcID == STREAMDEFTIMESTEP)
else if (header.id == STREAMDEFTIMESTEP)
{
header.offset
= (int)(txWin[collID].head - txWin[collID].buffer);
......@@ -569,12 +568,12 @@ pioBufferPartData(int streamID, int varID, const double *data,
xassert(chunk <= INT_MAX);
struct winHeaderEntry dataHeader
= { .specific.dataRecord = { streamID, varID, nmiss }, .offset = -1 };
= { .id = streamID, .specific.dataRecord = { varID, nmiss }, .offset = -1 };
modelWinEnqueue(collID, dataHeader, data, chunk * sizeof (data[0]));
{
struct winHeaderEntry partHeader
= { .specific.partDesc = { .partDescMarker = PARTDESCMARKER,
.uid = xt_idxlist_get_uid(partDesc) },
= { .id = PARTDESCMARKER,
.specific.partDesc = { .uid = xt_idxlist_get_uid(partDesc) },
.offset = 0 };
modelWinEnqueue(collID, partHeader, partDesc, 0);
}
......@@ -590,7 +589,7 @@ void pioBufferFuncCall(struct winHeaderEntry header,
int rankGlob = commInqRankGlob ();
int root = commInqRootGlob ();
int collID, nProcsColl = commInqNProcsColl ();
int funcID = header.specific.funcCall.funcID;
int funcID = header.id;
xassert(funcID >= MINFUNCID && funcID <= MAXFUNCID);
xdebug("%s, func: %s", "START", funcMap[(-1 - funcID)]);
......@@ -828,9 +827,9 @@ void pioWriteTimestep()
modelWinFlushBuffer ( collID );
}
struct winHeaderEntry header
= { .specific.headerSize
= { .sizeID = HEADERSIZEMARKER,
.numDataEntries = txWin[collID].dictDataUsed,
= { .id = HEADERSIZEMARKER,
.specific.headerSize
= { .numDataEntries = txWin[collID].dictDataUsed,
.numRPCEntries = txWin[collID].dictRPCUsed } };
struct winHeaderEntry *winDict
= (struct winHeaderEntry *)txWin[collID].buffer;
......
......@@ -37,17 +37,16 @@ extern const char * const funcMap[numRPCFuncs];
struct headerSize
{
int sizeID, numDataEntries, numRPCEntries;
int numDataEntries, numRPCEntries;
};
struct dataRecord
{
int streamID, varID, nmiss;
int varID, nmiss;
};
struct funcCallDesc
{
int funcID;
union funcArgs
{
struct
......@@ -69,12 +68,12 @@ struct funcCallDesc
* partDescMarker == PARTDESCMARKER, always. */
struct partDescRecord
{
int partDescMarker;
Xt_uid uid;
};
struct winHeaderEntry
{
int id;
union
{
struct headerSize headerSize;
......
......@@ -186,7 +186,7 @@ static void
readFuncCall(struct winHeaderEntry *header)
{
int root = commInqRootGlob ();
int funcID = header->specific.funcCall.funcID;
int funcID = header->id;
union funcArgs *funcArgs = &(header->specific.funcCall.funcArgs);
xassert(funcID >= MINFUNCID && funcID <= MAXFUNCID);
......@@ -272,7 +272,7 @@ gatherArray(int root, int nProcsModel, int headerIdx,
{
struct winHeaderEntry *winDict
= (struct winHeaderEntry *)rxWin[root].buffer;
int streamID = winDict[headerIdx].specific.dataRecord.streamID;
int streamID = winDict[headerIdx].id;
int varID = winDict[headerIdx].specific.dataRecord.varID;
int varShape[3] = { 0, 0, 0 };
cdiPioQueryVarDims(varShape, vlistID, varID);
......@@ -292,14 +292,14 @@ gatherArray(int root, int nProcsModel, int headerIdx,
struct dataRecord *dataHeader
= &((struct winHeaderEntry *)
rxWin[modelID].buffer)[headerIdx].specific.dataRecord;
struct partDescRecord *partHeader
= &((struct winHeaderEntry *)
rxWin[modelID].buffer)[headerIdx + 1].specific.partDesc;
int position =
((struct winHeaderEntry *)rxWin[modelID].buffer)[headerIdx + 1].offset;
xassert(namespaceAdaptKey2(dataHeader->streamID) == streamID
xassert(namespaceAdaptKey2(((struct winHeaderEntry *)
rxWin[modelID].buffer)[headerIdx].id)
== streamID
&& dataHeader->varID == varID
&& partHeader->partDescMarker == PARTDESCMARKER
&& ((struct winHeaderEntry *)
rxWin[modelID].buffer)[headerIdx + 1].id == PARTDESCMARKER
&& position > 0
&& ((size_t)position
>= sizeof (struct winHeaderEntry) * rxWin[modelID].dictSize)
......@@ -544,8 +544,8 @@ buildStreamMap(struct winHeaderEntry *winDict)
for (int headerIdx = 1; headerIdx < numDataEntries; headerIdx += 2)
{
int streamID
= winDict[headerIdx].specific.dataRecord.streamID
= namespaceAdaptKey2(winDict[headerIdx].specific.dataRecord.streamID);
= winDict[headerIdx].id
= namespaceAdaptKey2(winDict[headerIdx].id);
xassert(streamID > 0);
if (streamID != streamIDOld)
{
......@@ -612,7 +612,7 @@ static void readGetBuffers()
struct winHeaderEntry *winDict
= (struct winHeaderEntry *)rxWin[root].buffer;
xassert(winDict[0].specific.headerSize.sizeID == HEADERSIZEMARKER);
xassert(winDict[0].id == HEADERSIZEMARKER);
{
int dictSize = rxWin[root].dictSize,
firstNonRPCEntry = dictSize - winDict[0].specific.headerSize.numRPCEntries - 1,
......@@ -622,10 +622,8 @@ static void readGetBuffers()
headerIdx > firstNonRPCEntry;
--headerIdx)
{
struct funcCallDesc *header
= &(winDict[headerIdx].specific.funcCall);
xassert(header->funcID >= MINFUNCID
&& header->funcID <= MAXFUNCID);
xassert(winDict[headerIdx].id >= MINFUNCID
&& winDict[headerIdx].id <= MAXFUNCID);
++numFuncCalls;
readFuncCall(winDict + headerIdx);
}
......@@ -660,7 +658,7 @@ static void readGetBuffers()
for (headerIdx = map.entries[streamIdx].firstHeaderIdx;
headerIdx <= lastHeaderIdx;
headerIdx += 2)
if (streamID == winDict[headerIdx].specific.dataRecord.streamID)
if (streamID == winDict[headerIdx].id)
{
int varID = winDict[headerIdx].specific.dataRecord.varID;
int size = vlistInqVarSize(vlistID, varID);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment