Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / topo / dims3.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2003 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include "mpi.h"
7 #include <stdio.h>
8 #include "mpitest.h"
9
10 static inline void print_err(int *dims, int ndims)
11 {
12     int i;
13
14     printf("[ ");
15     for (i = 0; i < ndims; i++)
16         printf("%d ", dims[i]);
17     printf("] Suboptimal distribution!\n");
18 }
19
20 int main(int argc, char **argv)
21 {
22     int errs = 0;
23     int dims[4], ndims, nnodes;
24
25     MTest_Init(&argc, &argv);
26
27     for (ndims = 3; ndims <= 4; ndims++) {
28         for (nnodes = 2; nnodes <= 4096; nnodes *= 2) {
29             int i;
30             for (i = 0; i < ndims; i++)
31                 dims[i] = 0;
32
33             MPI_Dims_create(nnodes, ndims, dims);
34
35             /* Checking */
36             for (i = 0; i < ndims - 1; i++)
37                 if (dims[i] / 2 > dims[i + 1]) {
38                     print_err(dims, ndims);
39                     ++errs;
40                     break;
41                 }
42         }
43     }
44
45     MTest_Finalize(errs);
46     MPI_Finalize();
47
48     return 0;
49 }