|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* This test attempts collective communication after a process in
|
|
Packit Service |
c5cf8c |
* the communicator has failed.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int rank, size, i, rc, errclass, toterrs, errs = 0;
|
|
Packit Service |
c5cf8c |
char rbuf[100000];
|
|
Packit Service |
c5cf8c |
char *sendbuf;
|
|
Packit Service |
c5cf8c |
int deadprocs[1] = { 1 };
|
|
Packit Service |
c5cf8c |
MPI_Group world, newgroup;
|
|
Packit Service |
c5cf8c |
MPI_Comm newcomm;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (size < 3) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Must run with at least 3 processes\n");
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_group(MPI_COMM_WORLD, &world);
|
|
Packit Service |
c5cf8c |
MPI_Group_excl(world, 1, deadprocs, &newgroup);
|
|
Packit Service |
c5cf8c |
MPI_Comm_create_group(MPI_COMM_WORLD, newgroup, 0, &newcomm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 1) {
|
|
Packit Service |
c5cf8c |
exit(EXIT_FAILURE);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* try a small send first */
|
|
Packit Service |
c5cf8c |
sendbuf = (char *) malloc(10 * size * sizeof(char));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
strcpy(sendbuf + i * 10, "No Errors");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPI_Scatter(sendbuf, 10, MPI_CHAR, rbuf, 10, MPI_CHAR, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
|
|
Packit Service |
c5cf8c |
MPI_Error_class(rc, &errclass);
|
|
Packit Service |
c5cf8c |
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
|
|
Packit Service |
c5cf8c |
errclass);
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* reset the buffers and try a larger scatter */
|
|
Packit Service |
c5cf8c |
free(sendbuf);
|
|
Packit Service |
c5cf8c |
memset(rbuf, 0, sizeof(rbuf));
|
|
Packit Service |
c5cf8c |
sendbuf = (char *) malloc(100000 * size * sizeof(char));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
strcpy(sendbuf + i * 100000, "No Errors");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPI_Scatter(sendbuf, 100000, MPI_CHAR, rbuf, 100000, MPI_CHAR, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
|
|
Packit Service |
c5cf8c |
MPI_Error_class(rc, &errclass);
|
|
Packit Service |
c5cf8c |
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
|
|
Packit Service |
c5cf8c |
errclass);
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
rc = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, newcomm);
|
|
Packit Service |
c5cf8c |
if (rc)
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Failed to get errors from other processes\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
if (toterrs) {
|
|
Packit Service |
c5cf8c |
printf(" Found %d errors\n", toterrs);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
free(sendbuf);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&newcomm);
|
|
Packit Service |
c5cf8c |
MPI_Group_free(&newgroup);
|
|
Packit Service |
c5cf8c |
MPI_Group_free(&world);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|