File: isendtst.c

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (33 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "mpi.h"
#define BUFSIZE 100000
main(int argc, char **argv)
{
  int myid, nnodes, size;
  double start_time, end_time, elapsed_time;
  char buffer[BUFSIZE];
  MPI_Request request;
  MPI_Status status;
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &myid);
  MPI_Comm_size(MPI_COMM_WORLD, &nnodes);
  printf("node %d of %d checking in\n", myid, nnodes);
  for (size = 1; size < BUFSIZE; size*=2) {
    if (myid == 0) {
      printf("size = %d\n", size);

      printf("node 0 sending mpi_isend\n");
      MPI_Isend(buffer, size, MPI_BYTE, 1, 0, MPI_COMM_WORLD, &request);
      printf("node 0 sent mpi_isend. waiting\n");
      MPI_Wait(&request, &status);
      printf("node 0 finished waiting\n");
    } else if (myid == 1) {
      printf("node 1 receiving\n");
      MPI_Recv(buffer, size, MPI_BYTE, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &statu
s);
      printf("node 1 received\n");
    }
    MPI_Barrier(MPI_COMM_WORLD);
  }
  exit(0);

}