|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2015 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include "mpitestconf.h"
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include <string.h>
|
|
Packit |
0848f5 |
#include <stdlib.h>
|
|
Packit |
0848f5 |
#include <assert.h>
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int size, rank;
|
|
Packit |
0848f5 |
MPI_Group world_group;
|
|
Packit |
0848f5 |
MPI_Comm group_comm, idup_comm;
|
|
Packit |
0848f5 |
MPI_Request req;
|
|
Packit |
0848f5 |
MPI_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (size % 2) {
|
|
Packit |
0848f5 |
fprintf(stderr, "this program requires even number of processes\n");
|
|
Packit |
0848f5 |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Create some groups */
|
|
Packit |
0848f5 |
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (rank % 2 == 0) {
|
|
Packit |
0848f5 |
MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm);
|
|
Packit |
0848f5 |
MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req;;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
MPI_Comm_idup(MPI_COMM_WORLD, &idup_comm, &req;;
|
|
Packit |
0848f5 |
MPI_Comm_create_group(MPI_COMM_WORLD, world_group, 0, &group_comm);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Wait(&req, MPI_STATUSES_IGNORE);
|
|
Packit |
0848f5 |
/*Test new comm with a barrier */
|
|
Packit |
0848f5 |
MPI_Barrier(idup_comm);
|
|
Packit |
0848f5 |
MPI_Barrier(group_comm);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Group_free(&world_group);
|
|
Packit |
0848f5 |
MPI_Comm_free(&idup_comm);
|
|
Packit |
0848f5 |
MPI_Comm_free(&group_comm);
|
|
Packit |
0848f5 |
if (rank == 0)
|
|
Packit |
0848f5 |
printf(" No errors\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|