I wrote a MPI program in C to test sending/receiving messages between nodes.
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
int main(int* argc, char*** argv){
MPI_Init(NULL, NULL);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(size < 2){
fprintf(stderr, "Must have >2 processes.\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
int number;
if(rank == 0){
number = -1;
MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
}
else if(rank == 1){
MPI_Recv(&number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Received number %d from process 0.\n", number);
}
MPI_Finalize();
}
When running on 2 machines with one process each, the program provides the correct output:
Received number -1 from process 0.
But also throws the error:
================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 4529 RUNNING AT node0
= EXIT CODE: 2
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
Most resources I've found on bad terminations are dealing with segfaults rather than exit code 2. I've tried adding an MPI_Barrier right before MPI_Finalize, which adds an "assert (!closed) failed" error.
Both nodes are using MPICH 3.1.4 on Raspbian 2015-05-05.