|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
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 <stdio.h>
|
|
Packit |
0848f5 |
#include <stdlib.h>
|
|
Packit |
0848f5 |
#include <string.h>
|
|
Packit |
0848f5 |
#include "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* This test attempts collective bcast communication after a process in
|
|
Packit |
0848f5 |
* the communicator has failed.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
int main(int argc, char **argv)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int rank, size, rc, errclass, toterrs, errs = 0;
|
|
Packit |
0848f5 |
int deadprocs[] = { 1 };
|
|
Packit |
0848f5 |
char buf[100000];
|
|
Packit |
0848f5 |
MPI_Group world, newgroup;
|
|
Packit |
0848f5 |
MPI_Comm newcomm;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Init(&argc, &argv);
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit |
0848f5 |
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_group(MPI_COMM_WORLD, &world);
|
|
Packit |
0848f5 |
MPI_Group_excl(world, 1, deadprocs, &newgroup);
|
|
Packit |
0848f5 |
MPI_Comm_create_group(MPI_COMM_WORLD, newgroup, 0, &newcomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (size < 3) {
|
|
Packit |
0848f5 |
fprintf(stderr, "Must run with at least 3 processes\n");
|
|
Packit |
0848f5 |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank == 1) {
|
|
Packit |
0848f5 |
exit(EXIT_FAILURE);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank == 0) {
|
|
Packit |
0848f5 |
strcpy(buf, "No Errors");
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* do a small bcast first */
|
|
Packit |
0848f5 |
rc = MPI_Bcast(buf, 10, MPI_CHAR, 0, MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
|
|
Packit |
0848f5 |
MPI_Error_class(rc, &errclass);
|
|
Packit |
0848f5 |
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
|
|
Packit |
0848f5 |
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
|
|
Packit |
0848f5 |
errclass);
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* reset the non-root buffers */
|
|
Packit |
0848f5 |
if (rank != 0)
|
|
Packit |
0848f5 |
memset(buf, 0, sizeof(buf));
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* do a larger bcast */
|
|
Packit |
0848f5 |
rc = MPI_Bcast(buf, 100000, MPI_CHAR, 0, MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
|
|
Packit |
0848f5 |
MPI_Error_class(rc, &errclass);
|
|
Packit |
0848f5 |
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
|
|
Packit |
0848f5 |
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
|
|
Packit |
0848f5 |
errclass);
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
rc = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, newcomm);
|
|
Packit |
0848f5 |
if (rc)
|
|
Packit |
0848f5 |
fprintf(stderr, "Failed to get errors from other processes\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank == 0) {
|
|
Packit |
0848f5 |
if (toterrs) {
|
|
Packit |
0848f5 |
printf(" Found %d errors\n", toterrs);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
printf(" No Errors\n");
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
fflush(stdout);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Group_free(&world);
|
|
Packit |
0848f5 |
MPI_Group_free(&newgroup);
|
|
Packit |
0848f5 |
MPI_Comm_free(&newcomm);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
}
|