/* * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. */ /* * Test the connectivity between all processes. */ #include #include #include #include #include #include #include int main(int argc, char **argv) { MPI_Status status; int verbose = 0; int rank; int np; /* number of processes in job */ int peer; int i; int j; int length; char name[MPI_MAX_PROCESSOR_NAME+1]; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &np); /* * If we cannot get the name for whatever reason, just * set it to unknown. */ if (MPI_SUCCESS != MPI_Get_processor_name(name, &length)) { strcpy(name, "unknown"); } if (argc>1 && strcmp(argv[1], "-v")==0) verbose = 1; for (i=0; ii) { /* receive from and reply to rank i */ MPI_Recv(&peer, 1, MPI_INT, i, i, MPI_COMM_WORLD, &status); MPI_Send(&rank, 1, MPI_INT, i, rank, MPI_COMM_WORLD); } } MPI_Barrier(MPI_COMM_WORLD); if (rank==0) printf("Connectivity test on %d processes PASSED.\n", np); MPI_Finalize(); return 0; }