|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2011 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
Tests invocation of error handlers on a variety of communicators, including
|
|
Packit |
0848f5 |
COMM_NULL.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#include "mpitestconf.h"
|
|
Packit |
0848f5 |
#include <mpi.h>
|
|
Packit |
0848f5 |
#include <iostream>
|
|
Packit |
0848f5 |
#include "mpitestcxx.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* returns number of errors found */
|
|
Packit |
0848f5 |
int testCommCall( MPI::Comm &comm )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int i;
|
|
Packit |
0848f5 |
bool sawException = false;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
comm.Set_errhandler( MPI::ERRORS_THROW_EXCEPTIONS );
|
|
Packit |
0848f5 |
try {
|
|
Packit |
0848f5 |
// Invalid send
|
|
Packit |
0848f5 |
comm.Send( &i, -1, MPI::DATATYPE_NULL, -1, -10 );
|
|
Packit |
0848f5 |
} catch (MPI::Exception &ex ) {
|
|
Packit |
0848f5 |
// This is good
|
|
Packit |
0848f5 |
sawException = true;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
catch (...) {
|
|
Packit |
0848f5 |
// This is bad
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
if (!sawException) {
|
|
Packit |
0848f5 |
int len;
|
|
Packit |
0848f5 |
char commname[MPI_MAX_OBJECT_NAME];
|
|
Packit |
0848f5 |
comm.Get_name( commname, len );
|
|
Packit |
0848f5 |
std::cout << "Did not see MPI exception on invalid call on communicator " <<
|
|
Packit |
0848f5 |
commname << "\n";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
return sawException ? 0 : 1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int testNullCommCall( void )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int i;
|
|
Packit |
0848f5 |
bool sawException = false;
|
|
Packit |
0848f5 |
const MPI::Comm &comm = MPI::COMM_NULL;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI::COMM_WORLD.Set_errhandler( MPI::ERRORS_THROW_EXCEPTIONS );
|
|
Packit |
0848f5 |
try {
|
|
Packit |
0848f5 |
// Invalid send
|
|
Packit |
0848f5 |
comm.Send( &i, -1, MPI::DATATYPE_NULL, -1, -10 );
|
|
Packit |
0848f5 |
} catch (MPI::Exception &ex ) {
|
|
Packit |
0848f5 |
// This is good
|
|
Packit |
0848f5 |
sawException = true;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
catch (...) {
|
|
Packit |
0848f5 |
// This is bad
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
if (!sawException) {
|
|
Packit |
0848f5 |
std::cout << "Did not see MPI exception on invalid call on communicator COMM_NULL\n";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
return sawException ? 0 : 1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main( int argc, char *argv[] )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errs = 0;
|
|
Packit |
0848f5 |
bool periods[2] = { false, false };
|
|
Packit |
0848f5 |
int dims[2] = { 0, 0 };
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Init( );
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI::Compute_dims( MPI::COMM_WORLD.Get_size(), 2, dims );
|
|
Packit |
0848f5 |
MPI::Cartcomm cart = MPI::COMM_WORLD.Create_cart( 2, dims, periods, true );
|
|
Packit |
0848f5 |
cart.Set_name( "Cart comm" );
|
|
Packit |
0848f5 |
// Graphcomm graph = COMM_WORLD.Create_graph( );
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
errs += testCommCall( MPI::COMM_WORLD );
|
|
Packit |
0848f5 |
errs += testNullCommCall( );
|
|
Packit |
0848f5 |
errs += testCommCall( MPI::COMM_SELF );
|
|
Packit |
0848f5 |
errs += testCommCall( cart );
|
|
Packit |
0848f5 |
//errs += testCommCall( graph );
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize( errs );
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
cart.Free();
|
|
Packit |
0848f5 |
// graph.Free();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI::Finalize();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|