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 / collective-misorder-allreduce.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Jeffrey Vetter (j-vetter@llnl.gov) Mon Nov  1 1999 */
3 /* collective-misorder.c -- do some collective operations (w/ one of them out of order) */
4
5 #ifndef lint
6 static char *rcsid =
7   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/collective-misorder-allreduce.c,v 1.2 2000/12/04 19:09:45 bronis Exp $";
8 #endif
9
10 #include <stdio.h>
11 #include <string.h>
12 #include "mpi.h"
13
14 #define buf_size 128
15
16 int
17 main (int argc, char **argv)
18 {
19   int nprocs = -1;
20   int rank = -1;
21   MPI_Comm comm = MPI_COMM_WORLD;
22   char processor_name[128];
23   int namelen = 128;
24   int sbuf[buf_size];
25   int rbuf[buf_size];
26
27   /* init */
28   MPI_Init (&argc, &argv);
29   MPI_Comm_size (comm, &nprocs);
30   MPI_Comm_rank (comm, &rank);
31   MPI_Get_processor_name (processor_name, &namelen);
32   printf ("(%d) is alive on %s\n", rank, processor_name);
33   fflush (stdout);
34
35   memset (sbuf, 0, buf_size*sizeof(int));
36   memset (rbuf, 1, buf_size*sizeof(int));
37
38   MPI_Barrier (comm);
39
40   switch (rank)
41     {
42     case 0:
43       MPI_Reduce(sbuf,rbuf,1,MPI_INT,MPI_MAX,0,comm);
44       break;
45
46     default:
47       MPI_Allreduce(sbuf,rbuf,1,MPI_INT, MPI_MAX, comm);
48       break;
49     }
50
51   MPI_Barrier(comm);
52
53   MPI_Finalize ();
54   printf ("(%d) Finished normally\n", rank);
55 }
56
57 /* EOF */