@@ -150,38 +150,24 @@ static int set_broker_mapping_attr (attr_t *attrs, struct taskmap *map)
150150 return 0 ;
151151}
152152
153- /* Count the number of TBON children that could be reached by IPC .
153+ /* Return the number of ranks[] members that are in the same clique as rank .
154154 */
155- static int count_local_children (struct taskmap * map ,
156- int * child_ranks ,
157- int child_count ,
158- int rank )
155+ static int clique_ranks (struct taskmap * map , int rank , int * ranks , int nranks )
159156{
160157 int count = 0 ;
161158
162159 if (map ) {
163- int nodeid = taskmap_nodeid (map , rank ); // this broker's nodeid
164- if (nodeid >= 0 ) {
165- for (int i = 0 ; i < child_count ; i ++ ) {
166- if (taskmap_nodeid (map , child_ranks [i ]) == nodeid )
160+ int nid = taskmap_nodeid (map , rank );
161+ if (nid >= 0 ) {
162+ for (int i = 0 ; i < nranks ; i ++ ) {
163+ if (taskmap_nodeid (map , ranks [i ]) == nid )
167164 count ++ ;
168165 }
169166 }
170167 }
171168 return count ;
172169}
173170
174- static bool ranks_are_peers (struct taskmap * map , int rank1 , int rank2 )
175- {
176- int nid1 ;
177- int nid2 ;
178-
179- if ((nid1 = taskmap_nodeid (map , rank1 )) < 0
180- || (nid2 = taskmap_nodeid (map , rank2 )) < 0 )
181- return false;
182- return (nid1 == nid2 ? true : false);
183- }
184-
185171/* Check if TCP should be used, even if IPC could work.
186172 */
187173static bool get_prefer_tcp (attr_t * attrs )
@@ -532,10 +518,7 @@ int boot_pmi (const char *hostname, struct overlay *overlay, attr_t *attrs)
532518 char tcp [1024 ];
533519 char ipc [1024 ];
534520
535- nlocal = count_local_children (taskmap ,
536- child_ranks ,
537- child_count ,
538- info .rank );
521+ nlocal = clique_ranks (taskmap , info .rank , child_ranks , child_count );
539522
540523 if (format_tcp_uri (tcp , sizeof (tcp ), attrs , & error ) < 0 ) {
541524 log_err ("%s" , error .text );
@@ -600,7 +583,7 @@ int boot_pmi (const char *hostname, struct overlay *overlay, attr_t *attrs)
600583 goto error ;
601584 }
602585 if (!get_prefer_tcp (attrs )
603- && ranks_are_peers (taskmap , info .rank , parent_rank ) )
586+ && clique_ranks (taskmap , info .rank , & parent_rank , 1 ) == 1 )
604587 uri = bizcard_uri_find (bc , "ipc://" );
605588 if (!uri )
606589 uri = bizcard_uri_find (bc , NULL );
0 commit comments