|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
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 prodof(int ndims, const int dims[]);
|
|
Packit Service |
c5cf8c |
int increasing(int ndims, const int dims[]);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int prodof(int ndims, const int dims[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i, prod = 1;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < ndims; i++)
|
|
Packit Service |
c5cf8c |
prod *= dims[i];
|
|
Packit Service |
c5cf8c |
return prod;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int increasing(int ndims, const int dims[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i, err = 0;
|
|
Packit Service |
c5cf8c |
for (i = 1; i < ndims; i++) {
|
|
Packit Service |
c5cf8c |
if (dims[i] > dims[i - 1]) {
|
|
Packit Service |
c5cf8c |
printf("%d = dims[%d] > dims[%d] = %d\n", dims[i], i, i - 1, dims[i - 1]);
|
|
Packit Service |
c5cf8c |
err = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return err;
|
|
Packit Service |
c5cf8c |
}
|
|
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 dims[4], nnodes, ndims;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Test multiple dims create values. For each, make sure that the
|
|
Packit Service |
c5cf8c |
* product of dims is the number of input nodes */
|
|
Packit Service |
c5cf8c |
nnodes = 2 * 3 * 5 * 7 * 11;
|
|
Packit Service |
c5cf8c |
ndims = 2;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Test multiple dims create values. For each, make sure that the
|
|
Packit Service |
c5cf8c |
* product of dims is the number of input nodes */
|
|
Packit Service |
c5cf8c |
nnodes = 2 * 7;
|
|
Packit Service |
c5cf8c |
ndims = 2;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
nnodes = 2 * 2 * 3 * 3 * 5 * 7 * 11;
|
|
Packit Service |
c5cf8c |
ndims = 2;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
nnodes = 11;
|
|
Packit Service |
c5cf8c |
ndims = 2;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
nnodes = 5 * 7 * 11;
|
|
Packit Service |
c5cf8c |
ndims = 4;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = dims[2] = dims[3] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
nnodes = 64;
|
|
Packit Service |
c5cf8c |
ndims = 4;
|
|
Packit Service |
c5cf8c |
dims[0] = dims[1] = dims[2] = dims[3] = 0;
|
|
Packit Service |
c5cf8c |
MPI_Dims_create(nnodes, ndims, dims);
|
|
Packit Service |
c5cf8c |
if (prodof(ndims, dims) != nnodes) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (increasing(ndims, dims)) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf
|
|
Packit Service |
c5cf8c |
("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
|
|
Packit Service |
c5cf8c |
printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|