Blame test/mpi/ft/barrier.c
|
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 |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* This test attempts collective communication after a process in
|
|
Packit Service |
c5cf8c |
* the communicator has failed. Since all processes contribute to
|
|
Packit Service |
c5cf8c |
* the result of the operation, all process will receive an error.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int rank, size;
|
|
Packit Service |
c5cf8c |
int err, errclass;
|
|
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 < 2) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Must run with at least 2 processes\n");
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 1) {
|
|
Packit Service |
c5cf8c |
exit(EXIT_FAILURE);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
|
|
Packit Service |
c5cf8c |
MPI_Error_class(err, &errclass);
|
|
Packit Service |
c5cf8c |
if (errclass == MPIX_ERR_PROC_FAILED) {
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
|
|
Packit Service |
c5cf8c |
errclass);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MPI_SUCCESS != err;
|
|
Packit Service |
c5cf8c |
}
|