Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove warning with mc
[simgrid.git] / teshsuite / smpi / mpich3-test / coll / bcast3.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */
7 #include "mpi.h"
8 #include <stdio.h>
9 #include "mpitest.h"
10
11 /*
12 static char MTEST_Descrip[] = "Test of broadcast with various roots and datatypes and sizes that are not powers of two";
13 */
14
15 int main( int argc, char *argv[] )
16 {
17     int errs = 0, err;
18     int rank, size, root;
19     int minsize = 2, count; 
20     MPI_Comm      comm;
21     MTestDatatype sendtype, recvtype;
22
23     MTest_Init( &argc, &argv );
24
25     /* The following illustrates the use of the routines to 
26        run through a selection of communicators and datatypes.
27        Use subsets of these for tests that do not involve combinations 
28        of communicators, datatypes, and counts of datatypes */
29     while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
30         if (comm == MPI_COMM_NULL) continue;
31         /* Determine the sender and receiver */
32         MPI_Comm_rank( comm, &rank );
33         MPI_Comm_size( comm, &size );
34         
35         count = 1;
36         /* This must be very large to ensure that we reach the long message
37            algorithms */
38         for (count = 4; count < 6600; count = count * 4) {
39             while (MTestGetDatatypes( &sendtype, &recvtype, count-1 )) {
40                 for (root=0; root<size; root++) {
41                     if (rank == root) {
42                         sendtype.InitBuf( &sendtype );
43                         err = MPI_Bcast( sendtype.buf, sendtype.count,
44                                          sendtype.datatype, root, comm );
45                         if (err) {
46                             errs++;
47                             MTestPrintError( err );
48                         }
49                     }
50                     else {
51                         recvtype.InitBuf( &recvtype );
52                         err = MPI_Bcast( recvtype.buf, recvtype.count, 
53                                     recvtype.datatype, root, comm );
54                         if (err) {
55                             errs++;
56                             fprintf( stderr, "Error with communicator %s and datatype %s\n", 
57                                  MTestGetIntracommName(), 
58                                  MTestGetDatatypeName( &recvtype ) );
59                             MTestPrintError( err );
60                         }
61                         err = MTestCheckRecv( 0, &recvtype );
62                         if (err) {
63                             errs += errs;
64                         }
65                     }
66                 }
67                 MTestFreeDatatype( &recvtype );
68                 MTestFreeDatatype( &sendtype );
69             }
70         }
71         MTestFreeComm( &comm );
72     }
73
74     MTest_Finalize( errs );
75     MPI_Finalize();
76     return 0;
77 }