Blame test/mpi/ft/nbccoll.c

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
Packit 0848f5
/*
Packit 0848f5
 * This test checks if a non-blocking collective failing impacts the result
Packit 0848f5
 * of another operation going on at the same time.
Packit 0848f5
 */
Packit 0848f5
int main(int argc, char **argv)
Packit 0848f5
{
Packit 0848f5
    int rank, size;
Packit 0848f5
    int err;
Packit 0848f5
    int excl;
Packit 0848f5
    MPI_Comm small_comm;
Packit 0848f5
    MPI_Group orig_grp, small_grp;
Packit 0848f5
    MPI_Request req;
Packit 0848f5
    MPI_Status status;
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, &orig_grp);
Packit 0848f5
    MPI_Group_size(orig_grp, &excl);
Packit 0848f5
    excl--;
Packit 0848f5
    MPI_Group_excl(orig_grp, 1, &excl, &small_grp);
Packit 0848f5
    MPI_Comm_create_group(MPI_COMM_WORLD, small_grp, 0, &small_comm);
Packit 0848f5
    MPI_Group_free(&orig_grp);
Packit 0848f5
    MPI_Group_free(&small_grp);
Packit 0848f5
Packit 0848f5
    if (size < 4) {
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
    if (rank == excl) {
Packit 0848f5
        exit(EXIT_FAILURE);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Ibarrier(MPI_COMM_WORLD, &req;;
Packit 0848f5
Packit 0848f5
    err = MPI_Barrier(small_comm);
Packit 0848f5
    if (err != MPI_SUCCESS) {
Packit 0848f5
        int ec;
Packit 0848f5
        MPI_Error_class(err, &ec);
Packit 0848f5
        fprintf(stderr, "Result != MPI_SUCCESS: %d\n", ec);
Packit 0848f5
        MPI_Abort(MPI_COMM_WORLD, 1);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    err = MPI_Wait(&req, &status);
Packit 0848f5
    if (err == MPI_SUCCESS) {
Packit 0848f5
        int ec, ec2;
Packit 0848f5
        MPI_Error_class(err, &ec);
Packit 0848f5
        MPI_Error_class(status.MPI_ERROR, &ec2;;
Packit 0848f5
        fprintf(stderr, "Result != MPIX_ERR_PROC_FAILED: %d Status: %d\n", ec, ec2);
Packit 0848f5
        MPI_Abort(MPI_COMM_WORLD, 1);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Comm_free(&small_comm);
Packit 0848f5
Packit 0848f5
    if (rank == 0) {
Packit 0848f5
        printf(" No Errors\n");
Packit 0848f5
        fflush(stdout);
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}