1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
12 * This program tests the allocation (and deallocation) of contexts.
15 int main( int argc, char **argv )
19 MPI_Comm newcomm1, newcomm2[200];
21 MTest_Init( &argc, &argv );
23 /* Get a separate communicator to duplicate */
24 MPI_Comm_dup( MPI_COMM_WORLD, &newcomm1 );
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] );
34 fprintf( stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j );
35 MTestPrintError( err );
39 for (j=0; j<200; j++) {
40 err = MPI_Comm_free( &newcomm2[j] );
44 fprintf( stderr, "Failed to free %d,%d\n", i, j );
45 MTestPrintError( err );
50 err = MPI_Comm_free( &newcomm1 );
53 fprintf( stderr, "Failed to free newcomm1\n" );
54 MTestPrintError( err );
57 MTest_Finalize( errs );