Commit 9e93f27a authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Align code structure of 1D- and 2D-decomposed tests.

parent f2782a95
......@@ -38,6 +38,7 @@ enum {
nproma = 16,
};
static void
modelRegionCompute(double region[], int nlev, int nlat, int nlon,
const int chunkStart[3], const int chunkSize[3],
......@@ -215,6 +216,18 @@ modelRun(struct model_config setup, MPI_Comm comm)
= (size_t)nlon * (size_t)nlat * (size_t)varDesc[varIdx].nlev;
#ifdef USE_MPI
{
for (size_t i = 0; i < varIdx; ++i)
if (varDesc[i].nlev == varLevs)
{
varDesc[varIdx].redist4gather = varDesc[i].redist4gather;
varDesc[varIdx].partDesc = varDesc[i].partDesc;
for (size_t j = 0; j < 2; ++j)
{
varDesc[varIdx].start[j] = varDesc[i].start[j];
varDesc[varIdx].chunkSize[j] = varDesc[i].chunkSize[j];
}
goto partDescriptionSet;
}
int start[2], chunkSize[3], varSize[2] = { nlon, nlat };
for (size_t i = 0; i < 2; ++i)
{
......@@ -231,13 +244,6 @@ modelRun(struct model_config setup, MPI_Comm comm)
Xt_int varSizeXt[3] = { (Xt_int)nlon, (Xt_int)nlat, (Xt_int)varLevs };
chunkSize[2] = varLevs;
Xt_int varStartXt[3] = { start[0], start[1], 0 };
for (size_t i = 0; i < varIdx; ++i)
if (varDesc[i].nlev == varLevs)
{
varDesc[varIdx].redist4gather = varDesc[i].redist4gather;
varDesc[varIdx].partDesc = varDesc[i].partDesc;
goto gatherRedistSet;
}
Xt_idxlist part_idxlist
= xt_idxsection_new(0, (varLevs > 1 ? 3 : 2), varSizeXt,
chunkSize, varStartXt),
......@@ -276,7 +282,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
Free(src_blocks);
xt_xmap_delete(xmap4gather);
}
gatherRedistSet: ;
partDescriptionSet: ;
}
#endif
varDesc[varIdx].code = GRIB_USERDEF + (int)varIdx;
......@@ -318,6 +324,14 @@ modelRun(struct model_config setup, MPI_Comm comm)
taxisDefVdate(taxisID, vdatetime[1]);
taxisDefVtime(taxisID, vdatetime[0]);
streamDefTimestep ( streamID, tsID );
if (setup.filetype == FILETYPE_EXT)
{
/* EXTRA doesn't store time, only date
* set the value to 0 before checksumming, because a
* time field of 0 is what reading an EXTRA file will
* return */
vdatetime[0] = 0;
}
for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
{
size_t varLevs = (size_t)varDesc[varIdx].nlev;
......
......@@ -183,17 +183,25 @@ modelRun(struct model_config setup, MPI_Comm comm)
= (size_t)nlon * (size_t)nlat * (size_t)varDesc[varIdx].nlev;
#ifdef USE_MPI
{
for (size_t i = 0; i < varIdx; ++i)
if (varDesc[i].nlev == varLevs)
{
varDesc[varIdx].partDesc = varDesc[i].partDesc;
varDesc[varIdx].start = varDesc[i].start;
varDesc[varIdx].chunkSize = varDesc[i].chunkSize;
goto partDescriptionSet;
}
struct PPM_extent range
= PPM_uniform_partition((struct PPM_extent){ 0,
(int32_t)varDesc[varIdx].size }, comm_size, rank);
int start = range.first;
int chunkSize = range.size;
Xt_idxlist idxlist
= xt_idxstripes_new(&(struct Xt_stripe){ .start = start,
.nstrides = chunkSize, .stride = 1 }, 1);
varDesc[varIdx].start = start;
varDesc[varIdx].chunkSize = chunkSize;
varDesc[varIdx].partDesc = idxlist;
varDesc[varIdx].partDesc
= xt_idxstripes_new(&(struct Xt_stripe){ .start = start,
.nstrides = chunkSize, .stride = 1 }, 1);
partDescriptionSet: ;
}
#endif
varDesc[varIdx].code = GRIB_USERDEF + (int)varIdx;
......@@ -247,23 +255,24 @@ modelRun(struct model_config setup, MPI_Comm comm)
{
#ifdef USE_MPI
int start = varDesc[varIdx].start;
int chunk = varDesc[varIdx].chunkSize;
size_t chunkSize = (size_t)varDesc[varIdx].chunkSize;
#else
int chunk = (int)varDesc[varIdx].size;
size_t chunkSize = varDesc[varIdx].size;
int start = 0;
#endif
if (varslice_size < (size_t)chunk)
if (varslice_size < chunkSize)
{
varslice = (double *)realloc(varslice, (size_t)chunk * sizeof (var[0]));
varslice_size = (size_t)chunk;
varslice = (double *)Realloc(varslice, chunkSize * sizeof (var[0]));
varslice_size = chunkSize;
}
modelRegionCompute(varslice, (size_t)start, (size_t)chunk,
modelRegionCompute(varslice, (size_t)start, chunkSize,
varDesc[varIdx].nlev, nlat, nlon,
tsID, lons, lats,
mscale, mrscale);
if (setup.compute_checksum)
{
#if USE_MPI
int chunk = (int)chunkSize;
xmpi(MPI_Gather(&chunk, 1, MPI_INT,
chunks, 1, MPI_INT, 0, comm));
if (rank == 0)
......@@ -272,7 +281,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
for (size_t i = 1; i < (size_t)comm_size; ++i)
displs[i] = displs[i - 1] + chunks[i - 1];
}
xmpi(MPI_Gatherv(varslice, chunk, MPI_DOUBLE,
xmpi(MPI_Gatherv(varslice, (size_t)chunkSize, MPI_DOUBLE,
var, chunks, displs, MPI_DOUBLE, 0, comm));
#else
var = varslice;
......@@ -344,6 +353,9 @@ modelRun(struct model_config setup, MPI_Comm comm)
if (zID != CDI_UNDEFID)
{
zaxisDestroy(zID);
#if USE_MPI
xt_idxlist_delete(varDesc[varIdx].partDesc);
#endif
for (size_t j = varIdx + 1; j < nVars; ++j)
if (zID == varDesc[j].zaxisID)
varDesc[j].zaxisID = CDI_UNDEFID;
......
Markdown is supported
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