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