|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2003 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 "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int errs = 0;
|
|
Packit |
0848f5 |
int size, dims[2], periods[2], remain[2];
|
|
Packit |
0848f5 |
int result, rank;
|
|
Packit |
0848f5 |
MPI_Comm comm, newcomm;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* First, create a 1-dim cartesian communicator */
|
|
Packit |
0848f5 |
periods[0] = 0;
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit |
0848f5 |
dims[0] = size;
|
|
Packit |
0848f5 |
MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Now, extract a communicator with no dimensions */
|
|
Packit |
0848f5 |
remain[0] = 0;
|
|
Packit |
0848f5 |
MPI_Cart_sub(comm, remain, &newcomm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_rank(comm, &rank;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank == 0) {
|
|
Packit |
0848f5 |
/* This should be congruent to MPI_COMM_SELF */
|
|
Packit |
0848f5 |
MPI_Comm_compare(MPI_COMM_SELF, newcomm, &result);
|
|
Packit |
0848f5 |
if (result != MPI_CONGRUENT) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("cart sub to size 0 did not give self\n");
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPI_Comm_free(&newcomm);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else if (newcomm != MPI_COMM_NULL) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("cart sub to size 0 did not give null\n");
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Free the new communicator so that storage leak tests will
|
|
Packit |
0848f5 |
* be happy */
|
|
Packit |
0848f5 |
MPI_Comm_free(&comm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize(errs);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
}
|