Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / teshsuite / smpi / isp / umpire / op-no-free.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) */
3
4 /* op-no-free.c -- construct some MPI_Ops without freeing them */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/op-no-free.c,v 1.1 2002/05/29 16:09:50 bronis Exp $";
9 #endif
10
11 #include <stdio.h>
12 #include <string.h>
13 #include "mpi.h"
14
15 /* construct multiple instances of same op to exercise more Umpire code... */
16 #define OP_COUNT  5
17
18
19 typedef struct {
20   double real, imag;
21 } Complex;
22
23 void 
24 myProd (void *inp, void *inoutp, int *len, MPI_Datatype *dptr) 
25 {
26   int i;
27   Complex c;
28   Complex *in = (Complex *) inp;
29   Complex *inout = (Complex *) inoutp;
30
31   for (i =0; i < *len; ++i) {
32     c.real = inout->real*in->real - inout->imag*in->imag;
33     c.imag = inout->real*in->imag + inout->imag*in->real;
34     *inout = c;
35     in++; inout++;
36   }
37
38   return;
39 }
40
41
42 int
43 main (int argc, char **argv)
44 {
45   int nprocs = -1;
46   int rank = -1;
47   MPI_Comm comm = MPI_COMM_WORLD;
48   int i;
49   char processor_name[128];
50   int namelen = 128;
51   MPI_Op newop[OP_COUNT];
52
53   /* init */
54   MPI_Init (&argc, &argv);
55   MPI_Comm_size (comm, &nprocs);
56   MPI_Comm_rank (comm, &rank);
57   MPI_Get_processor_name (processor_name, &namelen);
58   printf ("(%d) is alive on %s\n", rank, processor_name);
59   fflush (stdout);
60
61   MPI_Barrier (comm);
62
63   for (i = 0; i < OP_COUNT; i++) 
64     MPI_Op_create (myProd, 1, &newop[i]);
65
66   MPI_Barrier (comm);
67
68   printf ("(%d) Finished normally\n", rank);
69   MPI_Finalize ();
70 }
71
72 /* EOF */