From b97b0021f9110e33f5a094ca8cb5afd2a8bcb0a0 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 9 Apr 2014 14:11:28 +0000 Subject: [PATCH] ck_barrier: Just pass-through tournament barrier with only one participating thread. --- include/ck_barrier.h | 1 + src/ck_barrier_tournament.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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: