|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2004 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 |
#include "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
static char MTEST_Descrip[] = "Test intercomm merge, including the choice of the high value";
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errs = 0;
|
|
Packit |
0848f5 |
int rank, size, rsize;
|
|
Packit |
0848f5 |
int nsize, nrank;
|
|
Packit |
0848f5 |
int minsize = 2;
|
|
Packit |
0848f5 |
int isLeft;
|
|
Packit |
0848f5 |
MPI_Comm comm, comm1, comm2, comm3, comm4;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* The following illustrates the use of the routines to
|
|
Packit |
0848f5 |
* run through a selection of communicators and datatypes.
|
|
Packit |
0848f5 |
* Use subsets of these for tests that do not involve combinations
|
|
Packit |
0848f5 |
* of communicators, datatypes, and counts of datatypes */
|
|
Packit |
0848f5 |
while (MTestGetIntercomm(&comm, &isLeft, minsize)) {
|
|
Packit |
0848f5 |
if (comm == MPI_COMM_NULL)
|
|
Packit |
0848f5 |
continue;
|
|
Packit |
0848f5 |
/* Determine the sender and receiver */
|
|
Packit |
0848f5 |
MPI_Comm_rank(comm, &rank;;
|
|
Packit |
0848f5 |
MPI_Comm_remote_size(comm, &rsize);
|
|
Packit |
0848f5 |
MPI_Comm_size(comm, &size);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Try building intercomms */
|
|
Packit |
0848f5 |
MPI_Intercomm_merge(comm, isLeft, &comm1;;
|
|
Packit |
0848f5 |
/* Check the size and ranks */
|
|
Packit |
0848f5 |
MPI_Comm_size(comm1, &nsize);
|
|
Packit |
0848f5 |
MPI_Comm_rank(comm1, &nrank);
|
|
Packit |
0848f5 |
if (nsize != size + rsize) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(1) Comm size is %d but should be %d\n", nsize, size + rsize);
|
|
Packit |
0848f5 |
if (isLeft) {
|
|
Packit |
0848f5 |
/* The left processes should be high */
|
|
Packit |
0848f5 |
if (nrank != rsize + rank) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(1) rank for high process is %d should be %d\n", nrank, rsize + rank);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
/* The right processes should be low */
|
|
Packit |
0848f5 |
if (nrank != rank) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(1) rank for low process is %d should be %d\n", nrank, rank);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Intercomm_merge(comm, !isLeft, &comm2;;
|
|
Packit |
0848f5 |
/* Check the size and ranks */
|
|
Packit |
0848f5 |
MPI_Comm_size(comm1, &nsize);
|
|
Packit |
0848f5 |
MPI_Comm_rank(comm1, &nrank);
|
|
Packit |
0848f5 |
if (nsize != size + rsize) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(2) Comm size is %d but should be %d\n", nsize, size + rsize);
|
|
Packit |
0848f5 |
if (!isLeft) {
|
|
Packit |
0848f5 |
/* The right processes should be high */
|
|
Packit |
0848f5 |
if (nrank != rsize + rank) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(2) rank for high process is %d should be %d\n", nrank, rsize + rank);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
/* The left processes should be low */
|
|
Packit |
0848f5 |
if (nrank != rank) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("(2) rank for low process is %d should be %d\n", nrank, rank);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Intercomm_merge(comm, 0, &comm3;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Intercomm_merge(comm, 1, &comm4;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_free(&comm1;;
|
|
Packit |
0848f5 |
MPI_Comm_free(&comm2;;
|
|
Packit |
0848f5 |
MPI_Comm_free(&comm3;;
|
|
Packit |
0848f5 |
MPI_Comm_free(&comm4;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTestFreeComm(&comm);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize(errs);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|