diff --git a/include/ck_barrier.h b/include/ck_barrier.h index cb3e37d..52d3973 100644 --- a/include/ck_barrier.h +++ b/include/ck_barrier.h @@ -121,6 +121,7 @@ typedef struct ck_barrier_tournament_round ck_barrier_tournament_round_t; struct ck_barrier_tournament { unsigned int tid; + unsigned int size; struct ck_barrier_tournament_round **rounds; }; typedef struct ck_barrier_tournament ck_barrier_tournament_t; diff --git a/src/ck_barrier_tournament.c b/src/ck_barrier_tournament.c index 0b6abae..e505890 100644 --- a/src/ck_barrier_tournament.c +++ b/src/ck_barrier_tournament.c @@ -64,7 +64,7 @@ ck_barrier_tournament_init(struct ck_barrier_tournament *barrier, unsigned int i, k, size, twok, twokm1, imod2k; ck_pr_store_uint(&barrier->tid, 0); - size = ck_barrier_tournament_size(nthr); + barrier->size = size = ck_barrier_tournament_size(nthr); for (i = 0; i < nthr; ++i) { /* The first role is always CK_BARRIER_TOURNAMENT_DROPOUT. */ @@ -112,6 +112,9 @@ ck_barrier_tournament(struct ck_barrier_tournament *barrier, struct ck_barrier_tournament_round **rounds = ck_pr_load_ptr(&barrier->rounds); int round = 1; + if (barrier->size == 1) + return; + for (;; ++round) { switch (rounds[state->vpid][round].role) { case CK_BARRIER_TOURNAMENT_BYE: