1+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12/*
23 * Copyright (c) 2009-2012 Oak Ridge National Laboratory. All rights reserved.
34 * Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved.
5+ * Copyright (c) 2016 Los Alamos National Security, LLC. All rights
6+ * reserved.
47 * $COPYRIGHT$
58 *
69 * Additional copyrights may follow
@@ -72,7 +75,7 @@ int bcol_basesmuma_k_nomial_barrier_init(bcol_function_args_t *input_args,
7275 int pow_k , tree_order ;
7376 int max_requests = 0 ; /* important to initialize this */
7477
75- int matched = 0 ;
78+ bool matched ;
7679 int64_t sequence_number = input_args -> sequence_num ;
7780 int my_rank = bcol_module -> super .sbgp_partner_module -> my_index ;
7881
@@ -128,10 +131,8 @@ int bcol_basesmuma_k_nomial_barrier_init(bcol_function_args_t *input_args,
128131 src = exchange_node -> rank_extra_sources_array [0 ];
129132 peer_ctl_pointer = data_buffs [src ].ctl_struct ;
130133
131- for ( i = 0 ; i < cm -> num_to_probe && ( 0 == matched ) ; i ++ ) {
134+ for ( i = 0 ; i < cm -> num_to_probe ; i ++ ) {
132135 if (IS_PEER_READY (peer_ctl_pointer , ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
133- matched = 1 ;
134-
135136 goto FINISHED ;
136137 }
137138
@@ -148,20 +149,21 @@ int bcol_basesmuma_k_nomial_barrier_init(bcol_function_args_t *input_args,
148149 peer_ctl_pointer = data_buffs [src ].ctl_struct ;
149150
150151 /* probe for extra rank's arrival */
151- for ( i = 0 ; i < cm -> num_to_probe && ( 0 == matched ) ; i ++ ) {
152+ for ( i = 0 , matched = false ; i < cm -> num_to_probe && ! matched ; i ++ ) {
152153 if (IS_PEER_READY (peer_ctl_pointer ,ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
153- matched = 1 ;
154- /* copy it in */
155- goto MAIN_PHASE ;
154+ /* copy it in */
155+ matched = true;
156+ break ;
156157 }
157158 }
158- * status = ready_flag ;
159- * iteration = -1 ;
160- return BCOL_FN_STARTED ;
161159
160+ if (!matched ) {
161+ * status = ready_flag ;
162+ * iteration = -1 ;
163+ return BCOL_FN_STARTED ;
164+ }
162165 }
163166
164- MAIN_PHASE :
165167 /* bump the ready flag */
166168 ready_flag ++ ;
167169
@@ -189,12 +191,11 @@ int bcol_basesmuma_k_nomial_barrier_init(bcol_function_args_t *input_args,
189191 * better temporal locality, this comes at a cost to asynchronicity
190192 * but should get better cache performance
191193 */
192- matched = 0 ;
193- for ( probe = 0 ; probe < cm -> num_to_probe && (0 == matched ); probe ++ ){
194+ for ( probe = 0 ; probe < cm -> num_to_probe ; probe ++ ){
194195 if (IS_PEER_READY (peer_ctl_pointer ,ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
195- matched = 1 ;
196196 /* set this request's bit */
197197 * active_requests ^= (1 <<j );
198+ break ;
198199 }
199200 }
200201 }
@@ -261,7 +262,7 @@ int bcol_basesmuma_k_nomial_barrier_progress(bcol_function_args_t *input_args,
261262 int pow_k , tree_order ;
262263 int bcol_id = (int ) bcol_module -> super .bcol_id ;
263264
264- int matched = 0 ;
265+ bool matched ;
265266 int64_t sequence_number = input_args -> sequence_num ;
266267 int my_rank = bcol_module -> super .sbgp_partner_module -> my_index ;
267268
@@ -311,10 +312,8 @@ int bcol_basesmuma_k_nomial_barrier_progress(bcol_function_args_t *input_args,
311312 src = exchange_node -> rank_extra_sources_array [0 ];
312313 peer_ctl_pointer = data_buffs [src ].ctl_struct ;
313314
314- for ( i = 0 ; i < cm -> num_to_probe && ( 0 == matched ) ; i ++ ) {
315+ for ( i = 0 ; i < cm -> num_to_probe ; i ++ ) {
315316 if (IS_PEER_READY (peer_ctl_pointer , ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
316- matched = 1 ;
317-
318317 goto FINISHED ;
319318 }
320319
@@ -330,21 +329,21 @@ int bcol_basesmuma_k_nomial_barrier_progress(bcol_function_args_t *input_args,
330329 peer_ctl_pointer = data_buffs [src ].ctl_struct ;
331330
332331 /* probe for extra rank's arrival */
333- for ( i = 0 ; i < cm -> num_to_probe && ( 0 == matched ) ; i ++ ) {
332+ for ( i = 0 , matched = false ; i < cm -> num_to_probe && ! matched ; i ++ ) {
334333 if (IS_PEER_READY (peer_ctl_pointer ,ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
335- matched = 1 ;
334+ matched = true ;
336335 /* bump the flag */
337336 ready_flag ++ ;
338337 * iteration = 0 ;
339- goto MAIN_PHASE ;
338+ break ;
340339 }
341340 }
342- return BCOL_FN_STARTED ;
343341
342+ if (!matched ) {
343+ return BCOL_FN_STARTED ;
344+ }
344345 }
345346
346- MAIN_PHASE :
347-
348347 /* start the recursive k - ing phase */
349348 for ( * iter = * iteration ; * iter < pow_k ; (* iter )++ ) {
350349 /* I am ready at this level */
@@ -369,12 +368,11 @@ int bcol_basesmuma_k_nomial_barrier_progress(bcol_function_args_t *input_args,
369368 /* I am putting the probe loop as the inner most loop to achieve
370369 * better temporal locality
371370 */
372- matched = 0 ;
373- for ( probe = 0 ; probe < cm -> num_to_probe && (0 == matched ); probe ++ ){
371+ for ( probe = 0 ; probe < cm -> num_to_probe ; probe ++ ){
374372 if (IS_PEER_READY (peer_ctl_pointer ,ready_flag , sequence_number , BARRIER_RKING_FLAG , bcol_id )){
375- matched = 1 ;
376373 /* flip the request's bit */
377374 * active_requests ^= (1 <<j );
375+ break ;
378376 }
379377 }
380378 }
0 commit comments