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.
13
* This test attempts collective communication after a process in
14
* the communicator has failed.
16
int main(int argc, char **argv)
18
int rank, size, i, rc, errclass, toterrs, errs = 0;
21
int deadprocs[1] = {1};
22
MPI_Group world, newgroup;
25
MPI_Init(&argc, &argv);
26
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27
MPI_Comm_size(MPI_COMM_WORLD, &size);
28
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
31
fprintf( stderr, "Must run with at least 3 processes\n" );
32
MPI_Abort( MPI_COMM_WORLD, 1 );
39
/* try a small send first */
40
sendbuf = (char *)malloc(10*size*sizeof(char));
43
for (i=0;i<size;i++) {
44
strcpy(sendbuf + i*10, "No Errors");
48
rc = MPI_Scatter(sendbuf, 10, MPI_CHAR, rbuf, 10, MPI_CHAR, 0, MPI_COMM_WORLD);
50
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
51
MPI_Error_class(rc, &errclass);
52
if ((rc) && (errclass != MPIX_ERR_PROC_FAIL_STOP)) {
53
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAIL_STOP\n", errclass);
58
/* reset the buffers and try a larger scatter */
60
memset(rbuf, 0, sizeof(rbuf));
61
sendbuf = (char *)malloc(100000*size*sizeof(char));
64
for (i=0;i<size;i++) {
65
strcpy(sendbuf + i*100000, "No Errors");
69
rc = MPI_Scatter(sendbuf, 100000, MPI_CHAR, rbuf, 100000, MPI_CHAR, 0, MPI_COMM_WORLD);
71
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
72
MPI_Error_class(rc, &errclass);
73
if ((rc) && (errclass != MPIX_ERR_PROC_FAIL_STOP)) {
74
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAIL_STOP\n", errclass);
79
MPI_Comm_group(MPI_COMM_WORLD, &world);
80
MPI_Group_excl(world, 1, deadprocs, &newgroup);
81
MPI_Comm_create_group(MPI_COMM_WORLD, newgroup, 0, &newcomm);
83
rc = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, newcomm);
85
fprintf(stderr, "Failed to get errors from other processes\n");
89
printf( " Found %d errors\n", toterrs );
92
printf( " No Errors\n" );