@@ -68,36 +68,19 @@ int MPIR_Comm_test_threadcomm_impl(MPIR_Comm * comm_ptr, int *flag)
6868static int comm_create_local_group (MPIR_Comm * comm_ptr )
6969{
7070 int mpi_errno = MPI_SUCCESS ;
71- MPIR_Group * group_ptr ;
72- int n = comm_ptr -> local_size ;
73-
74- mpi_errno = MPIR_Group_create (n , & group_ptr );
75- MPIR_ERR_CHECK (mpi_errno );
7671
77- /* Group belongs to the same session as communicator */
78- MPIR_Group_set_session_ptr (group_ptr , comm_ptr -> session_ptr );
79-
80- group_ptr -> is_local_dense_monotonic = TRUE;
72+ int n = comm_ptr -> local_size ;
73+ MPIR_Lpid * map = MPL_malloc (n * sizeof (MPIR_Lpid ), MPL_MEM_GROUP );
8174
82- int comm_world_size = MPIR_Process .size ;
8375 for (int i = 0 ; i < n ; i ++ ) {
8476 uint64_t lpid ;
8577 (void ) MPID_Comm_get_lpid (comm_ptr , i , & lpid , FALSE);
86- group_ptr -> lrank_to_lpid [i ].lpid = lpid ;
87- if (lpid > comm_world_size || (i > 0 && group_ptr -> lrank_to_lpid [i - 1 ].lpid != (lpid - 1 ))) {
88- group_ptr -> is_local_dense_monotonic = FALSE;
89- }
78+ map [i ] = lpid ;
9079 }
9180
92- group_ptr -> size = n ;
93- group_ptr -> rank = comm_ptr -> rank ;
94- group_ptr -> idx_of_first_lpid = -1 ;
95-
96- comm_ptr -> local_group = group_ptr ;
97-
98- /* FIXME : Add a sanity check that the size of the group is the same as
99- * the size of the communicator. This helps catch corrupted
100- * communicators */
81+ mpi_errno = MPIR_Group_create_map (n , comm_ptr -> rank , comm_ptr -> session_ptr , map ,
82+ & comm_ptr -> local_group );
83+ MPIR_ERR_CHECK (mpi_errno );
10184
10285 fn_exit :
10386 return mpi_errno ;
@@ -215,16 +198,13 @@ int MPII_Comm_create_calculate_mapping(MPIR_Group * group_ptr,
215198 * exactly the same as the ranks in comm world.
216199 */
217200
218- /* we examine the group's lpids in both the intracomm and non-comm_world cases */
219- MPII_Group_setup_lpid_list (group_ptr );
220-
221201 /* Optimize for groups contained within MPI_COMM_WORLD. */
222202 if (comm_ptr -> comm_kind == MPIR_COMM_KIND__INTRACOMM ) {
223203 int wsize ;
224204 subsetOfWorld = 1 ;
225205 wsize = MPIR_Process .size ;
226206 for (i = 0 ; i < n ; i ++ ) {
227- uint64_t g_lpid = group_ptr -> lrank_to_lpid [ i ]. lpid ;
207+ MPIR_Lpid g_lpid = MPIR_Group_rank_to_lpid ( group_ptr , i ) ;
228208
229209 /* This mapping is relative to comm world */
230210 MPL_DBG_MSG_FMT (MPIR_DBG_COMM , VERBOSE ,
@@ -261,7 +241,7 @@ int MPII_Comm_create_calculate_mapping(MPIR_Group * group_ptr,
261241 for (j = 0 ; j < comm_ptr -> local_size ; j ++ ) {
262242 uint64_t comm_lpid ;
263243 MPID_Comm_get_lpid (comm_ptr , j , & comm_lpid , FALSE);
264- if (comm_lpid == group_ptr -> lrank_to_lpid [ i ]. lpid ) {
244+ if (comm_lpid == MPIR_Group_rank_to_lpid ( group_ptr , i ) ) {
265245 mapping [i ] = j ;
266246 break ;
267247 }
@@ -795,7 +775,7 @@ int MPIR_Intercomm_create_from_groups_impl(MPIR_Group * local_group_ptr, int loc
795775
796776 int tag = get_tag_from_stringtag (stringtag );
797777 /* FIXME: ensure lpid is from comm_world */
798- uint64_t remote_lpid = remote_group_ptr -> lrank_to_lpid [ remote_leader ]. lpid ;
778+ MPIR_Lpid remote_lpid = MPIR_Group_rank_to_lpid ( remote_group_ptr , remote_leader ) ;
799779 MPIR_Assert (remote_lpid < MPIR_Process .size );
800780 mpi_errno = MPIR_Intercomm_create_impl (local_comm , local_leader ,
801781 MPIR_Process .comm_world , (int ) remote_lpid ,
@@ -926,31 +906,23 @@ int MPIR_Comm_idup_with_info_impl(MPIR_Comm * comm_ptr, MPIR_Info * info,
926906int MPIR_Comm_remote_group_impl (MPIR_Comm * comm_ptr , MPIR_Group * * group_ptr )
927907{
928908 int mpi_errno = MPI_SUCCESS ;
929- int i , n ;
930-
931909 MPIR_FUNC_ENTER ;
910+
932911 /* Create a group and populate it with the local process ids */
933912 if (!comm_ptr -> remote_group ) {
934- n = comm_ptr -> remote_size ;
935- mpi_errno = MPIR_Group_create (n , group_ptr );
936- MPIR_ERR_CHECK (mpi_errno );
913+ int n = comm_ptr -> remote_size ;
914+ MPIR_Lpid * map = MPL_malloc (n * sizeof (MPIR_Lpid ), MPL_MEM_GROUP );
937915
938- for (i = 0 ; i < n ; i ++ ) {
916+ for (int i = 0 ; i < n ; i ++ ) {
939917 uint64_t lpid ;
940918 (void ) MPID_Comm_get_lpid (comm_ptr , i , & lpid , TRUE);
941- (* group_ptr )-> lrank_to_lpid [i ].lpid = lpid ;
942- /* TODO calculate is_local_dense_monotonic */
919+ map [i ] = lpid ;
943920 }
944- (* group_ptr )-> size = n ;
945- (* group_ptr )-> rank = MPI_UNDEFINED ;
946- (* group_ptr )-> idx_of_first_lpid = -1 ;
947-
948- MPIR_Group_set_session_ptr (* group_ptr , comm_ptr -> session_ptr );
949-
950- comm_ptr -> remote_group = * group_ptr ;
951- } else {
952- * group_ptr = comm_ptr -> remote_group ;
921+ mpi_errno = MPIR_Group_create_map (n , MPI_UNDEFINED , comm_ptr -> session_ptr , map ,
922+ & comm_ptr -> remote_group );
923+ MPIR_ERR_CHECK (mpi_errno );
953924 }
925+ * group_ptr = comm_ptr -> remote_group ;
954926 MPIR_Group_add_ref (comm_ptr -> remote_group );
955927
956928 fn_exit :
0 commit comments