sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 1 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 2 | This file is part of drd, a thread error detector. |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 3 | |
bart | d4bab99 | 2013-10-04 05:55:30 +0000 | [diff] [blame] | 4 | Copyright (C) 2006-2013 Bart Van Assche <bvanassche@acm.org>. |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or |
| 7 | modify it under the terms of the GNU General Public License as |
| 8 | published by the Free Software Foundation; either version 2 of the |
| 9 | License, or (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 19 | 02111-1307, USA. |
| 20 | |
| 21 | The GNU General Public License is contained in the file COPYING. |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include "drd_barrier.h" |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 26 | #include "drd_clientobj.h" |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 27 | #include "drd_error.h" |
| 28 | #include "drd_suppression.h" |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 29 | #include "pub_tool_errormgr.h" // VG_(maybe_record_error)() |
| 30 | #include "pub_tool_libcassert.h" // tl_assert() |
| 31 | #include "pub_tool_libcprint.h" // VG_(printf)() |
| 32 | #include "pub_tool_machine.h" // VG_(get_IP)() |
| 33 | #include "pub_tool_mallocfree.h" // VG_(malloc)(), VG_(free)() |
| 34 | #include "pub_tool_oset.h" |
| 35 | #include "pub_tool_threadstate.h" // VG_(get_running_tid)() |
| 36 | |
| 37 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 38 | /* Type definitions. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 39 | |
bart | 8ddef88 | 2008-03-09 08:48:01 +0000 | [diff] [blame] | 40 | /** Information associated with one thread participating in a barrier. */ |
bart | bebc5d6 | 2008-02-24 18:42:53 +0000 | [diff] [blame] | 41 | struct barrier_thread_info |
| 42 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 43 | UWord tid; // A DrdThreadId declared as UWord because |
bart | 62cc232 | 2010-03-07 10:54:21 +0000 | [diff] [blame] | 44 | // this member variable is the key of an OSet. |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 45 | Segment* sg; // Segment of the last pthread_barrier() call |
| 46 | // by thread tid. |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 47 | Segment* post_wait_sg; // Segment created after *_barrier_wait() finished |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 48 | ExeContext* wait_call_ctxt;// call stack for *_barrier_wait() call. |
| 49 | Bool thread_finished;// Whether thread 'tid' has finished. |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 53 | /* Local functions. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 54 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 55 | static void barrier_cleanup(struct barrier_info* p); |
| 56 | static void barrier_delete_thread(struct barrier_info* const p, |
| 57 | const DrdThreadId tid); |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 58 | static const HChar* barrier_get_typename(struct barrier_info* const p); |
| 59 | static const HChar* barrier_type_name(const BarrierT bt); |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 60 | static |
| 61 | void barrier_report_wait_delete_race(const struct barrier_info* const p, |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 62 | const struct barrier_thread_info* const q); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 63 | |
| 64 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 65 | /* Local variables. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 66 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 67 | static Bool s_trace_barrier = False; |
| 68 | static ULong s_barrier_segment_creation_count; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 69 | |
| 70 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 71 | /* Function definitions. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 72 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 73 | void DRD_(barrier_set_trace)(const Bool trace_barrier) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 74 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 75 | s_trace_barrier = trace_barrier; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 76 | } |
| 77 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 78 | /** |
| 79 | * Initialize the structure *p with the specified thread ID and iteration |
| 80 | * information. |
| 81 | */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 82 | static |
| 83 | void DRD_(barrier_thread_initialize)(struct barrier_thread_info* const p, |
bart | cdc3fdb | 2011-07-29 12:31:33 +0000 | [diff] [blame] | 84 | const DrdThreadId tid) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 85 | { |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 86 | p->tid = tid; |
| 87 | p->sg = NULL; |
| 88 | p->post_wait_sg = 0; |
| 89 | p->wait_call_ctxt = 0; |
| 90 | p->thread_finished = False; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 91 | } |
| 92 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 93 | /** |
| 94 | * Deallocate the memory that is owned by members of |
| 95 | * struct barrier_thread_info. |
| 96 | */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 97 | static void DRD_(barrier_thread_destroy)(struct barrier_thread_info* const p) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 98 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 99 | tl_assert(p); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 100 | DRD_(sg_put)(p->sg); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 101 | DRD_(sg_put)(p->post_wait_sg); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 102 | } |
| 103 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 104 | /** |
| 105 | * Initialize the structure *p with the specified client-side barrier address, |
| 106 | * barrier object size and number of participants in each barrier. |
| 107 | */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 108 | static |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 109 | void DRD_(barrier_initialize)(struct barrier_info* const p, |
| 110 | const Addr barrier, |
| 111 | const BarrierT barrier_type, |
| 112 | const Word count) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 113 | { |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 114 | int i; |
| 115 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 116 | tl_assert(barrier != 0); |
| 117 | tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier); |
| 118 | tl_assert(p->a1 == barrier); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 119 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 120 | p->cleanup = (void(*)(DrdClientobj*))barrier_cleanup; |
| 121 | p->delete_thread |
| 122 | = (void(*)(DrdClientobj*, DrdThreadId))barrier_delete_thread; |
| 123 | p->barrier_type = barrier_type; |
| 124 | p->count = count; |
| 125 | p->pre_iteration = 0; |
| 126 | p->post_iteration = 0; |
| 127 | p->pre_waiters_left = count; |
| 128 | p->post_waiters_left = count; |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 129 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 130 | tl_assert(sizeof(((struct barrier_thread_info*)0)->tid) == sizeof(Word)); |
| 131 | tl_assert(sizeof(((struct barrier_thread_info*)0)->tid) |
| 132 | >= sizeof(DrdThreadId)); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 133 | for (i = 0; i < 2; i++) { |
| 134 | p->oset[i] = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.barrier.bi.1", |
| 135 | VG_(free)); |
| 136 | } |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 137 | } |
| 138 | |
bart | 195e41f | 2009-02-15 11:34:57 +0000 | [diff] [blame] | 139 | /** |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 140 | * Deallocate the memory owned by the struct barrier_info object and also |
| 141 | * all the nodes in the OSet p->oset. |
| 142 | * |
bart | 195e41f | 2009-02-15 11:34:57 +0000 | [diff] [blame] | 143 | * Called by clientobj_destroy(). |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 144 | */ |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 145 | static void barrier_cleanup(struct barrier_info* p) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 146 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 147 | struct barrier_thread_info* q; |
| 148 | Segment* latest_sg = 0; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 149 | OSet* oset; |
| 150 | int i; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 151 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 152 | tl_assert(p); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 153 | |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 154 | DRD_(thread_get_latest_segment)(&latest_sg, DRD_(thread_get_running_tid)()); |
| 155 | tl_assert(latest_sg); |
| 156 | |
| 157 | if (p->pre_waiters_left != p->count) { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 158 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), p->a1, 0, 0 }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 159 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 160 | BarrierErr, |
| 161 | VG_(get_IP)(VG_(get_running_tid)()), |
| 162 | "Destruction of barrier that is being waited" |
| 163 | " upon", |
| 164 | &bei); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 165 | } else { |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 166 | oset = p->oset[1 - (p->pre_iteration & 1)]; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 167 | VG_(OSetGen_ResetIter)(oset); |
| 168 | for ( ; (q = VG_(OSetGen_Next)(oset)) != 0; ) { |
| 169 | if (q->post_wait_sg && !DRD_(vc_lte)(&q->post_wait_sg->vc, |
| 170 | &latest_sg->vc)) |
| 171 | { |
| 172 | barrier_report_wait_delete_race(p, q); |
| 173 | } |
| 174 | DRD_(barrier_thread_destroy)(q); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 175 | } |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 176 | } |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 177 | |
| 178 | for (i = 0; i < 2; i++) { |
| 179 | VG_(OSetGen_Destroy)(p->oset[i]); |
| 180 | p->oset[i] = NULL; |
| 181 | } |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 182 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 183 | DRD_(sg_put)(latest_sg); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 184 | } |
| 185 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 186 | /** |
| 187 | * Look up the client-side barrier address barrier in s_barrier[]. If not |
| 188 | * found, add it. |
| 189 | */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 190 | static |
| 191 | struct barrier_info* |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 192 | DRD_(barrier_get_or_allocate)(const Addr barrier, |
| 193 | const BarrierT barrier_type, const Word count) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 194 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 195 | struct barrier_info *p; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 196 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 197 | tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 198 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 199 | tl_assert(offsetof(DrdClientobj, barrier) == 0); |
| 200 | p = &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier); |
| 201 | if (p == 0) |
| 202 | { |
| 203 | p = &(DRD_(clientobj_add)(barrier, ClientBarrier)->barrier); |
| 204 | DRD_(barrier_initialize)(p, barrier, barrier_type, count); |
| 205 | } |
| 206 | return p; |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 207 | } |
| 208 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 209 | /** |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 210 | * Look up the address of the struct barrier_info associated with the |
| 211 | * client-side barrier object. |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 212 | */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 213 | static struct barrier_info* DRD_(barrier_get)(const Addr barrier) |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 214 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 215 | tl_assert(offsetof(DrdClientobj, barrier) == 0); |
| 216 | return &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 217 | } |
| 218 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 219 | /** |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 220 | * Initialize a barrier with given client address, barrier type and number of |
| 221 | * participants. The 'reinitialization' argument indicates whether a barrier |
| 222 | * object is being initialized or reinitialized. |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 223 | * |
| 224 | * Called before pthread_barrier_init(). |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 225 | */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 226 | void DRD_(barrier_init)(const Addr barrier, |
| 227 | const BarrierT barrier_type, const Word count, |
| 228 | const Bool reinitialization) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 229 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 230 | struct barrier_info* p; |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 231 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 232 | tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier); |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 233 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 234 | if (count == 0) |
| 235 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 236 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), barrier, 0, 0 }; |
bart | d9e39ec | 2008-06-28 15:03:26 +0000 | [diff] [blame] | 237 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 238 | BarrierErr, |
| 239 | VG_(get_IP)(VG_(get_running_tid)()), |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 240 | "pthread_barrier_init: 'count' argument is zero", |
bart | d9e39ec | 2008-06-28 15:03:26 +0000 | [diff] [blame] | 241 | &bei); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 242 | } |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 243 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 244 | if (! reinitialization && barrier_type == pthread_barrier) |
| 245 | { |
| 246 | p = DRD_(barrier_get)(barrier); |
| 247 | if (p) |
| 248 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 249 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), barrier, 0, 0 }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 250 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 251 | BarrierErr, |
| 252 | VG_(get_IP)(VG_(get_running_tid)()), |
| 253 | "Barrier reinitialization", |
| 254 | &bei); |
| 255 | } |
| 256 | } |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 257 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 258 | p = DRD_(barrier_get_or_allocate)(barrier, barrier_type, count); |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 259 | |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 260 | if (s_trace_barrier) { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 261 | if (reinitialization) |
bart | ad994e8 | 2011-10-13 18:04:30 +0000 | [diff] [blame] | 262 | DRD_(trace_msg)("[%d] barrier_reinit %s 0x%lx count %ld -> %ld", |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 263 | DRD_(thread_get_running_tid)(), |
| 264 | barrier_get_typename(p), barrier, p->count, count); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 265 | else |
bart | ad994e8 | 2011-10-13 18:04:30 +0000 | [diff] [blame] | 266 | DRD_(trace_msg)("[%d] barrier_init %s 0x%lx", |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 267 | DRD_(thread_get_running_tid)(), |
| 268 | barrier_get_typename(p), |
| 269 | barrier); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | if (reinitialization && p->count != count) |
| 273 | { |
| 274 | if (p->pre_waiters_left != p->count || p->post_waiters_left != p->count) |
| 275 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 276 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), p->a1, 0, 0 }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 277 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 278 | BarrierErr, |
| 279 | VG_(get_IP)(VG_(get_running_tid)()), |
| 280 | "Reinitialization of barrier with active" |
| 281 | " waiters", |
| 282 | &bei); |
| 283 | } |
| 284 | p->count = count; |
| 285 | } |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 286 | } |
| 287 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 288 | /** Called after pthread_barrier_destroy() / gomp_barrier_destroy(). */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 289 | void DRD_(barrier_destroy)(const Addr barrier, const BarrierT barrier_type) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 290 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 291 | struct barrier_info* p; |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 292 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 293 | p = DRD_(barrier_get)(barrier); |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 294 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 295 | if (s_trace_barrier) |
bart | ad994e8 | 2011-10-13 18:04:30 +0000 | [diff] [blame] | 296 | DRD_(trace_msg)("[%d] barrier_destroy %s 0x%lx", |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 297 | DRD_(thread_get_running_tid)(), |
| 298 | barrier_get_typename(p), barrier); |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 299 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 300 | if (p == 0) |
| 301 | { |
bart | 62cc232 | 2010-03-07 10:54:21 +0000 | [diff] [blame] | 302 | GenericErrInfo GEI = { |
| 303 | .tid = DRD_(thread_get_running_tid)(), |
| 304 | .addr = barrier, |
| 305 | }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 306 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 307 | GenericErr, |
| 308 | VG_(get_IP)(VG_(get_running_tid)()), |
| 309 | "Not a barrier", |
| 310 | &GEI); |
| 311 | return; |
| 312 | } |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 313 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 314 | if (p->pre_waiters_left != p->count || p->post_waiters_left != p->count) |
| 315 | { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 316 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), p->a1, 0, 0 }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 317 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 318 | BarrierErr, |
| 319 | VG_(get_IP)(VG_(get_running_tid)()), |
| 320 | "Destruction of a barrier with active waiters", |
| 321 | &bei); |
| 322 | } |
bart | 195a398 | 2008-07-01 13:15:31 +0000 | [diff] [blame] | 323 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 324 | DRD_(clientobj_remove)(p->a1, ClientBarrier); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 325 | } |
| 326 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 327 | /** Called before pthread_barrier_wait() / gomp_barrier_wait(). */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 328 | void DRD_(barrier_pre_wait)(const DrdThreadId tid, const Addr barrier, |
| 329 | const BarrierT barrier_type) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 330 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 331 | struct barrier_info* p; |
| 332 | struct barrier_thread_info* q; |
| 333 | const UWord word_tid = tid; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 334 | OSet* oset; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 335 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 336 | p = DRD_(barrier_get)(barrier); |
bart | 74b2d97 | 2011-10-08 08:54:57 +0000 | [diff] [blame] | 337 | if (p == 0 && barrier_type == gomp_barrier) { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 338 | /* |
| 339 | * gomp_barrier_wait() call has been intercepted but gomp_barrier_init() |
| 340 | * not. The only cause I know of that can trigger this is that libgomp.so |
| 341 | * has been compiled with --enable-linux-futex. |
| 342 | */ |
bart | 74b2d97 | 2011-10-08 08:54:57 +0000 | [diff] [blame] | 343 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), 0, 0, 0 }; |
| 344 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 345 | BarrierErr, |
| 346 | VG_(get_IP)(VG_(get_running_tid)()), |
| 347 | "Please verify whether gcc has been configured" |
| 348 | " with option --disable-linux-futex. See also" |
| 349 | " the section about OpenMP in the DRD manual.", |
| 350 | &bei); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 351 | } |
| 352 | tl_assert(p); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 353 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 354 | if (s_trace_barrier) |
bart | ad994e8 | 2011-10-13 18:04:30 +0000 | [diff] [blame] | 355 | DRD_(trace_msg)("[%d] barrier_pre_wait %s 0x%lx iteration %ld", |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 356 | DRD_(thread_get_running_tid)(), |
| 357 | barrier_get_typename(p), barrier, p->pre_iteration); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 358 | |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 359 | /* Clean up nodes associated with finished threads. */ |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 360 | oset = p->oset[p->pre_iteration & 1]; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 361 | tl_assert(oset); |
| 362 | VG_(OSetGen_ResetIter)(oset); |
| 363 | for ( ; (q = VG_(OSetGen_Next)(oset)) != 0; ) { |
| 364 | if (q->thread_finished) { |
| 365 | void* r = VG_(OSetGen_Remove)(oset, &q->tid); |
| 366 | tl_assert(r == q); |
| 367 | DRD_(barrier_thread_destroy)(q); |
| 368 | VG_(OSetGen_FreeNode)(oset, q); |
| 369 | VG_(OSetGen_ResetIterAt)(oset, &word_tid); |
| 370 | } |
| 371 | } |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 372 | /* Allocate the per-thread data structure if necessary. */ |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 373 | q = VG_(OSetGen_Lookup)(oset, &word_tid); |
| 374 | if (q == NULL) { |
| 375 | q = VG_(OSetGen_AllocNode)(oset, sizeof(*q)); |
bart | cdc3fdb | 2011-07-29 12:31:33 +0000 | [diff] [blame] | 376 | DRD_(barrier_thread_initialize)(q, tid); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 377 | VG_(OSetGen_Insert)(oset, q); |
| 378 | tl_assert(VG_(OSetGen_Lookup)(oset, &word_tid) == q); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 379 | } |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 380 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 381 | /* Record *_barrier_wait() call context. */ |
| 382 | q->wait_call_ctxt = VG_(record_ExeContext)(VG_(get_running_tid)(), 0); |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 383 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 384 | /* |
| 385 | * Store a pointer to the latest segment of the current thread in the |
| 386 | * per-thread data structure. |
| 387 | */ |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 388 | DRD_(thread_get_latest_segment)(&q->sg, tid); |
bart | bebc5d6 | 2008-02-24 18:42:53 +0000 | [diff] [blame] | 389 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 390 | /* |
| 391 | * If the same number of threads as the barrier count indicates have |
| 392 | * called the pre *_barrier_wait() wrapper, toggle p->pre_iteration and |
| 393 | * reset the p->pre_waiters_left counter. |
| 394 | */ |
| 395 | if (--p->pre_waiters_left <= 0) |
| 396 | { |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 397 | p->pre_iteration++; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 398 | p->pre_waiters_left = p->count; |
| 399 | } |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 400 | } |
| 401 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 402 | /** Called after pthread_barrier_wait() / gomp_barrier_wait(). */ |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 403 | void DRD_(barrier_post_wait)(const DrdThreadId tid, const Addr barrier, |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 404 | const BarrierT barrier_type, const Bool waited, |
| 405 | const Bool serializing) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 406 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 407 | struct barrier_info* p; |
| 408 | const UWord word_tid = tid; |
| 409 | struct barrier_thread_info* q; |
| 410 | struct barrier_thread_info* r; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 411 | OSet* oset; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 412 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 413 | p = DRD_(barrier_get)(barrier); |
bart | bebc5d6 | 2008-02-24 18:42:53 +0000 | [diff] [blame] | 414 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 415 | if (s_trace_barrier) |
bart | ad994e8 | 2011-10-13 18:04:30 +0000 | [diff] [blame] | 416 | DRD_(trace_msg)("[%d] barrier_post_wait %s 0x%lx iteration %ld%s", |
bart | b92ff0f | 2011-10-08 08:29:29 +0000 | [diff] [blame] | 417 | tid, p ? barrier_get_typename(p) : "(?)", |
| 418 | barrier, p ? p->post_iteration : -1, |
| 419 | serializing ? " (serializing)" : ""); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 420 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 421 | /* |
| 422 | * If p == 0, this means that the barrier has been destroyed after |
| 423 | * *_barrier_wait() returned and before this function was called. Just |
| 424 | * return in that case -- race conditions between *_barrier_wait() |
| 425 | * and *_barrier_destroy() are detected by the *_barrier_destroy() wrapper. |
| 426 | */ |
| 427 | if (p == 0) |
| 428 | return; |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 429 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 430 | /* If the *_barrier_wait() call returned an error code, exit. */ |
| 431 | if (! waited) |
| 432 | return; |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 433 | |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 434 | oset = p->oset[p->post_iteration & 1]; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 435 | q = VG_(OSetGen_Lookup)(oset, &word_tid); |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 436 | if (p->pre_iteration - p->post_iteration > 1) { |
| 437 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), p->a1, 0, 0 }; |
| 438 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 439 | BarrierErr, |
| 440 | VG_(get_IP)(VG_(get_running_tid)()), |
| 441 | "Number of concurrent pthread_barrier_wait()" |
| 442 | " calls exceeds the barrier count", |
| 443 | &bei); |
| 444 | } else if (q == NULL) { |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 445 | BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), p->a1, 0, 0 }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 446 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 447 | BarrierErr, |
| 448 | VG_(get_IP)(VG_(get_running_tid)()), |
| 449 | "Error in barrier implementation" |
| 450 | " -- barrier_wait() started before" |
| 451 | " barrier_destroy() and finished after" |
| 452 | " barrier_destroy()", |
| 453 | &bei); |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 454 | } |
| 455 | if (q == NULL) { |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 456 | q = VG_(OSetGen_AllocNode)(oset, sizeof(*q)); |
bart | cdc3fdb | 2011-07-29 12:31:33 +0000 | [diff] [blame] | 457 | DRD_(barrier_thread_initialize)(q, tid); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 458 | VG_(OSetGen_Insert)(oset, q); |
| 459 | tl_assert(VG_(OSetGen_Lookup)(oset, &word_tid) == q); |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 460 | DRD_(thread_get_latest_segment)(&q->sg, tid); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 461 | } |
bart | 7627be3 | 2009-06-06 12:26:05 +0000 | [diff] [blame] | 462 | |
| 463 | /* Create a new segment and store a pointer to that segment. */ |
| 464 | DRD_(thread_new_segment)(tid); |
| 465 | DRD_(thread_get_latest_segment)(&q->post_wait_sg, tid); |
| 466 | s_barrier_segment_creation_count++; |
| 467 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 468 | /* |
| 469 | * Combine all vector clocks that were stored in the pre_barrier_wait |
| 470 | * wrapper with the vector clock of the current thread. |
| 471 | */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 472 | { |
bart | 8f822af | 2009-06-08 18:20:42 +0000 | [diff] [blame] | 473 | VectorClock old_vc; |
| 474 | |
bart | ae37e6d | 2012-01-22 08:58:31 +0000 | [diff] [blame] | 475 | DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid)); |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 476 | VG_(OSetGen_ResetIter)(oset); |
| 477 | for ( ; (r = VG_(OSetGen_Next)(oset)) != 0; ) |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 478 | { |
bart | 8f822af | 2009-06-08 18:20:42 +0000 | [diff] [blame] | 479 | if (r != q) |
| 480 | { |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 481 | tl_assert(r->sg); |
bart | ae37e6d | 2012-01-22 08:58:31 +0000 | [diff] [blame] | 482 | DRD_(vc_combine)(DRD_(thread_get_vc)(tid), &r->sg->vc); |
bart | 8f822af | 2009-06-08 18:20:42 +0000 | [diff] [blame] | 483 | } |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 484 | } |
bart | 8f822af | 2009-06-08 18:20:42 +0000 | [diff] [blame] | 485 | DRD_(thread_update_conflict_set)(tid, &old_vc); |
| 486 | DRD_(vc_cleanup)(&old_vc); |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 487 | } |
bart | bebc5d6 | 2008-02-24 18:42:53 +0000 | [diff] [blame] | 488 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 489 | /* |
| 490 | * If the same number of threads as the barrier count indicates have |
| 491 | * called the post *_barrier_wait() wrapper, toggle p->post_iteration and |
| 492 | * reset the p->post_waiters_left counter. |
| 493 | */ |
| 494 | if (--p->post_waiters_left <= 0) |
| 495 | { |
bart | d378eaa | 2011-07-30 09:35:56 +0000 | [diff] [blame] | 496 | p->post_iteration++; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 497 | p->post_waiters_left = p->count; |
| 498 | } |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 499 | } |
| 500 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 501 | /** Called when thread tid stops to exist. */ |
| 502 | static void barrier_delete_thread(struct barrier_info* const p, |
| 503 | const DrdThreadId tid) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 504 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 505 | struct barrier_thread_info* q; |
| 506 | const UWord word_tid = tid; |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 507 | int i; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 508 | |
bart | d61580e | 2011-07-29 12:39:44 +0000 | [diff] [blame] | 509 | for (i = 0; i < 2; i++) { |
| 510 | q = VG_(OSetGen_Lookup)(p->oset[i], &word_tid); |
| 511 | if (q) |
| 512 | q->thread_finished = True; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 513 | } |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 514 | } |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 515 | |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 516 | /** |
| 517 | * Report that *_barrier_destroy() has been called but that this call was |
| 518 | * not synchronized with the last *_barrier_wait() call on the same barrier. |
bart | 776a91e | 2009-02-22 09:29:07 +0000 | [diff] [blame] | 519 | * |
| 520 | * This topic has been discussed extensively on comp.programming.threads |
| 521 | * (February 3, 2009). See also |
| 522 | * <a href="http://groups.google.com/group/comp.programming.threads/browse_thread/thread/4f65535d6192aa50/a5f4bf1e3b437c4d">Immediately destroying pthread barriers</a>. |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 523 | */ |
| 524 | static |
| 525 | void barrier_report_wait_delete_race(const struct barrier_info* const p, |
| 526 | const struct barrier_thread_info* const q) |
| 527 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 528 | tl_assert(p); |
| 529 | tl_assert(q); |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 530 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 531 | { |
| 532 | BarrierErrInfo bei |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 533 | = { DRD_(thread_get_running_tid)(), p->a1, q->tid, q->wait_call_ctxt }; |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 534 | VG_(maybe_record_error)(VG_(get_running_tid)(), |
| 535 | BarrierErr, |
| 536 | VG_(get_IP)(VG_(get_running_tid)()), |
| 537 | "Destruction of barrier not synchronized with" |
| 538 | " barrier wait call", |
| 539 | &bei); |
| 540 | } |
bart | d2c5eae | 2009-02-21 15:27:04 +0000 | [diff] [blame] | 541 | } |
| 542 | |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 543 | static const HChar* barrier_get_typename(struct barrier_info* const p) |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 544 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 545 | tl_assert(p); |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 546 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 547 | return barrier_type_name(p->barrier_type); |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 548 | } |
| 549 | |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 550 | static const HChar* barrier_type_name(const BarrierT bt) |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 551 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 552 | switch (bt) |
| 553 | { |
| 554 | case pthread_barrier: |
| 555 | return "pthread barrier"; |
| 556 | case gomp_barrier: |
| 557 | return "gomp barrier"; |
| 558 | } |
| 559 | return "?"; |
bart | 306527d | 2008-03-12 17:23:07 +0000 | [diff] [blame] | 560 | } |
bart | 6bbefaf | 2008-04-19 15:16:45 +0000 | [diff] [blame] | 561 | |
bart | a8cf765 | 2009-02-15 11:00:29 +0000 | [diff] [blame] | 562 | ULong DRD_(get_barrier_segment_creation_count)(void) |
bart | 6bbefaf | 2008-04-19 15:16:45 +0000 | [diff] [blame] | 563 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 564 | return s_barrier_segment_creation_count; |
bart | 6bbefaf | 2008-04-19 15:16:45 +0000 | [diff] [blame] | 565 | } |