|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2008 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 |
/*
|
|
Packit Service |
c5cf8c |
Check that the MPI implementation properly handles zero-dimensional
|
|
Packit Service |
c5cf8c |
Cartesian communicators - the original standard implies that these
|
|
Packit Service |
c5cf8c |
should be consistent with higher dimensional topologies and thus
|
|
Packit Service |
c5cf8c |
these should work with any MPI implementation. MPI 2.1 made this
|
|
Packit Service |
c5cf8c |
requirement explicit.
|
|
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, rank, ndims;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm, newcomm;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Create a new cartesian communicator in a subset of the processes */
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
if (size < 2) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "This test needs at least 2 processes\n");
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Cart_create(MPI_COMM_WORLD, 0, NULL, NULL, 0, &comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (comm != MPI_COMM_NULL) {
|
|
Packit Service |
c5cf8c |
int csize;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(comm, &csize);
|
|
Packit Service |
c5cf8c |
if (csize != 1) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Sizes is wrong in cart communicator. Is %d, should be 1\n", csize);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* This function is not meaningful, but should not fail */
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(1, 0, NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ndims = -1;
|
|
Packit Service |
c5cf8c |
MPI_Cartdim_get(comm, &ndims);
|
|
Packit Service |
c5cf8c |
if (ndims != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "MPI_Cartdim_get: ndims is %d, should be 0\n", ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* this function should not fail */
|
|
Packit Service |
c5cf8c |
MPI_Cart_get(comm, 0, NULL, NULL, NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Cart_rank(comm, NULL, &rank;;
|
|
Packit Service |
c5cf8c |
if (rank != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "MPI_Cart_rank: rank is %d, should be 0\n", rank);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* this function should not fail */
|
|
Packit Service |
c5cf8c |
MPI_Cart_coords(comm, 0, 0, NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Cart_sub(comm, NULL, &newcomm);
|
|
Packit Service |
c5cf8c |
ndims = -1;
|
|
Packit Service |
c5cf8c |
MPI_Cartdim_get(newcomm, &ndims);
|
|
Packit Service |
c5cf8c |
if (ndims != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "MPI_Cart_sub did not return zero-dimensional communicator\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&newcomm);
|
|
Packit Service |
c5cf8c |
} else if (rank == 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Communicator returned is null!");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|