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