@@ -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 ;
@@ -926,31 +909,23 @@ int MPIR_Comm_idup_with_info_impl(MPIR_Comm * comm_ptr, MPIR_Info * info,
926909int MPIR_Comm_remote_group_impl (MPIR_Comm * comm_ptr , MPIR_Group * * group_ptr )
927910{
928911 int mpi_errno = MPI_SUCCESS ;
929- int i , n ;
930-
931912 MPIR_FUNC_ENTER ;
913+
932914 /* Create a group and populate it with the local process ids */
933915 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 );
916+ int n = comm_ptr -> remote_size ;
917+ MPIR_Lpid * map = MPL_malloc (n * sizeof (MPIR_Lpid ), MPL_MEM_GROUP );
937918
938- for (i = 0 ; i < n ; i ++ ) {
919+ for (int i = 0 ; i < n ; i ++ ) {
939920 uint64_t lpid ;
940921 (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 */
922+ map [i ] = lpid ;
943923 }
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 ;
924+ mpi_errno = MPIR_Group_create_map (n , MPI_UNDEFINED , comm_ptr -> session_ptr , map ,
925+ & comm_ptr -> remote_group );
926+ MPIR_ERR_CHECK (mpi_errno );
953927 }
928+ * group_ptr = comm_ptr -> remote_group ;
954929 MPIR_Group_add_ref (comm_ptr -> remote_group );
955930
956931 fn_exit :
0 commit comments