Skip to content

Commit 1829bba

Browse files
authored
Merge pull request #10555 from hppritcha/fix_issue_10524
set instance field when creating new group objects
2 parents 5bc215a + 55cf3a5 commit 1829bba

File tree

11 files changed

+58
-70
lines changed

11 files changed

+58
-70
lines changed

ompi/communicator/comm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ int ompi_intercomm_create (ompi_communicator_t *local_comm, int local_leader, om
14111411
}
14121412

14131413
/* put group elements in the list */
1414-
new_group_pointer = ompi_group_allocate_plist_w_procs (rprocs, rsize);
1414+
new_group_pointer = ompi_group_allocate_plist_w_procs (local_comm->c_local_group, rprocs, rsize);
14151415
if (OPAL_UNLIKELY(NULL == new_group_pointer)) {
14161416
free (rprocs);
14171417
return MPI_ERR_GROUP;
@@ -1525,7 +1525,7 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
15251525
return OMPI_ERR_OUT_OF_RESOURCE;
15261526
}
15271527

1528-
leader_group = ompi_group_allocate_plist_w_procs (leader_procs, 2);
1528+
leader_group = ompi_group_allocate_plist_w_procs (NULL, leader_procs, 2);
15291529
ompi_set_group_rank (leader_group, my_proc);
15301530
if (OPAL_UNLIKELY(NULL == leader_group)) {
15311531
free (sub_tag);
@@ -1577,7 +1577,7 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
15771577

15781578
if (!i_am_leader) {
15791579
/* create a new group containing the remote processes for non-leader ranks */
1580-
remote_group = ompi_group_allocate_plist_w_procs (rprocs, rsize);
1580+
remote_group = ompi_group_allocate_plist_w_procs (local_group, rprocs, rsize);
15811581
if (OPAL_UNLIKELY(NULL == remote_group)) {
15821582
free (rprocs);
15831583
ompi_comm_free (&local_comm);
@@ -2341,6 +2341,10 @@ static int ompi_comm_fill_rest(ompi_communicator_t *comm,
23412341
int my_rank,
23422342
ompi_errhandler_t *errh)
23432343
{
2344+
ompi_group_t *new_group;
2345+
2346+
new_group = ompi_group_allocate_plist_w_procs(comm->c_local_group, proc_pointers, num_procs);
2347+
23442348
/* properly decrement the ref counts on the groups.
23452349
We are doing this because this function is sort of a redo
23462350
of what is done in comm.c. No need to decrement the ref
@@ -2356,7 +2360,7 @@ static int ompi_comm_fill_rest(ompi_communicator_t *comm,
23562360
}
23572361

23582362
/* allocate a group structure for the new communicator */
2359-
comm->c_local_group = ompi_group_allocate_plist_w_procs (proc_pointers, num_procs);
2363+
comm->c_local_group = new_group;
23602364

23612365
/* set the remote group to be the same as local group */
23622366
comm->c_remote_group = comm->c_local_group;

ompi/communicator/comm_init.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* and Technology (RIST). All rights reserved.
2424
* Copyright (c) 2015-2019 Intel, Inc. All rights reserved.
2525
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
26-
* Copyright (c) 2018-2019 Triad National Security, LLC. All rights
26+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2727
* reserved.
2828
* $COPYRIGHT$
2929
*
@@ -303,33 +303,6 @@ int ompi_comm_init_mpi3 (void)
303303
return OMPI_SUCCESS;
304304
}
305305

306-
307-
ompi_communicator_t *ompi_comm_allocate ( int local_size, int remote_size )
308-
{
309-
ompi_communicator_t *new_comm;
310-
311-
/* create new communicator element */
312-
new_comm = OBJ_NEW(ompi_communicator_t);
313-
new_comm->super.s_info = NULL;
314-
new_comm->c_local_group = ompi_group_allocate ( local_size );
315-
if ( 0 < remote_size ) {
316-
new_comm->c_remote_group = ompi_group_allocate (remote_size);
317-
new_comm->c_flags |= OMPI_COMM_INTER;
318-
} else {
319-
/*
320-
* simplifies some operations (e.g. p2p), if
321-
* we can always use the remote group
322-
*/
323-
new_comm->c_remote_group = new_comm->c_local_group;
324-
OBJ_RETAIN(new_comm->c_remote_group);
325-
}
326-
327-
/* fill in the inscribing hyper-cube dimensions */
328-
new_comm->c_cube_dim = opal_cube_dim(local_size);
329-
330-
return new_comm;
331-
}
332-
333306
static int ompi_comm_finalize (void)
334307
{
335308
int max, i;

ompi/communicator/communicator.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Copyright (c) 2015 Research Organization for Information Science
2323
* and Technology (RIST). All rights reserved.
2424
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
25-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
25+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2626
* reserved.
2727
* $COPYRIGHT$
2828
*
@@ -935,19 +935,6 @@ int ompi_comm_compare(ompi_communicator_t *comm1, ompi_communicator_t *comm2, in
935935
*/
936936
OMPI_DECLSPEC int ompi_comm_free (ompi_communicator_t **comm);
937937

938-
/**
939-
* allocate a new communicator structure
940-
* @param local_group_size
941-
* @param remote_group_size
942-
*
943-
* This routine allocates the structure, the according local and
944-
* remote groups, the proc-arrays in the local and remote group.
945-
* It furthermore sets the fortran index correctly,
946-
* and sets all other elements to zero.
947-
*/
948-
ompi_communicator_t* ompi_comm_allocate (int local_group_size,
949-
int remote_group_size);
950-
951938
/**
952939
* allocate new communicator ID
953940
* @param newcomm: pointer to the new communicator

ompi/dpm/dpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* and Technology (RIST). All rights reserved.
2222
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
2323
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
24-
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
24+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2525
* reserved.
2626
* $COPYRIGHT$
2727
*
@@ -485,7 +485,7 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root,
485485

486486
/* now deal with the remote group */
487487
rsize = opal_list_get_size(&rlist);
488-
new_group_pointer=ompi_group_allocate(rsize);
488+
new_group_pointer=ompi_group_allocate(NULL, rsize);
489489
if (NULL == new_group_pointer) {
490490
rc = OMPI_ERR_OUT_OF_RESOURCE;
491491
OPAL_LIST_DESTRUCT(&rlist);

ompi/group/group.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* reserved.
1919
* Copyright (c) 2016 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
21-
* Copyright (c) 2018 Triad National Security, LLC. All rights
21+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2222
* reserved.
2323
* $COPYRIGHT$
2424
*
@@ -163,15 +163,16 @@ OMPI_DECLSPEC extern struct opal_mutex_t ompi_group_afp_mutex;
163163
/**
164164
* Allocate a new group structure.
165165
*
166+
* @param orig_group Original group
166167
* @param group_size Number of MPI processes in the group
167168
*
168169
* @return Pointer to new group structure
169170
*/
170-
OMPI_DECLSPEC ompi_group_t *ompi_group_allocate(int group_size);
171-
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_size);
172-
ompi_group_t *ompi_group_allocate_sporadic(int group_size);
173-
ompi_group_t *ompi_group_allocate_strided(void);
174-
ompi_group_t *ompi_group_allocate_bmap(int orig_group_size, int group_size);
171+
OMPI_DECLSPEC ompi_group_t *ompi_group_allocate(ompi_group_t *orig_group, int group_size);
172+
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_group_t *orig_group, ompi_proc_t **procs, int group_size);
173+
ompi_group_t *ompi_group_allocate_sporadic(ompi_group_t *orig_group, int group_size);
174+
ompi_group_t *ompi_group_allocate_strided(ompi_group_t *orig_group);
175+
ompi_group_t *ompi_group_allocate_bmap(ompi_group_t *orig_group, int group_size);
175176

176177
/**
177178
* @brief Allocate a dense group from a group

ompi/group/group_bitmap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2022 Triad National Security, LLC. All rights
18+
* reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -159,7 +161,7 @@ int ompi_group_incl_bmap(ompi_group_t* group, int n, const int *ranks,
159161
return OMPI_SUCCESS;
160162
}
161163

162-
new_group_pointer = ompi_group_allocate_bmap(group->grp_proc_count, n);
164+
new_group_pointer = ompi_group_allocate_bmap(group, n);
163165
if( NULL == new_group_pointer ) {
164166
return MPI_ERR_GROUP;
165167
}

ompi/group/group_init.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19-
* Copyright (c) 2018 Triad National Security, LLC. All rights
19+
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2020
* reserved.
2121
* $COPYRIGHT$
2222
*
@@ -71,7 +71,7 @@ opal_mutex_t ompi_group_afp_mutex = OPAL_MUTEX_STATIC_INIT;
7171
/*
7272
* Allocate a new group structure
7373
*/
74-
ompi_group_t *ompi_group_allocate(int group_size)
74+
ompi_group_t *ompi_group_allocate(ompi_group_t *orig_group, int group_size)
7575
{
7676
/* local variables */
7777
ompi_proc_t **procs = calloc (group_size, sizeof (ompi_proc_t *));
@@ -81,15 +81,15 @@ ompi_group_t *ompi_group_allocate(int group_size)
8181
return NULL;
8282
}
8383

84-
new_group = ompi_group_allocate_plist_w_procs (procs, group_size);
84+
new_group = ompi_group_allocate_plist_w_procs (orig_group, procs, group_size);
8585
if (NULL == new_group) {
8686
free (procs);
8787
}
8888

8989
return new_group;
9090
}
9191

92-
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_size)
92+
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_group_t *orig_group, ompi_proc_t **procs, int group_size)
9393
{
9494
/* local variables */
9595
ompi_group_t * new_group = NULL;
@@ -121,12 +121,18 @@ ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_
121121
new_group->grp_my_rank = MPI_UNDEFINED;
122122
OMPI_GROUP_SET_DENSE(new_group);
123123

124+
if (NULL != orig_group) {
125+
new_group->grp_instance = orig_group->grp_instance;
126+
} else {
127+
new_group->grp_instance = NULL;
128+
}
129+
124130
ompi_group_increment_proc_count (new_group);
125131

126132
return new_group;
127133
}
128134

129-
ompi_group_t *ompi_group_allocate_sporadic(int group_size)
135+
ompi_group_t *ompi_group_allocate_sporadic(ompi_group_t *orig_group, int group_size)
130136
{
131137
/* local variables */
132138
ompi_group_t *new_group = NULL;
@@ -165,13 +171,14 @@ ompi_group_t *ompi_group_allocate_sporadic(int group_size)
165171
/* initialize our rank to MPI_UNDEFINED */
166172
new_group->grp_my_rank = MPI_UNDEFINED;
167173
new_group->grp_proc_pointers = NULL;
174+
new_group->grp_instance = orig_group->grp_instance;
168175
OMPI_GROUP_SET_SPORADIC(new_group);
169176

170177
error_exit:
171178
return new_group;
172179
}
173180

174-
ompi_group_t *ompi_group_allocate_strided(void)
181+
ompi_group_t *ompi_group_allocate_strided(ompi_group_t *orig_group)
175182
{
176183
ompi_group_t *new_group = NULL;
177184

@@ -188,6 +195,7 @@ ompi_group_t *ompi_group_allocate_strided(void)
188195
/* initialize our rank to MPI_UNDEFINED */
189196
new_group->grp_my_rank = MPI_UNDEFINED;
190197
new_group->grp_proc_pointers = NULL;
198+
new_group->grp_instance = orig_group->grp_instance;
191199
OMPI_GROUP_SET_STRIDED(new_group);
192200
new_group->sparse_data.grp_strided.grp_strided_stride = -1;
193201
new_group->sparse_data.grp_strided.grp_strided_offset = -1;
@@ -196,9 +204,13 @@ ompi_group_t *ompi_group_allocate_strided(void)
196204
/* return */
197205
return new_group;
198206
}
199-
ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)
207+
208+
ompi_group_t *ompi_group_allocate_bmap(ompi_group_t *orig_group , int group_size)
200209
{
201210
ompi_group_t *new_group = NULL;
211+
int orig_group_size;
212+
213+
orig_group_size = orig_group->grp_proc_count;
202214

203215
assert (group_size >= 0);
204216

@@ -224,6 +236,7 @@ ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)
224236
/* initialize our rank to MPI_UNDEFINED */
225237
new_group->grp_my_rank = MPI_UNDEFINED;
226238
new_group->grp_proc_pointers = NULL;
239+
new_group->grp_instance = orig_group->grp_instance;
227240
OMPI_GROUP_SET_BITMAP(new_group);
228241

229242
error_exit:

ompi/group/group_plist.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Copyright (c) 2016 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2017 Intel, Inc. All rights reserved.
20+
* Copyright (c) 2022 Triad National Security, LLC. All rights
21+
* reserved.
2022
* $COPYRIGHT$
2123
*
2224
* Additional copyrights may follow
@@ -81,7 +83,7 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, const int *ranks,
8183
}
8284

8385
/* get new group struct */
84-
new_group_pointer=ompi_group_allocate(n);
86+
new_group_pointer=ompi_group_allocate(group,n);
8587
if( NULL == new_group_pointer ) {
8688
return MPI_ERR_GROUP;
8789
}
@@ -103,6 +105,8 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, const int *ranks,
103105
new_group_pointer->grp_my_rank = MPI_UNDEFINED;
104106
}
105107

108+
new_group_pointer->grp_instance = group->grp_instance;
109+
106110
*new_group = (MPI_Group)new_group_pointer;
107111

108112
return OMPI_SUCCESS;
@@ -148,7 +152,7 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
148152
}
149153

150154
/* get new group struct */
151-
new_group_pointer = ompi_group_allocate(new_group_size);
155+
new_group_pointer = ompi_group_allocate(group1, new_group_size);
152156
if (NULL == new_group_pointer) {
153157
OBJ_DESTRUCT(&bitmap);
154158
return MPI_ERR_GROUP;
@@ -230,7 +234,7 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
230234
}
231235

232236
/* allocate a new ompi_group_t structure */
233-
new_group_pointer = ompi_group_allocate(new_group_size);
237+
new_group_pointer = ompi_group_allocate(group1, new_group_size);
234238
if( NULL == new_group_pointer ) {
235239
OBJ_DESTRUCT(&bitmap);
236240
return MPI_ERR_GROUP;

ompi/group/group_sporadic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2022 Triad National Security, LLC. All rights
18+
* reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -144,7 +146,7 @@ int ompi_group_incl_spor(ompi_group_t* group, int n, const int *ranks,
144146
}
145147
}
146148

147-
new_group_pointer = ompi_group_allocate_sporadic(l);
149+
new_group_pointer = ompi_group_allocate_sporadic(group,l);
148150
if( NULL == new_group_pointer ) {
149151
return MPI_ERR_GROUP;
150152
}

ompi/group/group_strided.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2022 Triad National Security, LLC. All rights
18+
* reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -117,7 +119,7 @@ int ompi_group_incl_strided(ompi_group_t* group, int n, const int *ranks,
117119
}
118120

119121
stride = check_stride(ranks,n);
120-
new_group_pointer = ompi_group_allocate_strided();
122+
new_group_pointer = ompi_group_allocate_strided(group);
121123
if( NULL == new_group_pointer ) {
122124
return MPI_ERR_GROUP;
123125
}

ompi/instance/instance.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ static int ompi_instance_group_world (ompi_instance_t *instance, ompi_group_t **
10991099

11001100
size = ompi_process_info.num_procs;
11011101

1102-
group = ompi_group_allocate (size);
1102+
group = ompi_group_allocate (NULL,size);
11031103
if (OPAL_UNLIKELY(NULL == group)) {
11041104
return OMPI_ERR_OUT_OF_RESOURCE;
11051105
}
@@ -1150,7 +1150,7 @@ static int ompi_instance_group_shared (ompi_instance_t *instance, ompi_group_t *
11501150

11511151
size = opal_argv_count (peers);
11521152

1153-
group = ompi_group_allocate (size);
1153+
group = ompi_group_allocate (NULL,size);
11541154
if (OPAL_UNLIKELY(NULL == group)) {
11551155
opal_argv_free (peers);
11561156
return OMPI_ERR_OUT_OF_RESOURCE;
@@ -1212,7 +1212,7 @@ static int ompi_instance_group_pmix_pset (ompi_instance_t *instance, const char
12121212
size_t size = 0;
12131213

12141214
/* make the group large enough to hold world */
1215-
group = ompi_group_allocate (ompi_process_info.num_procs);
1215+
group = ompi_group_allocate (NULL, ompi_process_info.num_procs);
12161216
if (OPAL_UNLIKELY(NULL == group)) {
12171217
return OMPI_ERR_OUT_OF_RESOURCE;
12181218
}

0 commit comments

Comments
 (0)