Blame test/mpi/ft/revoke_nofail.c

Packit 0848f5
Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *
Packit 0848f5
 *  (C) 2014 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
Packit 0848f5
/*
Packit 0848f5
 * This test ensures that MPI_Comm_revoke works when a process failure has not
Packit 0848f5
 * occurred yet.
Packit 0848f5
 */
Packit 0848f5
int main(int argc, char **argv)
Packit 0848f5
{
Packit 0848f5
    int rank, size;
Packit 0848f5
    int rc, ec;
Packit 0848f5
    char error[MPI_MAX_ERROR_STRING];
Packit 0848f5
    MPI_Comm world_dup;
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
    if (size < 2) {
Packit 0848f5
        fprintf(stderr, "Must run with at least 2 processes\n");
Packit 0848f5
        MPI_Abort(MPI_COMM_WORLD, 1);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
Packit 0848f5
Packit 0848f5
    MPI_Comm_dup(MPI_COMM_WORLD, &world_dup);
Packit 0848f5
Packit 0848f5
    if (rank == 1) {
Packit 0848f5
        MPIX_Comm_revoke(world_dup);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    rc = MPI_Barrier(world_dup);
Packit 0848f5
    MPI_Error_class(rc, &ec);
Packit 0848f5
    if (ec != MPIX_ERR_REVOKED) {
Packit 0848f5
        MPI_Error_string(ec, error, &size);
Packit 0848f5
        fprintf(stderr,
Packit 0848f5
                "[%d] MPI_Barrier should have returned MPIX_ERR_REVOKED (%d), but it actually returned: %d\n%s\n",
Packit 0848f5
                rank, MPIX_ERR_REVOKED, ec, error);
Packit 0848f5
        MPI_Abort(MPI_COMM_WORLD, 1);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Comm_free(&world_dup);
Packit 0848f5
Packit 0848f5
    if (rank == 0)
Packit 0848f5
        fprintf(stdout, " No errors\n");
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}