Fix indices. Introduce cdim index for data types

This commit is contained in:
Jan Eitzinger 2024-02-13 09:02:34 +01:00
parent 3e020396c5
commit 5d33bb9d57
4 changed files with 39 additions and 38 deletions

View File

@ -2,7 +2,7 @@
TAG ?= CLANG TAG ?= CLANG
ENABLE_MPI ?= true ENABLE_MPI ?= true
ENABLE_OPENMP ?= false ENABLE_OPENMP ?= false
COMM_TYPE ?= v2 COMM_TYPE ?= v3
#Feature options #Feature options
OPTIONS += -DARRAY_ALIGNMENT=64 OPTIONS += -DARRAY_ALIGNMENT=64

View File

@ -42,18 +42,18 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
int starts[NDIMS] = { 1, 1 }; int starts[NDIMS] = { 1, 1 };
if (commIsBoundary(c, LEFT)) { if (commIsBoundary(c, LEFT)) {
newSizes[IDIM] += 1; newSizes[CIDIM] += 1;
starts[IDIM] = 0; starts[CIDIM] = 0;
} }
if (commIsBoundary(c, RIGHT)) { if (commIsBoundary(c, RIGHT)) {
newSizes[IDIM] += 1; newSizes[CIDIM] += 1;
} }
if (commIsBoundary(c, BOTTOM)) { if (commIsBoundary(c, BOTTOM)) {
newSizes[JDIM] += 1; newSizes[CJDIM] += 1;
starts[JDIM] = 0; starts[CJDIM] = 0;
} }
if (commIsBoundary(c, TOP)) { if (commIsBoundary(c, TOP)) {
newSizes[JDIM] += 1; newSizes[CJDIM] += 1;
} }
MPI_Type_create_subarray(NDIMS, MPI_Type_create_subarray(NDIMS,
@ -68,8 +68,8 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
int newSizesI[c->size]; int newSizesI[c->size];
int newSizesJ[c->size]; int newSizesJ[c->size];
MPI_Gather(&newSizes[IDIM], 1, MPI_INT, newSizesI, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Gather(&newSizes[CIDIM], 1, MPI_INT, newSizesI, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Gather(&newSizes[JDIM], 1, MPI_INT, newSizesJ, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Gather(&newSizes[CJDIM], 1, MPI_INT, newSizesJ, 1, MPI_INT, 0, MPI_COMM_WORLD);
/* rank 0 assembles the subdomains */ /* rank 0 assembles the subdomains */
if (c->rank == 0) { if (c->rank == 0) {
@ -87,12 +87,12 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
i, i,
coords[IDIM], coords[IDIM],
coords[JDIM], coords[JDIM],
oldSizes[IDIM], oldSizes[CIDIM],
oldSizes[JDIM], oldSizes[CJDIM],
newSizes[IDIM], newSizes[CIDIM],
newSizes[JDIM], newSizes[CJDIM],
starts[IDIM], starts[CIDIM],
starts[JDIM]); starts[CJDIM]);
MPI_Type_create_subarray(NDIMS, MPI_Type_create_subarray(NDIMS,
oldSizes, oldSizes,

View File

@ -42,18 +42,18 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
int starts[NDIMS] = { 1, 1 }; int starts[NDIMS] = { 1, 1 };
if (commIsBoundary(c, LEFT)) { if (commIsBoundary(c, LEFT)) {
newSizes[IDIM] += 1; newSizes[CIDIM] += 1;
starts[IDIM] = 0; starts[CIDIM] = 0;
} }
if (commIsBoundary(c, RIGHT)) { if (commIsBoundary(c, RIGHT)) {
newSizes[IDIM] += 1; newSizes[CIDIM] += 1;
} }
if (commIsBoundary(c, BOTTOM)) { if (commIsBoundary(c, BOTTOM)) {
newSizes[JDIM] += 1; newSizes[CJDIM] += 1;
starts[JDIM] = 0; starts[CJDIM] = 0;
} }
if (commIsBoundary(c, TOP)) { if (commIsBoundary(c, TOP)) {
newSizes[JDIM] += 1; newSizes[CJDIM] += 1;
} }
MPI_Type_create_subarray(NDIMS, MPI_Type_create_subarray(NDIMS,
@ -68,8 +68,8 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
int newSizesI[c->size]; int newSizesI[c->size];
int newSizesJ[c->size]; int newSizesJ[c->size];
MPI_Gather(&newSizes[IDIM], 1, MPI_INT, newSizesI, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Gather(&newSizes[CIDIM], 1, MPI_INT, newSizesI, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Gather(&newSizes[JDIM], 1, MPI_INT, newSizesJ, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Gather(&newSizes[CJDIM], 1, MPI_INT, newSizesJ, 1, MPI_INT, 0, MPI_COMM_WORLD);
/* rank 0 assembles the subdomains */ /* rank 0 assembles the subdomains */
if (c->rank == 0) { if (c->rank == 0) {
@ -87,12 +87,12 @@ static void assembleResult(Comm* c, double* src, double* dst, int imax, int jmax
i, i,
coords[IDIM], coords[IDIM],
coords[JDIM], coords[JDIM],
oldSizes[IDIM], oldSizes[CIDIM],
oldSizes[JDIM], oldSizes[CJDIM],
newSizes[IDIM], newSizes[CIDIM],
newSizes[JDIM], newSizes[CJDIM],
starts[IDIM], starts[CIDIM],
starts[JDIM]); starts[CJDIM]);
MPI_Type_create_subarray(NDIMS, MPI_Type_create_subarray(NDIMS,
oldSizes, oldSizes,
@ -253,15 +253,15 @@ void commPartition(Comm* c, int jmax, int imax)
c->bufferTypes[TOP] = jBufferType; c->bufferTypes[TOP] = jBufferType;
size_t dblsize = sizeof(double); size_t dblsize = sizeof(double);
c->sdispls[LEFT] = ((imaxLocal + 2) + 1) * dblsize; // send left c->sdispls[LEFT] = ((imaxLocal + 2) + 1) * dblsize;
c->sdispls[RIGHT] = ((imaxLocal + 2) + imaxLocal) * dblsize; // send right c->sdispls[RIGHT] = ((imaxLocal + 2) + imaxLocal) * dblsize;
c->sdispls[BOTTOM] = ((imaxLocal + 2) + 1) * dblsize; // send bottom c->sdispls[BOTTOM] = ((imaxLocal + 2) + 1) * dblsize;
c->sdispls[TOP] = (jmaxLocal * (imaxLocal + 2) + 1) * dblsize; // send top c->sdispls[TOP] = (jmaxLocal * (imaxLocal + 2) + 1) * dblsize;
c->rdispls[LEFT] = (imaxLocal + 2) * dblsize; // recv left c->rdispls[LEFT] = (imaxLocal + 2) * dblsize;
c->rdispls[RIGHT] = ((imaxLocal + 2) + (imaxLocal + 1)) * dblsize; // recv right c->rdispls[RIGHT] = ((imaxLocal + 2) + (imaxLocal + 1)) * dblsize;
c->rdispls[BOTTOM] = 1 * dblsize; // recv bottom c->rdispls[BOTTOM] = 1 * dblsize;
c->rdispls[TOP] = ((jmaxLocal + 1) * (imaxLocal + 2) + 1) * dblsize; // recv top c->rdispls[TOP] = ((jmaxLocal + 1) * (imaxLocal + 2) + 1) * dblsize;
#else #else
c->imaxLocal = imax; c->imaxLocal = imax;
c->jmaxLocal = jmax; c->jmaxLocal = jmax;

View File

@ -11,7 +11,8 @@
#endif #endif
enum direction { LEFT = 0, RIGHT, BOTTOM, TOP, NDIRS }; enum direction { LEFT = 0, RIGHT, BOTTOM, TOP, NDIRS };
enum dimension { JDIM = 0, IDIM, NDIMS }; enum dimension { IDIM = 0, JDIM, NDIMS };
enum cdimension { CJDIM = 0, CIDIM };
enum layer { HALO = 0, BULK }; enum layer { HALO = 0, BULK };
enum op { MAX = 0, SUM }; enum op { MAX = 0, SUM };