Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/mesh/fv_ops.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,9 @@ void communicateFluxes(Field3D& f) {
comm_handle xin, xout;
// Cache results to silence spurious compiler warning about xin,
// xout possibly being uninitialised when used
bool not_first = !mesh->firstX();
bool not_last = !mesh->lastX();
const bool not_first = mesh->periodicX || !mesh->firstX();
const bool not_last = mesh->periodicX || !mesh->lastX();

if (not_first) {
xin = mesh->irecvXIn(f(0, 0), size, 0);
}
Expand Down
64 changes: 48 additions & 16 deletions src/mesh/impls/bout/boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1534,42 +1534,66 @@ bool BoutMesh::firstX() const { return PE_XIND == 0; }
bool BoutMesh::lastX() const { return PE_XIND == NXPE - 1; }

int BoutMesh::sendXOut(BoutReal* buffer, int size, int tag) {
Timer timer("comms");

int proc {-1};
if (PE_XIND == NXPE - 1) {
return 1;
if (periodicX) {
// Wrap around to first processor in X
proc = PROC_NUM(0, PE_YIND);
} else {
return 1;
}
} else {
proc = PROC_NUM(PE_XIND + 1, PE_YIND);
}

Timer timer("comms");

mpi->MPI_Send(buffer, size, PVEC_REAL_MPI_TYPE, PROC_NUM(PE_XIND + 1, PE_YIND), tag,
mpi->MPI_Send(buffer, size, PVEC_REAL_MPI_TYPE, proc, tag,
BoutComm::get());

return 0;
}

int BoutMesh::sendXIn(BoutReal* buffer, int size, int tag) {
Timer timer("comms");

int proc {-1};
if (PE_XIND == 0) {
return 1;
if (periodicX) {
// Wrap around to last processor in X
proc = PROC_NUM(NXPE - 1, PE_YIND);
} else {
return 1;
}
} else {
proc = PROC_NUM(PE_XIND - 1, PE_YIND);
}

Timer timer("comms");

mpi->MPI_Send(buffer, size, PVEC_REAL_MPI_TYPE, PROC_NUM(PE_XIND - 1, PE_YIND), tag,
mpi->MPI_Send(buffer, size, PVEC_REAL_MPI_TYPE, proc, tag,
BoutComm::get());

return 0;
}

comm_handle BoutMesh::irecvXOut(BoutReal* buffer, int size, int tag) {
Timer timer("comms");

int proc {-1};
if (PE_XIND == NXPE - 1) {
return nullptr;
if (periodicX) {
// Wrap around to first processor in X
proc = PROC_NUM(0, PE_YIND);
} else {
return nullptr;
}
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

                 BoutComm::get(), ch->request);
                                  ^

proc = PROC_NUM(PE_XIND + 1, PE_YIND);
}

Timer timer("comms");

// Get a communications handle. Not fussy about size of arrays
CommHandle* ch = get_handle(0, 0);

mpi->MPI_Irecv(buffer, size, PVEC_REAL_MPI_TYPE, PROC_NUM(PE_XIND + 1, PE_YIND), tag,
mpi->MPI_Irecv(buffer, size, PVEC_REAL_MPI_TYPE, proc, tag,
BoutComm::get(), ch->request);

ch->in_progress = true;
Expand All @@ -1578,16 +1602,24 @@ comm_handle BoutMesh::irecvXOut(BoutReal* buffer, int size, int tag) {
}

comm_handle BoutMesh::irecvXIn(BoutReal* buffer, int size, int tag) {
Timer timer("comms");

int proc {-1};
if (PE_XIND == 0) {
return nullptr;
if (periodicX) {
// Wrap around to last processor in X
proc = PROC_NUM(NXPE - 1, PE_YIND);
} else {
return nullptr;
}
} else {
Comment thread
bendudson marked this conversation as resolved.
proc = PROC_NUM(PE_XIND - 1, PE_YIND);
}

Timer timer("comms");

// Get a communications handle. Not fussy about size of arrays
CommHandle* ch = get_handle(0, 0);

mpi->MPI_Irecv(buffer, size, PVEC_REAL_MPI_TYPE, PROC_NUM(PE_XIND - 1, PE_YIND), tag,
mpi->MPI_Irecv(buffer, size, PVEC_REAL_MPI_TYPE, proc, tag,
BoutComm::get(), ch->request);

ch->in_progress = true;
Expand Down
Loading