Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into mc
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / sendall.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2007 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "mpi.h"
11 #include "mpitest.h"
12
13 /* 
14  * This test makes sure that each process can send to each other process.
15  * If there are bugs in the handling of request completions or in 
16  * queue operations, then this test may fail on them (it did with
17  * early EagerShort handling).
18  */
19
20 #define MAXPES 32
21 #define MYBUFSIZE 16*1024
22 static int buffer[MAXPES][MYBUFSIZE];
23
24 #define NUM_RUNS 10
25
26 int main ( int argc, char *argv[] )
27 {
28   int i;
29   int count, size;
30   int self, npes;
31   MPI_Request request[MAXPES];
32   MPI_Status status;
33
34   MTest_Init (&argc, &argv);
35   MPI_Comm_rank (MPI_COMM_WORLD, &self);
36   MPI_Comm_size (MPI_COMM_WORLD, &npes);
37
38   if (npes > MAXPES) {
39     fprintf( stderr, "This program requires a comm_world no larger than %d",
40              MAXPES );
41     MPI_Abort( MPI_COMM_WORLD, 1 );
42     exit(1);
43   }
44
45   for (size = 1; size  <= MYBUFSIZE ; size += size) {
46       for (count = 0; count < NUM_RUNS; count++) {
47           MPI_Barrier (MPI_COMM_WORLD);
48
49           for (i = 0; i < npes; i++) {
50               if (i != self)
51                 MPI_Irecv (buffer[i], size, MPI_INT, i,
52                          MPI_ANY_TAG, MPI_COMM_WORLD, &request[i]);
53             }
54
55           for (i = 0; i < npes; i++) {
56               if (i != self)
57                 MPI_Send (buffer[self], size, MPI_INT, i, 0, MPI_COMM_WORLD);
58             }
59
60           for (i = 0; i < npes; i++) {
61               if (i != self)
62                 MPI_Wait (&request[i], &status);
63             }
64
65         }
66       MPI_Barrier (MPI_COMM_WORLD);
67
68       if (self == 0) {
69           MTestPrintfMsg( 1, "length = %d ints\n", size );
70         }
71     }
72
73   /* Simple completion is all that we normally ask of this program */
74
75   MTest_Finalize( 0 );
76
77   MPI_Finalize();
78   return 0;
79 }