Intel® OpenMP* Runtime Library
 All Classes Functions Variables Typedefs Enumerations Enumerator Modules Pages
kmp_lock.h
1 /*
2  * kmp_lock.h -- lock header file
3  * $Revision: 43473 $
4  * $Date: 2014-09-26 15:02:57 -0500 (Fri, 26 Sep 2014) $
5  */
6 
7 /* <copyright>
8  Copyright (c) 1997-2014 Intel Corporation. All Rights Reserved.
9 
10  Redistribution and use in source and binary forms, with or without
11  modification, are permitted provided that the following conditions
12  are met:
13 
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of Intel Corporation nor the names of its
20  contributors may be used to endorse or promote products derived
21  from this software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 
35 </copyright> */
36 
37 #ifndef KMP_LOCK_H
38 #define KMP_LOCK_H
39 
40 #include <limits.h> // CHAR_BIT
41 #include <stddef.h> // offsetof
42 
43 #include "kmp_os.h"
44 #include "kmp_debug.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif // __cplusplus
49 
50 // ----------------------------------------------------------------------------
51 // Have to copy these definitions from kmp.h because kmp.h cannot be included
52 // due to circular dependencies. Will undef these at end of file.
53 
54 #define KMP_PAD(type, sz) (sizeof(type) + (sz - ((sizeof(type) - 1) % (sz)) - 1))
55 #define KMP_GTID_DNE (-2)
56 
57 // Forward declaration of ident and ident_t
58 
59 struct ident;
60 typedef struct ident ident_t;
61 
62 // End of copied code.
63 // ----------------------------------------------------------------------------
64 
65 //
66 // We need to know the size of the area we can assume that the compiler(s)
67 // allocated for obects of type omp_lock_t and omp_nest_lock_t. The Intel
68 // compiler always allocates a pointer-sized area, as does visual studio.
69 //
70 // gcc however, only allocates 4 bytes for regular locks, even on 64-bit
71 // intel archs. It allocates at least 8 bytes for nested lock (more on
72 // recent versions), but we are bounded by the pointer-sized chunks that
73 // the Intel compiler allocates.
74 //
75 
76 #if KMP_OS_LINUX && defined(KMP_GOMP_COMPAT)
77 # define OMP_LOCK_T_SIZE sizeof(int)
78 # define OMP_NEST_LOCK_T_SIZE sizeof(void *)
79 #else
80 # define OMP_LOCK_T_SIZE sizeof(void *)
81 # define OMP_NEST_LOCK_T_SIZE sizeof(void *)
82 #endif
83 
84 //
85 // The Intel compiler allocates a 32-byte chunk for a critical section.
86 // Both gcc and visual studio only allocate enough space for a pointer.
87 // Sometimes we know that the space was allocated by the Intel compiler.
88 //
89 #define OMP_CRITICAL_SIZE sizeof(void *)
90 #define INTEL_CRITICAL_SIZE 32
91 
92 //
93 // lock flags
94 //
95 typedef kmp_uint32 kmp_lock_flags_t;
96 
97 #define kmp_lf_critical_section 1
98 
99 //
100 // When a lock table is used, the indices are of kmp_lock_index_t
101 //
102 typedef kmp_uint32 kmp_lock_index_t;
103 
104 //
105 // When memory allocated for locks are on the lock pool (free list),
106 // it is treated as structs of this type.
107 //
108 struct kmp_lock_pool {
109  union kmp_user_lock *next;
110  kmp_lock_index_t index;
111 };
112 
113 typedef struct kmp_lock_pool kmp_lock_pool_t;
114 
115 
116 extern void __kmp_validate_locks( void );
117 
118 
119 // ----------------------------------------------------------------------------
120 //
121 // There are 5 lock implementations:
122 //
123 // 1. Test and set locks.
124 // 2. futex locks (Linux* OS on x86 and Intel(R) Many Integrated Core architecture)
125 // 3. Ticket (Lamport bakery) locks.
126 // 4. Queuing locks (with separate spin fields).
127 // 5. DRPA (Dynamically Reconfigurable Distributed Polling Area) locks
128 //
129 // and 3 lock purposes:
130 //
131 // 1. Bootstrap locks -- Used for a few locks available at library startup-shutdown time.
132 // These do not require non-negative global thread ID's.
133 // 2. Internal RTL locks -- Used everywhere else in the RTL
134 // 3. User locks (includes critical sections)
135 //
136 // ----------------------------------------------------------------------------
137 
138 
139 // ============================================================================
140 // Lock implementations.
141 // ============================================================================
142 
143 
144 // ----------------------------------------------------------------------------
145 // Test and set locks.
146 //
147 // Non-nested test and set locks differ from the other lock kinds (except
148 // futex) in that we use the memory allocated by the compiler for the lock,
149 // rather than a pointer to it.
150 //
151 // On lin32, lin_32e, and win_32, the space allocated may be as small as 4
152 // bytes, so we have to use a lock table for nested locks, and avoid accessing
153 // the depth_locked field for non-nested locks.
154 //
155 // Information normally available to the tools, such as lock location,
156 // lock usage (normal lock vs. critical section), etc. is not available with
157 // test and set locks.
158 // ----------------------------------------------------------------------------
159 
160 struct kmp_base_tas_lock {
161  volatile kmp_int32 poll; // 0 => unlocked
162  // locked: (gtid+1) of owning thread
163  kmp_int32 depth_locked; // depth locked, for nested locks only
164 };
165 
166 typedef struct kmp_base_tas_lock kmp_base_tas_lock_t;
167 
168 union kmp_tas_lock {
169  kmp_base_tas_lock_t lk;
170  kmp_lock_pool_t pool; // make certain struct is large enough
171  double lk_align; // use worst case alignment
172  // no cache line padding
173 };
174 
175 typedef union kmp_tas_lock kmp_tas_lock_t;
176 
177 //
178 // Static initializer for test and set lock variables. Usage:
179 // kmp_tas_lock_t xlock = KMP_TAS_LOCK_INITIALIZER( xlock );
180 //
181 #define KMP_TAS_LOCK_INITIALIZER( lock ) { { 0, 0 } }
182 
183 extern void __kmp_acquire_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
184 extern int __kmp_test_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
185 extern void __kmp_release_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
186 extern void __kmp_init_tas_lock( kmp_tas_lock_t *lck );
187 extern void __kmp_destroy_tas_lock( kmp_tas_lock_t *lck );
188 
189 extern void __kmp_acquire_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
190 extern int __kmp_test_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
191 extern void __kmp_release_nested_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid );
192 extern void __kmp_init_nested_tas_lock( kmp_tas_lock_t *lck );
193 extern void __kmp_destroy_nested_tas_lock( kmp_tas_lock_t *lck );
194 
195 
196 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
197 
198 // ----------------------------------------------------------------------------
199 // futex locks. futex locks are only available on Linux* OS.
200 //
201 // Like non-nested test and set lock, non-nested futex locks use the memory
202 // allocated by the compiler for the lock, rather than a pointer to it.
203 //
204 // Information normally available to the tools, such as lock location,
205 // lock usage (normal lock vs. critical section), etc. is not available with
206 // test and set locks. With non-nested futex locks, the lock owner is not
207 // even available.
208 // ----------------------------------------------------------------------------
209 
210 struct kmp_base_futex_lock {
211  volatile kmp_int32 poll; // 0 => unlocked
212  // 2*(gtid+1) of owning thread, 0 if unlocked
213  // locked: (gtid+1) of owning thread
214  kmp_int32 depth_locked; // depth locked, for nested locks only
215 };
216 
217 typedef struct kmp_base_futex_lock kmp_base_futex_lock_t;
218 
219 union kmp_futex_lock {
220  kmp_base_futex_lock_t lk;
221  kmp_lock_pool_t pool; // make certain struct is large enough
222  double lk_align; // use worst case alignment
223  // no cache line padding
224 };
225 
226 typedef union kmp_futex_lock kmp_futex_lock_t;
227 
228 //
229 // Static initializer for futex lock variables. Usage:
230 // kmp_futex_lock_t xlock = KMP_FUTEX_LOCK_INITIALIZER( xlock );
231 //
232 #define KMP_FUTEX_LOCK_INITIALIZER( lock ) { { 0, 0 } }
233 
234 extern void __kmp_acquire_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
235 extern int __kmp_test_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
236 extern void __kmp_release_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
237 extern void __kmp_init_futex_lock( kmp_futex_lock_t *lck );
238 extern void __kmp_destroy_futex_lock( kmp_futex_lock_t *lck );
239 
240 extern void __kmp_acquire_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
241 extern int __kmp_test_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
242 extern void __kmp_release_nested_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid );
243 extern void __kmp_init_nested_futex_lock( kmp_futex_lock_t *lck );
244 extern void __kmp_destroy_nested_futex_lock( kmp_futex_lock_t *lck );
245 
246 #endif // KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
247 
248 
249 // ----------------------------------------------------------------------------
250 // Ticket locks.
251 // ----------------------------------------------------------------------------
252 
253 struct kmp_base_ticket_lock {
254  // `initialized' must be the first entry in the lock data structure!
255  volatile union kmp_ticket_lock * initialized; // points to the lock union if in initialized state
256  ident_t const * location; // Source code location of omp_init_lock().
257  volatile kmp_uint32 next_ticket; // ticket number to give to next thread which acquires
258  volatile kmp_uint32 now_serving; // ticket number for thread which holds the lock
259  volatile kmp_int32 owner_id; // (gtid+1) of owning thread, 0 if unlocked
260  kmp_int32 depth_locked; // depth locked, for nested locks only
261  kmp_lock_flags_t flags; // lock specifics, e.g. critical section lock
262 };
263 
264 typedef struct kmp_base_ticket_lock kmp_base_ticket_lock_t;
265 
266 union KMP_ALIGN_CACHE kmp_ticket_lock {
267  kmp_base_ticket_lock_t lk; // This field must be first to allow static initializing.
268  kmp_lock_pool_t pool;
269  double lk_align; // use worst case alignment
270  char lk_pad[ KMP_PAD( kmp_base_ticket_lock_t, CACHE_LINE ) ];
271 };
272 
273 typedef union kmp_ticket_lock kmp_ticket_lock_t;
274 
275 //
276 // Static initializer for simple ticket lock variables. Usage:
277 // kmp_ticket_lock_t xlock = KMP_TICKET_LOCK_INITIALIZER( xlock );
278 // Note the macro argument. It is important to make var properly initialized.
279 //
280 #define KMP_TICKET_LOCK_INITIALIZER( lock ) { { (kmp_ticket_lock_t *) & (lock), NULL, 0, 0, 0, -1 } }
281 
282 extern void __kmp_acquire_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
283 extern int __kmp_test_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
284 extern int __kmp_test_ticket_lock_with_cheks( kmp_ticket_lock_t *lck, kmp_int32 gtid );
285 extern void __kmp_release_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
286 extern void __kmp_init_ticket_lock( kmp_ticket_lock_t *lck );
287 extern void __kmp_destroy_ticket_lock( kmp_ticket_lock_t *lck );
288 
289 extern void __kmp_acquire_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
290 extern int __kmp_test_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
291 extern void __kmp_release_nested_ticket_lock( kmp_ticket_lock_t *lck, kmp_int32 gtid );
292 extern void __kmp_init_nested_ticket_lock( kmp_ticket_lock_t *lck );
293 extern void __kmp_destroy_nested_ticket_lock( kmp_ticket_lock_t *lck );
294 
295 
296 // ----------------------------------------------------------------------------
297 // Queuing locks.
298 // ----------------------------------------------------------------------------
299 
300 #if KMP_USE_ADAPTIVE_LOCKS
301 
302 struct kmp_adaptive_lock_info;
303 
304 typedef struct kmp_adaptive_lock_info kmp_adaptive_lock_info_t;
305 
306 #if KMP_DEBUG_ADAPTIVE_LOCKS
307 
308 struct kmp_adaptive_lock_statistics {
309  /* So we can get stats from locks that haven't been destroyed. */
310  kmp_adaptive_lock_info_t * next;
311  kmp_adaptive_lock_info_t * prev;
312 
313  /* Other statistics */
314  kmp_uint32 successfulSpeculations;
315  kmp_uint32 hardFailedSpeculations;
316  kmp_uint32 softFailedSpeculations;
317  kmp_uint32 nonSpeculativeAcquires;
318  kmp_uint32 nonSpeculativeAcquireAttempts;
319  kmp_uint32 lemmingYields;
320 };
321 
322 typedef struct kmp_adaptive_lock_statistics kmp_adaptive_lock_statistics_t;
323 
324 extern void __kmp_print_speculative_stats();
325 extern void __kmp_init_speculative_stats();
326 
327 #endif // KMP_DEBUG_ADAPTIVE_LOCKS
328 
329 struct kmp_adaptive_lock_info
330 {
331  /* Values used for adaptivity.
332  * Although these are accessed from multiple threads we don't access them atomically,
333  * because if we miss updates it probably doesn't matter much. (It just affects our
334  * decision about whether to try speculation on the lock).
335  */
336  kmp_uint32 volatile badness;
337  kmp_uint32 volatile acquire_attempts;
338  /* Parameters of the lock. */
339  kmp_uint32 max_badness;
340  kmp_uint32 max_soft_retries;
341 
342 #if KMP_DEBUG_ADAPTIVE_LOCKS
343  kmp_adaptive_lock_statistics_t volatile stats;
344 #endif
345 };
346 
347 #endif // KMP_USE_ADAPTIVE_LOCKS
348 
349 
350 struct kmp_base_queuing_lock {
351 
352  // `initialized' must be the first entry in the lock data structure!
353  volatile union kmp_queuing_lock *initialized; // Points to the lock union if in initialized state.
354 
355  ident_t const * location; // Source code location of omp_init_lock().
356 
357  KMP_ALIGN( 8 ) // tail_id must be 8-byte aligned!
358 
359  volatile kmp_int32 tail_id; // (gtid+1) of thread at tail of wait queue, 0 if empty
360  // Must be no padding here since head/tail used in 8-byte CAS
361  volatile kmp_int32 head_id; // (gtid+1) of thread at head of wait queue, 0 if empty
362  // Decl order assumes little endian
363  // bakery-style lock
364  volatile kmp_uint32 next_ticket; // ticket number to give to next thread which acquires
365  volatile kmp_uint32 now_serving; // ticket number for thread which holds the lock
366  volatile kmp_int32 owner_id; // (gtid+1) of owning thread, 0 if unlocked
367  kmp_int32 depth_locked; // depth locked, for nested locks only
368 
369  kmp_lock_flags_t flags; // lock specifics, e.g. critical section lock
370 };
371 
372 typedef struct kmp_base_queuing_lock kmp_base_queuing_lock_t;
373 
374 KMP_BUILD_ASSERT( offsetof( kmp_base_queuing_lock_t, tail_id ) % 8 == 0 );
375 
376 union KMP_ALIGN_CACHE kmp_queuing_lock {
377  kmp_base_queuing_lock_t lk; // This field must be first to allow static initializing.
378  kmp_lock_pool_t pool;
379  double lk_align; // use worst case alignment
380  char lk_pad[ KMP_PAD( kmp_base_queuing_lock_t, CACHE_LINE ) ];
381 };
382 
383 typedef union kmp_queuing_lock kmp_queuing_lock_t;
384 
385 extern void __kmp_acquire_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
386 extern int __kmp_test_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
387 extern void __kmp_release_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
388 extern void __kmp_init_queuing_lock( kmp_queuing_lock_t *lck );
389 extern void __kmp_destroy_queuing_lock( kmp_queuing_lock_t *lck );
390 
391 extern void __kmp_acquire_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
392 extern int __kmp_test_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
393 extern void __kmp_release_nested_queuing_lock( kmp_queuing_lock_t *lck, kmp_int32 gtid );
394 extern void __kmp_init_nested_queuing_lock( kmp_queuing_lock_t *lck );
395 extern void __kmp_destroy_nested_queuing_lock( kmp_queuing_lock_t *lck );
396 
397 #if KMP_USE_ADAPTIVE_LOCKS
398 
399 // ----------------------------------------------------------------------------
400 // Adaptive locks.
401 // ----------------------------------------------------------------------------
402 struct kmp_base_adaptive_lock {
403  kmp_base_queuing_lock qlk;
404  KMP_ALIGN(CACHE_LINE)
405  kmp_adaptive_lock_info_t adaptive; // Information for the speculative adaptive lock
406 };
407 
408 typedef struct kmp_base_adaptive_lock kmp_base_adaptive_lock_t;
409 
410 union KMP_ALIGN_CACHE kmp_adaptive_lock {
411  kmp_base_adaptive_lock_t lk;
412  kmp_lock_pool_t pool;
413  double lk_align;
414  char lk_pad[ KMP_PAD(kmp_base_adaptive_lock_t, CACHE_LINE) ];
415 };
416 typedef union kmp_adaptive_lock kmp_adaptive_lock_t;
417 
418 # define GET_QLK_PTR(l) ((kmp_queuing_lock_t *) & (l)->lk.qlk)
419 
420 #endif // KMP_USE_ADAPTIVE_LOCKS
421 
422 // ----------------------------------------------------------------------------
423 // DRDPA ticket locks.
424 // ----------------------------------------------------------------------------
425 
426 struct kmp_base_drdpa_lock {
427  //
428  // All of the fields on the first cache line are only written when
429  // initializing or reconfiguring the lock. These are relatively rare
430  // operations, so data from the first cache line will usually stay
431  // resident in the cache of each thread trying to acquire the lock.
432  //
433  // initialized must be the first entry in the lock data structure!
434  //
435  KMP_ALIGN_CACHE
436 
437  volatile union kmp_drdpa_lock * initialized; // points to the lock union if in initialized state
438  ident_t const * location; // Source code location of omp_init_lock().
439  volatile struct kmp_lock_poll {
440  kmp_uint64 poll;
441  } * volatile polls;
442  volatile kmp_uint64 mask; // is 2**num_polls-1 for mod op
443  kmp_uint64 cleanup_ticket; // thread with cleanup ticket
444  volatile struct kmp_lock_poll * old_polls; // will deallocate old_polls
445  kmp_uint32 num_polls; // must be power of 2
446 
447  //
448  // next_ticket it needs to exist in a separate cache line, as it is
449  // invalidated every time a thread takes a new ticket.
450  //
451  KMP_ALIGN_CACHE
452 
453  volatile kmp_uint64 next_ticket;
454 
455  //
456  // now_serving is used to store our ticket value while we hold the lock.
457  // It has a slightly different meaning in the DRDPA ticket locks (where
458  // it is written by the acquiring thread) than it does in the simple
459  // ticket locks (where it is written by the releasing thread).
460  //
461  // Since now_serving is only read an written in the critical section,
462  // it is non-volatile, but it needs to exist on a separate cache line,
463  // as it is invalidated at every lock acquire.
464  //
465  // Likewise, the vars used for nested locks (owner_id and depth_locked)
466  // are only written by the thread owning the lock, so they are put in
467  // this cache line. owner_id is read by other threads, so it must be
468  // declared volatile.
469  //
470  KMP_ALIGN_CACHE
471 
472  kmp_uint64 now_serving; // doesn't have to be volatile
473  volatile kmp_uint32 owner_id; // (gtid+1) of owning thread, 0 if unlocked
474  kmp_int32 depth_locked; // depth locked
475  kmp_lock_flags_t flags; // lock specifics, e.g. critical section lock
476 };
477 
478 typedef struct kmp_base_drdpa_lock kmp_base_drdpa_lock_t;
479 
480 union KMP_ALIGN_CACHE kmp_drdpa_lock {
481  kmp_base_drdpa_lock_t lk; // This field must be first to allow static initializing. */
482  kmp_lock_pool_t pool;
483  double lk_align; // use worst case alignment
484  char lk_pad[ KMP_PAD( kmp_base_drdpa_lock_t, CACHE_LINE ) ];
485 };
486 
487 typedef union kmp_drdpa_lock kmp_drdpa_lock_t;
488 
489 extern void __kmp_acquire_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
490 extern int __kmp_test_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
491 extern void __kmp_release_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
492 extern void __kmp_init_drdpa_lock( kmp_drdpa_lock_t *lck );
493 extern void __kmp_destroy_drdpa_lock( kmp_drdpa_lock_t *lck );
494 
495 extern void __kmp_acquire_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
496 extern int __kmp_test_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
497 extern void __kmp_release_nested_drdpa_lock( kmp_drdpa_lock_t *lck, kmp_int32 gtid );
498 extern void __kmp_init_nested_drdpa_lock( kmp_drdpa_lock_t *lck );
499 extern void __kmp_destroy_nested_drdpa_lock( kmp_drdpa_lock_t *lck );
500 
501 
502 // ============================================================================
503 // Lock purposes.
504 // ============================================================================
505 
506 
507 // ----------------------------------------------------------------------------
508 // Bootstrap locks.
509 // ----------------------------------------------------------------------------
510 
511 // Bootstrap locks -- very few locks used at library initialization time.
512 // Bootstrap locks are currently implemented as ticket locks.
513 // They could also be implemented as test and set lock, but cannot be
514 // implemented with other lock kinds as they require gtids which are not
515 // available at initialization time.
516 
517 typedef kmp_ticket_lock_t kmp_bootstrap_lock_t;
518 
519 #define KMP_BOOTSTRAP_LOCK_INITIALIZER( lock ) KMP_TICKET_LOCK_INITIALIZER( (lock) )
520 
521 static inline void
522 __kmp_acquire_bootstrap_lock( kmp_bootstrap_lock_t *lck )
523 {
524  __kmp_acquire_ticket_lock( lck, KMP_GTID_DNE );
525 }
526 
527 static inline int
528 __kmp_test_bootstrap_lock( kmp_bootstrap_lock_t *lck )
529 {
530  return __kmp_test_ticket_lock( lck, KMP_GTID_DNE );
531 }
532 
533 static inline void
534 __kmp_release_bootstrap_lock( kmp_bootstrap_lock_t *lck )
535 {
536  __kmp_release_ticket_lock( lck, KMP_GTID_DNE );
537 }
538 
539 static inline void
540 __kmp_init_bootstrap_lock( kmp_bootstrap_lock_t *lck )
541 {
542  __kmp_init_ticket_lock( lck );
543 }
544 
545 static inline void
546 __kmp_destroy_bootstrap_lock( kmp_bootstrap_lock_t *lck )
547 {
548  __kmp_destroy_ticket_lock( lck );
549 }
550 
551 
552 // ----------------------------------------------------------------------------
553 // Internal RTL locks.
554 // ----------------------------------------------------------------------------
555 
556 //
557 // Internal RTL locks are also implemented as ticket locks, for now.
558 //
559 // FIXME - We should go through and figure out which lock kind works best for
560 // each internal lock, and use the type declaration and function calls for
561 // that explicit lock kind (and get rid of this section).
562 //
563 
564 typedef kmp_ticket_lock_t kmp_lock_t;
565 
566 static inline void
567 __kmp_acquire_lock( kmp_lock_t *lck, kmp_int32 gtid )
568 {
569  __kmp_acquire_ticket_lock( lck, gtid );
570 }
571 
572 static inline int
573 __kmp_test_lock( kmp_lock_t *lck, kmp_int32 gtid )
574 {
575  return __kmp_test_ticket_lock( lck, gtid );
576 }
577 
578 static inline void
579 __kmp_release_lock( kmp_lock_t *lck, kmp_int32 gtid )
580 {
581  __kmp_release_ticket_lock( lck, gtid );
582 }
583 
584 static inline void
585 __kmp_init_lock( kmp_lock_t *lck )
586 {
587  __kmp_init_ticket_lock( lck );
588 }
589 
590 static inline void
591 __kmp_destroy_lock( kmp_lock_t *lck )
592 {
593  __kmp_destroy_ticket_lock( lck );
594 }
595 
596 
597 // ----------------------------------------------------------------------------
598 // User locks.
599 // ----------------------------------------------------------------------------
600 
601 //
602 // Do not allocate objects of type union kmp_user_lock!!!
603 // This will waste space unless __kmp_user_lock_kind == lk_drdpa.
604 // Instead, check the value of __kmp_user_lock_kind and allocate objects of
605 // the type of the appropriate union member, and cast their addresses to
606 // kmp_user_lock_p.
607 //
608 
609 enum kmp_lock_kind {
610  lk_default = 0,
611  lk_tas,
612 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
613  lk_futex,
614 #endif
615  lk_ticket,
616  lk_queuing,
617  lk_drdpa,
618 #if KMP_USE_ADAPTIVE_LOCKS
619  lk_adaptive
620 #endif // KMP_USE_ADAPTIVE_LOCKS
621 };
622 
623 typedef enum kmp_lock_kind kmp_lock_kind_t;
624 
625 extern kmp_lock_kind_t __kmp_user_lock_kind;
626 
627 union kmp_user_lock {
628  kmp_tas_lock_t tas;
629 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
630  kmp_futex_lock_t futex;
631 #endif
632  kmp_ticket_lock_t ticket;
633  kmp_queuing_lock_t queuing;
634  kmp_drdpa_lock_t drdpa;
635 #if KMP_USE_ADAPTIVE_LOCKS
636  kmp_adaptive_lock_t adaptive;
637 #endif // KMP_USE_ADAPTIVE_LOCKS
638  kmp_lock_pool_t pool;
639 };
640 
641 typedef union kmp_user_lock *kmp_user_lock_p;
642 
643 extern size_t __kmp_base_user_lock_size;
644 extern size_t __kmp_user_lock_size;
645 
646 extern kmp_int32 ( *__kmp_get_user_lock_owner_ )( kmp_user_lock_p lck );
647 
648 static inline kmp_int32
649 __kmp_get_user_lock_owner( kmp_user_lock_p lck )
650 {
651  KMP_DEBUG_ASSERT( __kmp_get_user_lock_owner_ != NULL );
652  return ( *__kmp_get_user_lock_owner_ )( lck );
653 }
654 
655 extern void ( *__kmp_acquire_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
656 
657 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
658 
659 #define __kmp_acquire_user_lock_with_checks(lck,gtid) \
660  if (__kmp_user_lock_kind == lk_tas) { \
661  if ( __kmp_env_consistency_check ) { \
662  char const * const func = "omp_set_lock"; \
663  if ( ( sizeof ( kmp_tas_lock_t ) <= OMP_LOCK_T_SIZE ) \
664  && lck->tas.lk.depth_locked != -1 ) { \
665  KMP_FATAL( LockNestableUsedAsSimple, func ); \
666  } \
667  if ( ( gtid >= 0 ) && ( lck->tas.lk.poll - 1 == gtid ) ) { \
668  KMP_FATAL( LockIsAlreadyOwned, func ); \
669  } \
670  } \
671  if ( ( lck->tas.lk.poll != 0 ) || \
672  ( ! KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) ) ) { \
673  kmp_uint32 spins; \
674  KMP_FSYNC_PREPARE( lck ); \
675  KMP_INIT_YIELD( spins ); \
676  if ( TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc) ) { \
677  KMP_YIELD( TRUE ); \
678  } else { \
679  KMP_YIELD_SPIN( spins ); \
680  } \
681  while ( ( lck->tas.lk.poll != 0 ) || \
682  ( ! KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) ) ) { \
683  if ( TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc) ) { \
684  KMP_YIELD( TRUE ); \
685  } else { \
686  KMP_YIELD_SPIN( spins ); \
687  } \
688  } \
689  } \
690  KMP_FSYNC_ACQUIRED( lck ); \
691  } else { \
692  KMP_DEBUG_ASSERT( __kmp_acquire_user_lock_with_checks_ != NULL ); \
693  ( *__kmp_acquire_user_lock_with_checks_ )( lck, gtid ); \
694  }
695 
696 #else
697 static inline void
698 __kmp_acquire_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
699 {
700  KMP_DEBUG_ASSERT( __kmp_acquire_user_lock_with_checks_ != NULL );
701  ( *__kmp_acquire_user_lock_with_checks_ )( lck, gtid );
702 }
703 #endif
704 
705 extern int ( *__kmp_test_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
706 
707 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
708 
709 #include "kmp_i18n.h" /* AC: KMP_FATAL definition */
710 extern int __kmp_env_consistency_check; /* AC: copy from kmp.h here */
711 static inline int
712 __kmp_test_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
713 {
714  if ( __kmp_user_lock_kind == lk_tas ) {
715  if ( __kmp_env_consistency_check ) {
716  char const * const func = "omp_test_lock";
717  if ( ( sizeof ( kmp_tas_lock_t ) <= OMP_LOCK_T_SIZE )
718  && lck->tas.lk.depth_locked != -1 ) {
719  KMP_FATAL( LockNestableUsedAsSimple, func );
720  }
721  }
722  return ( ( lck->tas.lk.poll == 0 ) &&
723  KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) );
724  } else {
725  KMP_DEBUG_ASSERT( __kmp_test_user_lock_with_checks_ != NULL );
726  return ( *__kmp_test_user_lock_with_checks_ )( lck, gtid );
727  }
728 }
729 #else
730 static inline int
731 __kmp_test_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
732 {
733  KMP_DEBUG_ASSERT( __kmp_test_user_lock_with_checks_ != NULL );
734  return ( *__kmp_test_user_lock_with_checks_ )( lck, gtid );
735 }
736 #endif
737 
738 extern void ( *__kmp_release_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
739 
740 static inline void
741 __kmp_release_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
742 {
743  KMP_DEBUG_ASSERT( __kmp_release_user_lock_with_checks_ != NULL );
744  ( *__kmp_release_user_lock_with_checks_ ) ( lck, gtid );
745 }
746 
747 extern void ( *__kmp_init_user_lock_with_checks_ )( kmp_user_lock_p lck );
748 
749 static inline void
750 __kmp_init_user_lock_with_checks( kmp_user_lock_p lck )
751 {
752  KMP_DEBUG_ASSERT( __kmp_init_user_lock_with_checks_ != NULL );
753  ( *__kmp_init_user_lock_with_checks_ )( lck );
754 }
755 
756 //
757 // We need a non-checking version of destroy lock for when the RTL is
758 // doing the cleanup as it can't always tell if the lock is nested or not.
759 //
760 extern void ( *__kmp_destroy_user_lock_ )( kmp_user_lock_p lck );
761 
762 static inline void
763 __kmp_destroy_user_lock( kmp_user_lock_p lck )
764 {
765  KMP_DEBUG_ASSERT( __kmp_destroy_user_lock_ != NULL );
766  ( *__kmp_destroy_user_lock_ )( lck );
767 }
768 
769 extern void ( *__kmp_destroy_user_lock_with_checks_ )( kmp_user_lock_p lck );
770 
771 static inline void
772 __kmp_destroy_user_lock_with_checks( kmp_user_lock_p lck )
773 {
774  KMP_DEBUG_ASSERT( __kmp_destroy_user_lock_with_checks_ != NULL );
775  ( *__kmp_destroy_user_lock_with_checks_ )( lck );
776 }
777 
778 extern void ( *__kmp_acquire_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
779 
780 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
781 
782 #define __kmp_acquire_nested_user_lock_with_checks(lck,gtid) \
783  if (__kmp_user_lock_kind == lk_tas) { \
784  if ( __kmp_env_consistency_check ) { \
785  char const * const func = "omp_set_nest_lock"; \
786  if ( ( sizeof ( kmp_tas_lock_t ) <= OMP_NEST_LOCK_T_SIZE ) \
787  && lck->tas.lk.depth_locked == -1 ) { \
788  KMP_FATAL( LockSimpleUsedAsNestable, func ); \
789  } \
790  } \
791  if ( lck->tas.lk.poll - 1 == gtid ) { \
792  lck->tas.lk.depth_locked += 1; \
793  } else { \
794  if ( ( lck->tas.lk.poll != 0 ) || \
795  ( ! KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) ) ) { \
796  kmp_uint32 spins; \
797  KMP_FSYNC_PREPARE( lck ); \
798  KMP_INIT_YIELD( spins ); \
799  if ( TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc) ) { \
800  KMP_YIELD( TRUE ); \
801  } else { \
802  KMP_YIELD_SPIN( spins ); \
803  } \
804  while ( ( lck->tas.lk.poll != 0 ) || \
805  ( ! KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) ) ) { \
806  if ( TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc) ) { \
807  KMP_YIELD( TRUE ); \
808  } else { \
809  KMP_YIELD_SPIN( spins ); \
810  } \
811  } \
812  } \
813  lck->tas.lk.depth_locked = 1; \
814  } \
815  KMP_FSYNC_ACQUIRED( lck ); \
816  } else { \
817  KMP_DEBUG_ASSERT( __kmp_acquire_nested_user_lock_with_checks_ != NULL ); \
818  ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid ); \
819  }
820 
821 #else
822 static inline void
823 __kmp_acquire_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
824 {
825  KMP_DEBUG_ASSERT( __kmp_acquire_nested_user_lock_with_checks_ != NULL );
826  ( *__kmp_acquire_nested_user_lock_with_checks_ )( lck, gtid );
827 }
828 #endif
829 
830 extern int ( *__kmp_test_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
831 
832 #if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64)
833 static inline int
834 __kmp_test_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
835 {
836  if ( __kmp_user_lock_kind == lk_tas ) {
837  int retval;
838  if ( __kmp_env_consistency_check ) {
839  char const * const func = "omp_test_nest_lock";
840  if ( ( sizeof ( kmp_tas_lock_t ) <= OMP_NEST_LOCK_T_SIZE )
841  && lck->tas.lk.depth_locked == -1 ) {
842  KMP_FATAL( LockSimpleUsedAsNestable, func );
843  }
844  }
845  KMP_DEBUG_ASSERT( gtid >= 0 );
846  if ( lck->tas.lk.poll - 1 == gtid ) { /* __kmp_get_tas_lock_owner( lck ) == gtid */
847  return ++lck->tas.lk.depth_locked; /* same owner, depth increased */
848  }
849  retval = ( ( lck->tas.lk.poll == 0 ) &&
850  KMP_COMPARE_AND_STORE_ACQ32( &(lck->tas.lk.poll), 0, gtid + 1 ) );
851  if ( retval ) {
852  KMP_MB();
853  lck->tas.lk.depth_locked = 1;
854  }
855  return retval;
856  } else {
857  KMP_DEBUG_ASSERT( __kmp_test_nested_user_lock_with_checks_ != NULL );
858  return ( *__kmp_test_nested_user_lock_with_checks_ )( lck, gtid );
859  }
860 }
861 #else
862 static inline int
863 __kmp_test_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
864 {
865  KMP_DEBUG_ASSERT( __kmp_test_nested_user_lock_with_checks_ != NULL );
866  return ( *__kmp_test_nested_user_lock_with_checks_ )( lck, gtid );
867 }
868 #endif
869 
870 extern void ( *__kmp_release_nested_user_lock_with_checks_ )( kmp_user_lock_p lck, kmp_int32 gtid );
871 
872 static inline void
873 __kmp_release_nested_user_lock_with_checks( kmp_user_lock_p lck, kmp_int32 gtid )
874 {
875  KMP_DEBUG_ASSERT( __kmp_release_nested_user_lock_with_checks_ != NULL );
876  ( *__kmp_release_nested_user_lock_with_checks_ )( lck, gtid );
877 }
878 
879 extern void ( *__kmp_init_nested_user_lock_with_checks_ )( kmp_user_lock_p lck );
880 
881 static inline void __kmp_init_nested_user_lock_with_checks( kmp_user_lock_p lck )
882 {
883  KMP_DEBUG_ASSERT( __kmp_init_nested_user_lock_with_checks_ != NULL );
884  ( *__kmp_init_nested_user_lock_with_checks_ )( lck );
885 }
886 
887 extern void ( *__kmp_destroy_nested_user_lock_with_checks_ )( kmp_user_lock_p lck );
888 
889 static inline void
890 __kmp_destroy_nested_user_lock_with_checks( kmp_user_lock_p lck )
891 {
892  KMP_DEBUG_ASSERT( __kmp_destroy_nested_user_lock_with_checks_ != NULL );
893  ( *__kmp_destroy_nested_user_lock_with_checks_ )( lck );
894 }
895 
896 //
897 // user lock functions which do not necessarily exist for all lock kinds.
898 //
899 // The "set" functions usually have wrapper routines that check for a NULL set
900 // function pointer and call it if non-NULL.
901 //
902 // In some cases, it makes sense to have a "get" wrapper function check for a
903 // NULL get function pointer and return NULL / invalid value / error code if
904 // the function pointer is NULL.
905 //
906 // In other cases, the calling code really should differentiate between an
907 // unimplemented function and one that is implemented but returning NULL /
908 // invalied value. If this is the case, no get function wrapper exists.
909 //
910 
911 extern int ( *__kmp_is_user_lock_initialized_ )( kmp_user_lock_p lck );
912 
913 // no set function; fields set durining local allocation
914 
915 extern const ident_t * ( *__kmp_get_user_lock_location_ )( kmp_user_lock_p lck );
916 
917 static inline const ident_t *
918 __kmp_get_user_lock_location( kmp_user_lock_p lck )
919 {
920  if ( __kmp_get_user_lock_location_ != NULL ) {
921  return ( *__kmp_get_user_lock_location_ )( lck );
922  }
923  else {
924  return NULL;
925  }
926 }
927 
928 extern void ( *__kmp_set_user_lock_location_ )( kmp_user_lock_p lck, const ident_t *loc );
929 
930 static inline void
931 __kmp_set_user_lock_location( kmp_user_lock_p lck, const ident_t *loc )
932 {
933  if ( __kmp_set_user_lock_location_ != NULL ) {
934  ( *__kmp_set_user_lock_location_ )( lck, loc );
935  }
936 }
937 
938 extern kmp_lock_flags_t ( *__kmp_get_user_lock_flags_ )( kmp_user_lock_p lck );
939 
940 extern void ( *__kmp_set_user_lock_flags_ )( kmp_user_lock_p lck, kmp_lock_flags_t flags );
941 
942 static inline void
943 __kmp_set_user_lock_flags( kmp_user_lock_p lck, kmp_lock_flags_t flags )
944 {
945  if ( __kmp_set_user_lock_flags_ != NULL ) {
946  ( *__kmp_set_user_lock_flags_ )( lck, flags );
947  }
948 }
949 
950 //
951 // The fuction which sets up all of the vtbl pointers for kmp_user_lock_t.
952 //
953 extern void __kmp_set_user_lock_vptrs( kmp_lock_kind_t user_lock_kind );
954 
955 //
956 // Macros for binding user lock functions.
957 //
958 #define KMP_BIND_USER_LOCK_TEMPLATE(nest, kind, suffix) { \
959  __kmp_acquire##nest##user_lock_with_checks_ = ( void (*)( kmp_user_lock_p, kmp_int32 ) ) \
960  __kmp_acquire##nest##kind##_##suffix; \
961  __kmp_release##nest##user_lock_with_checks_ = ( void (*)( kmp_user_lock_p, kmp_int32 ) ) \
962  __kmp_release##nest##kind##_##suffix; \
963  __kmp_test##nest##user_lock_with_checks_ = ( int (*)( kmp_user_lock_p, kmp_int32 ) ) \
964  __kmp_test##nest##kind##_##suffix; \
965  __kmp_init##nest##user_lock_with_checks_ = ( void (*)( kmp_user_lock_p ) ) \
966  __kmp_init##nest##kind##_##suffix; \
967  __kmp_destroy##nest##user_lock_with_checks_ = ( void (*)( kmp_user_lock_p ) ) \
968  __kmp_destroy##nest##kind##_##suffix; \
969 }
970 
971 #define KMP_BIND_USER_LOCK(kind) KMP_BIND_USER_LOCK_TEMPLATE(_, kind, lock)
972 #define KMP_BIND_USER_LOCK_WITH_CHECKS(kind) KMP_BIND_USER_LOCK_TEMPLATE(_, kind, lock_with_checks)
973 #define KMP_BIND_NESTED_USER_LOCK(kind) KMP_BIND_USER_LOCK_TEMPLATE(_nested_, kind, lock)
974 #define KMP_BIND_NESTED_USER_LOCK_WITH_CHECKS(kind) KMP_BIND_USER_LOCK_TEMPLATE(_nested_, kind, lock_with_checks)
975 
976 // ----------------------------------------------------------------------------
977 // User lock table & lock allocation
978 // ----------------------------------------------------------------------------
979 
980 /*
981  On 64-bit Linux* OS (and OS X*) GNU compiler allocates only 4 bytems memory for lock variable, which
982  is not enough to store a pointer, so we have to use lock indexes instead of pointers and
983  maintain lock table to map indexes to pointers.
984 
985 
986  Note: The first element of the table is not a pointer to lock! It is a pointer to previously
987  allocated table (or NULL if it is the first table).
988 
989  Usage:
990 
991  if ( OMP_LOCK_T_SIZE < sizeof( <lock> ) ) { // or OMP_NEST_LOCK_T_SIZE
992  Lock table is fully utilized. User locks are indexes, so table is
993  used on user lock operation.
994  Note: it may be the case (lin_32) that we don't need to use a lock
995  table for regular locks, but do need the table for nested locks.
996  }
997  else {
998  Lock table initialized but not actually used.
999  }
1000 */
1001 
1002 struct kmp_lock_table {
1003  kmp_lock_index_t used; // Number of used elements
1004  kmp_lock_index_t allocated; // Number of allocated elements
1005  kmp_user_lock_p * table; // Lock table.
1006 };
1007 
1008 typedef struct kmp_lock_table kmp_lock_table_t;
1009 
1010 extern kmp_lock_table_t __kmp_user_lock_table;
1011 extern kmp_user_lock_p __kmp_lock_pool;
1012 
1013 struct kmp_block_of_locks {
1014  struct kmp_block_of_locks * next_block;
1015  void * locks;
1016 };
1017 
1018 typedef struct kmp_block_of_locks kmp_block_of_locks_t;
1019 
1020 extern kmp_block_of_locks_t *__kmp_lock_blocks;
1021 extern int __kmp_num_locks_in_block;
1022 
1023 extern kmp_user_lock_p __kmp_user_lock_allocate( void **user_lock, kmp_int32 gtid, kmp_lock_flags_t flags );
1024 extern void __kmp_user_lock_free( void **user_lock, kmp_int32 gtid, kmp_user_lock_p lck );
1025 extern kmp_user_lock_p __kmp_lookup_user_lock( void **user_lock, char const *func );
1026 extern void __kmp_cleanup_user_locks();
1027 
1028 #define KMP_CHECK_USER_LOCK_INIT() \
1029  { \
1030  if ( ! TCR_4( __kmp_init_user_locks ) ) { \
1031  __kmp_acquire_bootstrap_lock( &__kmp_initz_lock ); \
1032  if ( ! TCR_4( __kmp_init_user_locks ) ) { \
1033  TCW_4( __kmp_init_user_locks, TRUE ); \
1034  } \
1035  __kmp_release_bootstrap_lock( &__kmp_initz_lock ); \
1036  } \
1037  }
1038 
1039 #undef KMP_PAD
1040 #undef KMP_GTID_DNE
1041 
1042 #ifdef __cplusplus
1043 } // extern "C"
1044 #endif // __cplusplus
1045 
1046 #endif /* KMP_LOCK_H */
1047 
Definition: kmp.h:218