Blame test/mpi/cxx/coll/icbarrierx.cxx

Packit 0848f5
/* -*- Mode: C++; c-basic-offset:4 ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2003 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
#include "mpi.h"
Packit 0848f5
#include <iostream>
Packit 0848f5
#include "mpitestconf.h"
Packit 0848f5
#include "mpitestcxx.h"
Packit 0848f5
Packit 0848f5
static char MTEST_Descrip[] = "Simple intercomm barrier test";
Packit 0848f5
Packit 0848f5
/* This only checks that the Barrier operation accepts intercommunicators.
Packit 0848f5
   It does not check for the semantics of a intercomm barrier (all processes
Packit 0848f5
   in the local group can exit when (but not before) all processes in the 
Packit 0848f5
   remote group enter the barrier */
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    int errs = 0;
Packit 0848f5
    int leftGroup;
Packit 0848f5
    MPI::Intercomm comm;
Packit 0848f5
    MPI::Datatype datatype;
Packit 0848f5
Packit 0848f5
    MTest_Init( );
Packit 0848f5
Packit 0848f5
    datatype = MPI::INT;
Packit 0848f5
    while (MTestGetIntercomm( comm, leftGroup, 4 )) {
Packit 0848f5
        if (comm == MPI::COMM_NULL) continue;
Packit 0848f5
	/* Get an intercommunicator */
Packit 0848f5
	if (leftGroup) {
Packit 0848f5
	    try
Packit 0848f5
	    {
Packit 0848f5
		comm.Barrier( );
Packit 0848f5
	    }
Packit 0848f5
	    catch (MPI::Exception e)
Packit 0848f5
	    {
Packit 0848f5
		errs++;
Packit 0848f5
		MTestPrintError( e.Get_error_code() );
Packit 0848f5
	    }
Packit 0848f5
	}
Packit 0848f5
	else {
Packit 0848f5
	    /* In the right group */
Packit 0848f5
	    try
Packit 0848f5
	    {
Packit 0848f5
		comm.Barrier();
Packit 0848f5
	    }
Packit 0848f5
	    catch (MPI::Exception e)
Packit 0848f5
	    {
Packit 0848f5
		errs++;
Packit 0848f5
		MTestPrintError( e.Get_error_code() );
Packit 0848f5
	    }
Packit 0848f5
	}
Packit 0848f5
        MTestFreeComm(comm);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MTest_Finalize( errs );
Packit 0848f5
    MPI::Finalize();
Packit 0848f5
    return 0;
Packit 0848f5
}