|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2009 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define MAX_LOG_WSIZE 31
|
|
Packit Service |
c5cf8c |
#define MAX_LOOP 20
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_Group gworld, g;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm, newcomm[MAX_LOOP];
|
|
Packit Service |
c5cf8c |
int wsize, wrank, range[1][3], errs = 0;
|
|
Packit Service |
c5cf8c |
double t[MAX_LOG_WSIZE], tf;
|
|
Packit Service |
c5cf8c |
int maxi, i, k, ts, gsize[MAX_LOG_WSIZE];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &wsize);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (wrank == 0)
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "size\ttime\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_group(MPI_COMM_WORLD, &gworld);
|
|
Packit Service |
c5cf8c |
ts = 1;
|
|
Packit Service |
c5cf8c |
comm = MPI_COMM_WORLD;
|
|
Packit Service |
c5cf8c |
for (i = 0; ts <= wsize; i++, ts = ts + ts) {
|
|
Packit Service |
c5cf8c |
/* Create some groups with at most ts members */
|
|
Packit Service |
c5cf8c |
range[0][0] = ts - 1;
|
|
Packit Service |
c5cf8c |
range[0][1] = 0;
|
|
Packit Service |
c5cf8c |
range[0][2] = -1;
|
|
Packit Service |
c5cf8c |
MPI_Group_range_incl(gworld, 1, range, &g);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
tf = MPI_Wtime();
|
|
Packit Service |
c5cf8c |
for (k = 0; k < MAX_LOOP; k++)
|
|
Packit Service |
c5cf8c |
MPI_Comm_create(comm, g, &newcomm[k]);
|
|
Packit Service |
c5cf8c |
tf = MPI_Wtime() - tf;
|
|
Packit Service |
c5cf8c |
MPI_Allreduce(&tf, &t[i], 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
t[i] = t[i] / MAX_LOOP;
|
|
Packit Service |
c5cf8c |
gsize[i] = ts;
|
|
Packit Service |
c5cf8c |
if (wrank == 0)
|
|
Packit Service |
c5cf8c |
MTestPrintfMsg(1, "%d\t%e\n", ts, t[i]);
|
|
Packit Service |
c5cf8c |
MPI_Group_free(&g);
|
|
Packit Service |
c5cf8c |
if (newcomm[0] != MPI_COMM_NULL)
|
|
Packit Service |
c5cf8c |
for (k = 0; k < MAX_LOOP; k++)
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&newcomm[k]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Group_free(&gworld);
|
|
Packit Service |
c5cf8c |
maxi = i - 1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* The cost should be linear or at worst ts*log(ts).
|
|
Packit Service |
c5cf8c |
* We can check this in a number of ways.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
if (wrank == 0) {
|
|
Packit Service |
c5cf8c |
for (i = 4; i <= maxi; i++) {
|
|
Packit Service |
c5cf8c |
double rdiff;
|
|
Packit Service |
c5cf8c |
if (t[i] > 0) {
|
|
Packit Service |
c5cf8c |
rdiff = (t[i] - t[i - 1]) / t[i];
|
|
Packit Service |
c5cf8c |
if (rdiff >= 4) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr,
|
|
Packit Service |
c5cf8c |
"Relative difference between group of size %d and %d is %e exceeds 4\n",
|
|
Packit Service |
c5cf8c |
gsize[i - 1], gsize[i], rdiff);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
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 |
}
|