1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2001 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
8 /* stdlib.h Needed for malloc declaration */
11 int main(int argc, char **argv)
13 int i, n, n_goal = 2048, n_all, rc, n_ranks, *ranks, rank, size, len;
15 MPI_Group *group_array, world_group;
16 char msg[MPI_MAX_ERROR_STRING];
18 MPI_Init(&argc, &argv);
19 MPI_Comm_size(MPI_COMM_WORLD, &size);
20 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
23 group_array = (MPI_Group *) malloc(n * sizeof(MPI_Group));
25 MPI_Comm_group(MPI_COMM_WORLD, &world_group);
28 ranks = (int *) malloc(size * sizeof(int));
29 for (i = 0; i < size; i++)
32 MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
33 for (i = 0; i < n; i++) {
34 rc = MPI_Group_incl(world_group, n_ranks, ranks, group_array + i);
36 fprintf(stderr, "Error when creating group number %d\n", i);
37 MPI_Error_string(rc, msg, &len);
38 fprintf(stderr, "%s\n", msg);
43 /* Check that the group was created (and that any errors were
45 rc = MPI_Group_size(group_array[i], &group_size);
46 if (group_size != size) {
47 fprintf(stderr, "Group number %d not correct (size = %d)\n", i, size);
55 for (i = 0; i < n; i++) {
56 rc = MPI_Group_free(group_array + i);
58 fprintf(stderr, "Error when freeing group number %d\n", i);
59 MPI_Error_string(rc, msg, &len);
60 fprintf(stderr, "%s\n", msg);
65 MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
66 MPI_Group_free(&world_group);
68 MPI_Reduce(&n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
70 /* printf("Completed test of %d type creations\n", n_all); */
71 if (n_all != n_goal) {
72 printf("This MPI implementation limits the number of groups that can be created\n\
73 This is allowed by the standard and is not a bug, but is a limit on the\n\
77 printf(" No Errors\n");