Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich3-test / comm / ctxalloc.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  * This program tests the allocation (and deallocation) of contexts.
13  * 
14  */
15 int main( int argc, char **argv )
16 {
17     int errs = 0;
18     int i, j, err;
19     MPI_Comm newcomm1, newcomm2[200];
20
21     MTest_Init( &argc, &argv );
22
23     /* Get a separate communicator to duplicate */
24     MPI_Comm_dup( MPI_COMM_WORLD, &newcomm1 );
25
26     MPI_Errhandler_set( newcomm1, MPI_ERRORS_RETURN );
27     /* Allocate many communicators in batches, then free them */
28     for (i=0; i<1000; i++) {
29         for (j=0; j<200; j++) {
30             err = MPI_Comm_dup( newcomm1, &newcomm2[j] );
31             if (err) {
32                 errs++;
33                 if (errs < 10) {
34                     fprintf( stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j );
35                     MTestPrintError( err );
36                 }
37             }
38         }
39         for (j=0; j<200; j++) {
40             err = MPI_Comm_free( &newcomm2[j] );
41             if (err) {
42                 errs++;
43                 if (errs < 10) {
44                     fprintf( stderr, "Failed to free %d,%d\n", i, j );
45                     MTestPrintError( err );
46                 }
47             }
48         }
49     }
50     err = MPI_Comm_free( &newcomm1 );
51     if (err) {
52         errs++;
53         fprintf( stderr, "Failed to free newcomm1\n" );
54         MTestPrintError( err );
55     }
56       
57     MTest_Finalize( errs );
58
59     MPI_Finalize();
60
61     return 0;
62 }