|
| 1 | +/* |
| 2 | +//@HEADER |
| 3 | +// ************************************************************************ |
| 4 | +// |
| 5 | +// |
| 6 | +// _|_|_|_| _|_|_|_| _| _| _|_|_| _| _| |
| 7 | +// _| _| _|_| _| _| _| _| |
| 8 | +// _|_|_| _|_|_| _| _| _| _| _| |
| 9 | +// _| _| _| _|_| _| _| _| |
| 10 | +// _| _|_|_|_| _| _| _|_|_| _| _| |
| 11 | +// |
| 12 | +// |
| 13 | +// |
| 14 | +// |
| 15 | +// Copyright (C) 2016 Rutgers University and Sandia Corporation |
| 16 | +// |
| 17 | +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, |
| 18 | +// the U.S. Government retains certain rights in this software. |
| 19 | +// |
| 20 | +// Redistribution and use in source and binary forms, with or without |
| 21 | +// modification, are permitted provided that the following conditions are |
| 22 | +// met: |
| 23 | +// |
| 24 | +// 1. Redistributions of source code must retain the above copyright |
| 25 | +// notice, this list of conditions and the following disclaimer. |
| 26 | +// |
| 27 | +// 2. Redistributions in binary form must reproduce the above copyright |
| 28 | +// notice, this list of conditions and the following disclaimer in the |
| 29 | +// documentation and/or other materials provided with the distribution. |
| 30 | +// |
| 31 | +// 3. Neither the name of the Corporation nor the names of the |
| 32 | +// contributors may be used to endorse or promote products derived from |
| 33 | +// this software without specific prior written permission. |
| 34 | +// |
| 35 | +// THIS SOFTWARE IS PROVIDED BY RUTGERS UNIVERSITY and SANDIA CORPORATION |
| 36 | +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 37 | +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 38 | +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUTGERS |
| 39 | +// UNIVERISY, SANDIA CORPORATION OR THE CONTRIBUTORS BE LIABLE FOR ANY |
| 40 | +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 41 | +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 42 | +// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 43 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 44 | +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 45 | +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 46 | +// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 47 | +// |
| 48 | +// Author Marc Gamell, Eric Valenzuela, Keita Teranishi, Manish Parashar, |
| 49 | +// Michael Heroux, and Matthew Whitlock |
| 50 | +// |
| 51 | +// Questions? Contact Keita Teranishi (knteran@sandia.gov) and |
| 52 | +// Marc Gamell (mgamell@cac.rutgers.edu) |
| 53 | +// |
| 54 | +// ************************************************************************ |
| 55 | +//@HEADER |
| 56 | +*/ |
| 57 | + |
| 58 | +#include <mpi.h> |
| 59 | +#include <mpi-ext.h> |
| 60 | +#include <stdio.h> |
| 61 | +#include <signal.h> |
| 62 | + |
| 63 | +int main(int argc, char **argv) { |
| 64 | + MPI_Init(&argc, &argv); |
| 65 | + |
| 66 | + MPI_Comm world; |
| 67 | + MPI_Comm_dup(MPI_COMM_WORLD, &world); |
| 68 | + |
| 69 | + MPI_Comm_set_errhandler(world, MPI_ERRORS_RETURN); |
| 70 | + |
| 71 | + int rank; |
| 72 | + MPI_Comm_rank(world, &rank); |
| 73 | + |
| 74 | + if(rank == 2){ |
| 75 | + MPI_Barrier(world); |
| 76 | + fprintf(stderr, "Rank %d raising SIGKILL\n", rank); |
| 77 | + raise(SIGKILL); |
| 78 | + } else { |
| 79 | + int ret; |
| 80 | + while((ret = MPI_Barrier(world)) == MPI_SUCCESS) { } |
| 81 | + fprintf(stderr, "Rank %d caught return %d\n", rank, ret); |
| 82 | + } |
| 83 | + |
| 84 | + int whatever = 0; |
| 85 | + MPIX_Comm_agree(world, &whatever); |
| 86 | + fprintf(stderr, "Rank %d agreed to %d\n", rank, whatever); |
| 87 | + |
| 88 | + MPI_Comm new_world; |
| 89 | + MPIX_Comm_shrink(world, &new_world); |
| 90 | + |
| 91 | + MPI_Barrier(new_world); |
| 92 | + |
| 93 | + fprintf(stderr, "Rank %d completed\n", rank); |
| 94 | + return 0; |
| 95 | +} |
0 commit comments