diff --git a/BasicSolver/2D-mpi/src/comm-v2.c b/BasicSolver/2D-mpi/src/comm-v2.c index 4e53e33..7b4e60f 100644 --- a/BasicSolver/2D-mpi/src/comm-v2.c +++ b/BasicSolver/2D-mpi/src/comm-v2.c @@ -252,15 +252,18 @@ void commPartition(Comm* c, int jmax, int imax) MPI_Cart_shift(c->comm, JDIM, 1, &c->neighbours[BOTTOM], &c->neighbours[TOP]); MPI_Cart_get(c->comm, NDIMS, c->dims, periods, c->coords); - c->imaxLocal = sizeOfRank(c->rank, dims[IDIM], imax); - c->jmaxLocal = sizeOfRank(c->rank, dims[JDIM], jmax); + int imaxLocal = sizeOfRank(c->rank, dims[IDIM], imax); + int jmaxLocal = sizeOfRank(c->rank, dims[JDIM], jmax); + + c->imaxLocal = imaxLocal; + c->jmaxLocal = jmaxLocal; MPI_Datatype jBufferType; - MPI_Type_contiguous(c->imaxLocal, MPI_DOUBLE, &jBufferType); + MPI_Type_contiguous(imaxLocal, MPI_DOUBLE, &jBufferType); MPI_Type_commit(&jBufferType); MPI_Datatype iBufferType; - MPI_Type_vector(c->jmaxLocal, 1, c->imaxLocal + 2, MPI_DOUBLE, &iBufferType); + MPI_Type_vector(jmaxLocal, 1, imaxLocal + 2, MPI_DOUBLE, &iBufferType); MPI_Type_commit(&iBufferType); c->bufferTypes[LEFT] = iBufferType; @@ -268,14 +271,15 @@ void commPartition(Comm* c, int jmax, int imax) c->bufferTypes[BOTTOM] = jBufferType; c->bufferTypes[TOP] = jBufferType; - c->rdispls[LEFT] = (c->imaxLocal + 2); - c->rdispls[RIGHT] = (c->imaxLocal + 2) + (c->imaxLocal + 1); + c->sdispls[LEFT] = (imaxLocal + 2) + 1; + c->sdispls[RIGHT] = (imaxLocal + 2) + imaxLocal; + c->sdispls[BOTTOM] = (imaxLocal + 2) + 1; + c->sdispls[TOP] = jmaxLocal * (imaxLocal + 2) + 1; + + c->rdispls[LEFT] = (imaxLocal + 2); + c->rdispls[RIGHT] = (imaxLocal + 2) + (imaxLocal + 1); c->rdispls[BOTTOM] = 1; - c->rdispls[TOP] = (c->jmaxLocal + 1) * (c->imaxLocal + 2) + 1; - c->sdispls[LEFT] = (c->imaxLocal + 2) + 1; - c->sdispls[RIGHT] = (c->imaxLocal + 2) + (c->imaxLocal); - c->sdispls[BOTTOM] = (c->imaxLocal + 2) + 1; - c->sdispls[TOP] = (c->jmaxLocal) * (c->imaxLocal + 2) + 1; + c->rdispls[TOP] = (jmaxLocal + 1) * (imaxLocal + 2) + 1; #else c->imaxLocal = imax; c->jmaxLocal = jmax; diff --git a/BasicSolver/2D-mpi/src/comm-v3.c b/BasicSolver/2D-mpi/src/comm-v3.c index c8bd0b5..e47c10e 100644 --- a/BasicSolver/2D-mpi/src/comm-v3.c +++ b/BasicSolver/2D-mpi/src/comm-v3.c @@ -4,7 +4,6 @@ * Use of this source code is governed by a MIT style * license that can be found in the LICENSE file. */ -#include #include #include @@ -234,27 +233,26 @@ void commPartition(Comm* c, int jmax, int imax) MPI_Cart_shift(c->comm, JDIM, 1, &c->neighbours[BOTTOM], &c->neighbours[TOP]); MPI_Cart_get(c->comm, NDIMS, c->dims, periods, c->coords); - c->imaxLocal = sizeOfRank(c->rank, dims[IDIM], imax); - c->jmaxLocal = sizeOfRank(c->rank, dims[JDIM], jmax); + int imaxLocal = sizeOfRank(c->rank, dims[IDIM], imax); + int jmaxLocal = sizeOfRank(c->rank, dims[JDIM], jmax); + + c->imaxLocal = imaxLocal; + c->jmaxLocal = jmaxLocal; MPI_Datatype jBufferType; - MPI_Type_contiguous(c->imaxLocal, MPI_DOUBLE, &jBufferType); + MPI_Type_contiguous(imaxLocal, MPI_DOUBLE, &jBufferType); MPI_Type_commit(&jBufferType); MPI_Datatype iBufferType; - MPI_Type_vector(c->jmaxLocal, 1, c->imaxLocal + 2, MPI_DOUBLE, &iBufferType); + MPI_Type_vector(jmaxLocal, 1, imaxLocal + 2, MPI_DOUBLE, &iBufferType); MPI_Type_commit(&iBufferType); - // in the order of the dimensions i->0, j->1 - // first negative direction, then positive direction - size_t dblsize = sizeof(double); - int imaxLocal = c->imaxLocal; - int jmaxLocal = c->jmaxLocal; c->bufferTypes[LEFT] = iBufferType; c->bufferTypes[RIGHT] = iBufferType; c->bufferTypes[BOTTOM] = jBufferType; c->bufferTypes[TOP] = jBufferType; + size_t dblsize = sizeof(double); c->sdispls[LEFT] = ((imaxLocal + 2) + 1) * dblsize; // send left c->sdispls[RIGHT] = ((imaxLocal + 2) + imaxLocal) * dblsize; // send right c->sdispls[BOTTOM] = ((imaxLocal + 2) + 1) * dblsize; // send bottom