diff options
Diffstat (limited to 'libgomp/single.c')
-rw-r--r-- | libgomp/single.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libgomp/single.c b/libgomp/single.c index dde05d9ceb8..16c7fa988a1 100644 --- a/libgomp/single.c +++ b/libgomp/single.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2008 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU OpenMP Library (libgomp). @@ -37,10 +37,24 @@ bool GOMP_single_start (void) { +#ifdef HAVE_SYNC_BUILTINS + struct gomp_thread *thr = gomp_thread (); + struct gomp_team *team = thr->ts.team; + unsigned long single_count; + + if (__builtin_expect (team == NULL, 0)) + return true; + + single_count = thr->ts.single_count++; + return __sync_bool_compare_and_swap (&team->single_count, single_count, + single_count + 1L); +#else bool ret = gomp_work_share_start (false); - gomp_mutex_unlock (&gomp_thread ()->ts.work_share->lock); + if (ret) + gomp_work_share_init_done (); gomp_work_share_end_nowait (); return ret; +#endif } /* This routine is called when first encountering a SINGLE construct that @@ -57,13 +71,15 @@ GOMP_single_copy_start (void) void *ret; first = gomp_work_share_start (false); - gomp_mutex_unlock (&thr->ts.work_share->lock); if (first) - ret = NULL; + { + gomp_work_share_init_done (); + ret = NULL; + } else { - gomp_barrier_wait (&thr->ts.team->barrier); + gomp_team_barrier_wait (&thr->ts.team->barrier); ret = thr->ts.work_share->copyprivate; gomp_work_share_end_nowait (); @@ -84,7 +100,7 @@ GOMP_single_copy_end (void *data) if (team != NULL) { thr->ts.work_share->copyprivate = data; - gomp_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier); } gomp_work_share_end_nowait (); |