|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2012 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* This test attempts to create a large number of communicators, in an effort
|
|
Packit Service |
c5cf8c |
* to exceed the number of communicators that the MPI implementation can
|
|
Packit Service |
c5cf8c |
* provide. It checks that the implementation detects this error correctly
|
|
Packit Service |
c5cf8c |
* handles it.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* In this version, we duplicate MPI_COMM_WORLD in a non-blocking
|
|
Packit Service |
c5cf8c |
* fashion until we run out of context IDs. */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <mpi.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define MAX_NCOMM 100000
|
|
Packit Service |
c5cf8c |
#define WAIT_COMM 7
|
|
Packit Service |
c5cf8c |
static const int verbose = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int rank, nproc, mpi_errno;
|
|
Packit Service |
c5cf8c |
int i, j, ncomm, block;
|
|
Packit Service |
c5cf8c |
int errs = 1;
|
|
Packit Service |
c5cf8c |
MPI_Comm *comm_hdls;
|
|
Packit Service |
c5cf8c |
MPI_Request req[WAIT_COMM];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
MPI_Status error_status[WAIT_COMM];
|
|
Packit Service |
c5cf8c |
comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ncomm = 0;
|
|
Packit Service |
c5cf8c |
block = 0;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MAX_NCOMM; i++) {
|
|
Packit Service |
c5cf8c |
/* Note: the comms we create are all dups of MPI_COMM_WORLD */
|
|
Packit Service |
c5cf8c |
MPI_Comm_idup(MPI_COMM_WORLD, &comm_hdls[i], &req[block++]);
|
|
Packit Service |
c5cf8c |
if (block == WAIT_COMM) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Waitall(block, req, error_status);
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ncomm += block;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (verbose)
|
|
Packit Service |
c5cf8c |
printf("%d: Error creating comm %d\n", rank, i);
|
|
Packit Service |
c5cf8c |
for (j = 0; j < block; j++) {
|
|
Packit Service |
c5cf8c |
if (error_status[j].MPI_ERROR == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ncomm += 1;
|
|
Packit Service |
c5cf8c |
} else if (error_status[j].MPI_ERROR == MPI_ERR_PENDING) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Wait(&req[j], MPI_STATUSES_IGNORE);
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ncomm += 1;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (verbose)
|
|
Packit Service |
c5cf8c |
printf("%d: Error creating comm %d\n", rank, i);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
errs = 0;
|
|
Packit Service |
c5cf8c |
block = 0;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
block = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (block != 0) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Waitall(block, req, MPI_STATUSES_IGNORE);
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ncomm += block;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (verbose)
|
|
Packit Service |
c5cf8c |
printf("%d: Error creating comm %d\n", rank, i);
|
|
Packit Service |
c5cf8c |
errs = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (i = 0; i < ncomm; i++)
|
|
Packit Service |
c5cf8c |
MPI_Comm_free(&comm_hdls[i]);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
free(comm_hdls);
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|