|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2009 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include <stdlib.h>
|
|
Packit |
0848f5 |
#include "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
static char MTEST_Descrip[] = "Test error reporting from faults with collective communication";
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int ReportErr(int errcode, const char name[]);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int wrank, wsize, rank, size, color;
|
|
Packit |
0848f5 |
int tmp, errs = 0;
|
|
Packit |
0848f5 |
MPI_Comm newcomm;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &wsize);
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Color is 0 or 1; 1 will be the processes that "fault" */
|
|
Packit |
0848f5 |
/* process 0 and wsize/2+1...wsize-1 are in non-faulting group */
|
|
Packit |
0848f5 |
color = (wrank > 0) && (wrank <= wsize / 2);
|
|
Packit |
0848f5 |
MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_size(newcomm, &size);
|
|
Packit |
0848f5 |
MPI_Comm_rank(newcomm, &rank;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Set errors return on COMM_WORLD and the new comm */
|
|
Packit |
0848f5 |
MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, newcomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
if (color) {
|
|
Packit |
0848f5 |
/* Simulate a fault on some processes */
|
|
Packit |
0848f5 |
exit(1);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Can we still use newcomm? */
|
|
Packit |
0848f5 |
MPI_Allreduce(&rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm);
|
|
Packit |
0848f5 |
if (tmp != (size * (size + 1)) / 2) {
|
|
Packit |
0848f5 |
printf("Allreduce gave %d but expected %d\n", tmp, (size * (size + 1)) / 2);
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_free(&newcomm);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
printf(" No Errors\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int ReportErr(int errcode, const char name[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errclass, errlen;
|
|
Packit |
0848f5 |
char errmsg[MPI_MAX_ERROR_STRING];
|
|
Packit |
0848f5 |
MPI_Error_class(errcode, &errclass);
|
|
Packit |
0848f5 |
MPI_Error_string(errcode, errmsg, &errlen);
|
|
Packit |
0848f5 |
fprintf(stderr, "In %s, error code %d(class %d) = %s\n", name, errcode, errclass, errmsg);
|
|
Packit |
0848f5 |
return 1;
|
|
Packit |
0848f5 |
}
|