|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
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 |
/*
|
|
Packit Service |
c5cf8c |
* This program tests the allocation (and deallocation) of contexts.
|
|
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 i, j, err;
|
|
Packit Service |
c5cf8c |
MPI_Comm newcomm1, newcomm2[200];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Get a separate communicator to duplicate */
|
|
Packit Service |
c5cf8c |
MPI_Comm_dup(MPI_COMM_WORLD, &newcomm1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Errhandler_set(newcomm1, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
/* Allocate many communicators in batches, then free them */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < 1000; i++) {
|
|
Packit Service |
c5cf8c |
for (j = 0; j < 200; j++) {
|
|
Packit Service |
c5cf8c |
err = MPI_Comm_dup(newcomm1, &newcomm2[j]);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < 10) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j);
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (j = 0; j < 200; j++) {
|
|
Packit Service |
c5cf8c |
err = MPI_Comm_free(&newcomm2[j]);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < 10) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Failed to free %d,%d\n", i, j);
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
err = MPI_Comm_free(&newcomm1);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Failed to free newcomm1\n");
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
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 |
}
|