@@ -68,6 +68,9 @@ struct ompi_group_bitmap_data_t
6868 int grp_bitmap_array_len ; /* length of the bit array */
6969};
7070
71+ #define OMPI_GROUP_ALLOCATE 0x01
72+ #define OMPI_GROUP_LOCK 0x02
73+
7174/**
7275 * Group structure
7376 * Currently we have four formats for storing the process pointers that are members
@@ -337,15 +340,14 @@ int ompi_group_minloc (int list[], int length);
337340 * @brief Helper function for retreiving the proc of a group member in a dense group
338341 *
339342 * This function exists to handle the translation of sentinel group members to real
340- * ompi_proc_t's. If a sentinel value is found and allocate is true then this function
343+ * ompi_proc_t's. If a sentinel value is found and allocate bit is true then this function
341344 * looks for an existing ompi_proc_t using ompi_proc_for_name which will allocate a
342- * ompi_proc_t if one does not exist. If allocate is false then sentinel values translate
345+ * ompi_proc_t if one does not exist. If allocate bit is false then sentinel values translate
343346 * to NULL.
344347 */
345- static inline struct ompi_proc_t * ompi_group_dense_lookup (ompi_group_t * group , const int peer_id , const bool allocate )
348+ static inline struct ompi_proc_t * ompi_group_dense_lookup (ompi_group_t * group , const int peer_id , unsigned char flags )
346349{
347- ompi_proc_t * proc ;
348-
350+ ompi_proc_t * proc , * real_proc ;
349351#if OPAL_ENABLE_DEBUG
350352 if (peer_id >= group -> grp_proc_count ) {
351353 opal_output (0 , "ompi_group_dense_lookup: invalid peer index (%d)" , peer_id );
@@ -356,13 +358,17 @@ static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group,
356358 proc = group -> grp_proc_pointers [peer_id ];
357359
358360 if (OPAL_UNLIKELY (ompi_proc_is_sentinel (proc ))) {
359- if (! allocate ) {
361+ if (flags == 0 ) {
360362 return NULL ;
361363 }
362-
363364 /* replace sentinel value with an actual ompi_proc_t */
364- ompi_proc_t * real_proc =
365- (ompi_proc_t * ) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t ) proc ));
365+ if ((flags & OMPI_GROUP_LOCK ) == OMPI_GROUP_LOCK ) {
366+ real_proc =
367+ (ompi_proc_t * ) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t ) proc ));
368+ } else {
369+ real_proc =
370+ (ompi_proc_t * ) ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((uintptr_t ) proc ));
371+ }
366372
367373 if (opal_atomic_compare_exchange_strong_ptr ((opal_atomic_intptr_t * )(group -> grp_proc_pointers + peer_id ),
368374 (intptr_t * ) & proc , (intptr_t ) real_proc )) {
@@ -379,19 +385,19 @@ static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group,
379385 * This is the function that iterates through the sparse groups to the dense group
380386 * to reach the process pointer
381387 */
382- static inline ompi_proc_t * ompi_group_get_proc_ptr (ompi_group_t * group , int rank , const bool allocate )
388+ static inline ompi_proc_t * ompi_group_get_proc_ptr (ompi_group_t * group , int rank , unsigned char flags )
383389{
384390#if OMPI_GROUP_SPARSE
385391 do {
386392 if (OMPI_GROUP_IS_DENSE (group )) {
387- return ompi_group_dense_lookup (group , rank , allocate );
393+ return ompi_group_dense_lookup (group , rank , flags );
388394 }
389395 int ranks1 = rank ;
390396 ompi_group_translate_ranks (group , 1 , & ranks1 , group -> grp_parent_group_ptr , & rank );
391397 group = group -> grp_parent_group_ptr ;
392398 } while (1 );
393399#else
394- return ompi_group_dense_lookup (group , rank , allocate );
400+ return ompi_group_dense_lookup (group , rank , flags );
395401#endif
396402}
397403
@@ -420,12 +426,17 @@ static inline opal_process_name_t ompi_group_get_proc_name (ompi_group_t *group,
420426 */
421427static inline struct ompi_proc_t * ompi_group_peer_lookup (ompi_group_t * group , int peer_id )
422428{
423- return ompi_group_get_proc_ptr (group , peer_id , true);
429+ return ompi_group_get_proc_ptr (group , peer_id , (unsigned char ) (OMPI_GROUP_ALLOCATE | OMPI_GROUP_LOCK ));
430+ }
431+
432+ static inline struct ompi_proc_t * ompi_group_peer_lookup_nolock (ompi_group_t * group , int peer_id )
433+ {
434+ return ompi_group_get_proc_ptr (group , peer_id , (unsigned char ) OMPI_GROUP_ALLOCATE );
424435}
425436
426437static inline struct ompi_proc_t * ompi_group_peer_lookup_existing (ompi_group_t * group , int peer_id )
427438{
428- return ompi_group_get_proc_ptr (group , peer_id , false );
439+ return ompi_group_get_proc_ptr (group , peer_id , ( unsigned char ) 0 );
429440}
430441
431442#if OPAL_ENABLE_FT_MPI
0 commit comments