@@ -1784,22 +1784,22 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
17841784 leader_procs [1 ] = tmp ;
17851785 }
17861786
1787- /* create a unique tag for allocating the leader communicator. we can eliminate this step
1788- * if we take a CID from the newly allocated block belonging to local_comm. this is
1789- * a note to make this change at a later time. */
1790- opal_asprintf (& sub_tag , "%s-OMPIi-LC" , tag );
1791- if (OPAL_UNLIKELY (NULL == sub_tag )) {
1792- ompi_comm_free (& local_comm );
1787+ leader_group = ompi_group_allocate_plist_w_procs (NULL , leader_procs , 2 );
1788+ ompi_set_group_rank (leader_group , my_proc );
1789+ if (OPAL_UNLIKELY (NULL == leader_group )) {
17931790 free (leader_procs );
1791+ ompi_comm_free (& local_comm );
17941792 return OMPI_ERR_OUT_OF_RESOURCE ;
17951793 }
17961794
1797- leader_group = ompi_group_allocate_plist_w_procs (NULL , leader_procs , 2 );
1798- ompi_set_group_rank (leader_group , my_proc );
1799- if (OPAL_UNLIKELY (NULL == leader_group )) {
1800- free (sub_tag );
1795+ /* create a unique tag for allocating the leader communicator. we can eliminate this step
1796+ * if we take a CID from the newly allocated block belonging to local_comm. this is
1797+ * a note to make this change at a later time. */
1798+ opal_asprintf (& sub_tag , "%s-OMPIi-LC-%s" , tag , OPAL_NAME_PRINT (ompi_group_get_proc_name (leader_group , 0 )));
1799+ if (OPAL_UNLIKELY (NULL == sub_tag )) {
18011800 free (leader_procs );
18021801 ompi_comm_free (& local_comm );
1802+ OBJ_RELEASE (leader_group );
18031803 return OMPI_ERR_OUT_OF_RESOURCE ;
18041804 }
18051805
@@ -1809,6 +1809,7 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
18091809 rc = ompi_comm_create_from_group (leader_group , sub_tag , info , errhandler , & leader_comm );
18101810 OBJ_RELEASE (leader_group );
18111811 free (sub_tag );
1812+ sub_tag = NULL ;
18121813 if (OPAL_UNLIKELY (OMPI_SUCCESS != rc )) {
18131814 free (leader_procs );
18141815 ompi_comm_free (& local_comm );
@@ -1864,7 +1865,16 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead
18641865 return rc ;
18651866 }
18661867
1867- rc = ompi_comm_nextcid (newcomp , NULL , NULL , (void * ) tag , NULL , false, OMPI_COMM_CID_GROUP_NEW );
1868+ /*
1869+ * append the pmix CONTEXT_ID obtained when creating the leader comm as discriminator
1870+ */
1871+ opal_asprintf (& sub_tag , "%s-%ld" , tag , data [1 ]);
1872+ if (OPAL_UNLIKELY (NULL == sub_tag )) {
1873+ return OMPI_ERR_OUT_OF_RESOURCE ;
1874+ }
1875+
1876+ rc = ompi_comm_nextcid (newcomp , NULL , NULL , (void * ) sub_tag , NULL , false, OMPI_COMM_CID_GROUP_NEW );
1877+ free (sub_tag );
18681878 if ( OMPI_SUCCESS != rc ) {
18691879 OBJ_RELEASE (newcomp );
18701880 return rc ;
0 commit comments