Page MenuHomec4science

exchange_send_recv.c
No OneTemporary

File Metadata

Created
Mon, Nov 25, 02:50

exchange_send_recv.c

#include <mpi.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
int myrank;
int buf1[100];
int buf2[100];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank == 0) {
MPI_Sendrecv(buf1, 100, MPI_INT, 1, 0, buf2, 100, MPI_INT, 1, 0,
MPI_COMM_WORLD, MPI_STATUS_IGNORE);
} else if (myrank == 1) {
MPI_Sendrecv(buf1, 100, MPI_INT, 0, 0, buf2, 100, MPI_INT, 0, 0,
MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
memcpy(buf1, buf2, 100 * sizeof(int));
MPI_Finalize();
return 0;
}

Event Timeline