46 int *iproc = mpi->
iproc;
49 int neighbor_rank[2] = {-1,-1};
55 if (ip[dir] == 0) neighbor_rank[0] = -1;
56 else neighbor_rank[0] =
MPIRank1D(ndims,iproc,nip);
58 if (ip[dir] == (iproc[dir]-1))neighbor_rank[1] = -1;
59 else neighbor_rank[1] =
MPIRank1D(ndims,iproc,nip);
62 double sendbuf[2][ghosts], recvbuf[2][ghosts];
66 if (neighbor_rank[0] != -1) {
68 for (i = 0; i < ghosts; i++) sendbuf[0][i] = x[i+ghosts];
70 if (neighbor_rank[1] != -1) {
72 for (i = 0; i < ghosts; i++) sendbuf[1][i] = x[i+N];
74 MPI_Request requests[2*non];
75 MPI_Status statuses[2*non];
79 if (neighbor_rank[0]!= -1) {
80 MPI_Irecv(recvbuf[0],ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->
world,&requests[tick]);
81 MPI_Isend(sendbuf[0],ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->
world,&requests[tick+non]);
84 if (neighbor_rank[1] != -1) {
85 MPI_Irecv(recvbuf[1],ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->
world,&requests[tick]);
86 MPI_Isend(sendbuf[1],ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->
world,&requests[tick+non]);
91 MPI_Waitall(2*non,requests,statuses);
94 if (neighbor_rank[0] != -1)
for (i = 0; i < ghosts; i++) x[i] = recvbuf[0][i];
95 if (neighbor_rank[1] != -1)
for (i = 0; i < ghosts; i++) x[i+N+ghosts] = recvbuf[1][i];
int MPIRank1D(int, int *, int *)
int MPIExchangeBoundaries1D(void *, double *, int, int, int, int)
MPI related function definitions.
#define _ArrayCopy1D_(x, y, size)
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.