Blame test/mpi/comm/comm_idup_mul.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2013 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
/*
Packit 0848f5
 * Test creating multiple communicators with MPI_Comm_idup.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include <mpi.h>
Packit 0848f5
Packit 0848f5
#define NUM_ITER    10
Packit 0848f5
Packit 0848f5
int main(int argc, char **argv)
Packit 0848f5
{
Packit 0848f5
    int i, rank;
Packit 0848f5
    MPI_Comm comms[NUM_ITER];
Packit 0848f5
    MPI_Request req[NUM_ITER];
Packit 0848f5
Packit 0848f5
    MPI_Init(&argc, &argv);
Packit 0848f5
    MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
Packit 0848f5
Packit 0848f5
    for (i = 0; i < NUM_ITER; i++)
Packit 0848f5
        MPI_Comm_idup(MPI_COMM_WORLD, &comms[i], &req[i]);
Packit 0848f5
Packit 0848f5
    MPI_Waitall(NUM_ITER, req, MPI_STATUSES_IGNORE);
Packit 0848f5
Packit 0848f5
    for (i = 0; i < NUM_ITER; i++)
Packit 0848f5
        MPI_Comm_free(&comms[i]);
Packit 0848f5
Packit 0848f5
    if (rank == 0)
Packit 0848f5
        printf(" No Errors\n");
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}