2007-02-05 18:24:01 +03:00
|
|
|
/* -*- C -*-
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
* The most basic of MPI applications
|
|
|
|
*/
|
|
|
|
|
2016-04-16 03:47:42 +03:00
|
|
|
#include "orte_config.h"
|
|
|
|
|
2007-02-05 18:24:01 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "mpi.h"
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
int rank, size;
|
2016-04-16 03:47:42 +03:00
|
|
|
char hostname[OPAL_MAXHOSTNAMELEN];
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-02-05 18:24:01 +03:00
|
|
|
MPI_Init(&argc, &argv);
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
|
|
|
2016-04-16 03:47:42 +03:00
|
|
|
gethostname(hostname, sizeof(hostname));
|
2007-02-05 18:24:01 +03:00
|
|
|
printf("%s: I am %d of %d. pid=%d\n", hostname, rank, size, getpid());
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2007-02-05 18:24:01 +03:00
|
|
|
if (rank%3 == 0) {
|
|
|
|
printf("%s: rank %d aborts\n", hostname, rank);
|
|
|
|
if (rank == 3) {
|
|
|
|
printf("%s: rank %d is going to sleep\n", hostname, rank);
|
|
|
|
sleep(2);
|
|
|
|
}
|
|
|
|
MPI_Abort(MPI_COMM_WORLD, 2);
|
|
|
|
printf("%s: sleeping. You should not see this\n", hostname);
|
|
|
|
sleep(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
MPI_Finalize();
|
|
|
|
return 0;
|
|
|
|
}
|