Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Multiply memset size by size of element in umpire.
[simgrid.git] / teshsuite / smpi / isp / umpire / no-error.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Fri Mar  17 2000 */
3 /* no-error.c -- do some MPI calls without any errors */
4
5 #include <stdio.h>
6 #include "mpi.h"
7
8 #define buf_size 128
9
10 int
11 main (int argc, char **argv)
12 {
13   int nprocs = -1;
14   int rank = -1;
15   char processor_name[128];
16   int namelen = 128;
17   int buf0[buf_size];
18   int buf1[buf_size];
19   MPI_Status status;
20
21   /* init */
22   MPI_Init (&argc, &argv);
23   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
24   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
25   MPI_Get_processor_name (processor_name, &namelen);
26   printf ("(%d) is alive on %s\n", rank, processor_name);
27   fflush (stdout);
28
29   if (nprocs < 2)
30     {
31       printf ("not enough tasks\n");
32     }
33   else
34     {
35       if (rank == 0)
36         {
37           memset (buf0, 0, buf_size*sizeof(int));
38
39           MPI_Sendrecv (buf0, buf_size, MPI_INT, 1, 0,
40                         buf1, buf_size, MPI_INT, 1, 0,
41                         MPI_COMM_WORLD, &status);
42
43           MPI_Sendrecv (buf1, buf_size, MPI_INT, 1, 0,
44                         buf0, buf_size, MPI_INT, 1, 0,
45                         MPI_COMM_WORLD, &status);
46
47           MPI_Sendrecv (buf0, buf_size, MPI_INT, 1, 0,
48                         buf1, buf_size, MPI_INT, 1, 0,
49                         MPI_COMM_WORLD, &status);
50         }
51       else
52         {
53           if (rank == 1)
54             {
55               memset (buf1, 1, buf_size*sizeof(int));
56
57               MPI_Sendrecv (buf1, buf_size, MPI_INT, 0, 0,
58                             buf0, buf_size, MPI_INT, 0, 0,
59                             MPI_COMM_WORLD, &status);
60
61               MPI_Sendrecv (buf0, buf_size, MPI_INT, 0, 0,
62                             buf1, buf_size, MPI_INT, 0, 0,
63                             MPI_COMM_WORLD, &status);
64
65               MPI_Sendrecv (buf1, buf_size, MPI_INT, 0, 0,
66                             buf0, buf_size, MPI_INT, 0, 0,
67                             MPI_COMM_WORLD, &status);
68             }
69         }
70     }
71
72   MPI_Finalize ();
73   printf ("(%d) Finished normally\n", rank);
74 }
75
76 /* EOF */