forked from OSchip/llvm-project
parent
412eabdeb2
commit
f2d119ff8e
|
@ -926,12 +926,12 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
ret = (kmp_indirect_lock_t *)TCR_PTR(*lck);
|
ret = (kmp_indirect_lock_t *)TCR_PTR(*lck);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
void *idx;
|
void *idx;
|
||||||
kmp_indirect_locktag_t tag = DYNA_GET_I_TAG(seq);
|
kmp_indirect_locktag_t tag = KMP_GET_I_TAG(seq);
|
||||||
kmp_indirect_lock_t *ilk = __kmp_allocate_indirect_lock(&idx, gtid, tag);
|
kmp_indirect_lock_t *ilk = __kmp_allocate_indirect_lock(&idx, gtid, tag);
|
||||||
ret = ilk;
|
ret = ilk;
|
||||||
DYNA_I_LOCK_FUNC(ilk, init)(ilk->lock);
|
KMP_I_LOCK_FUNC(ilk, init)(ilk->lock);
|
||||||
DYNA_SET_I_LOCK_LOCATION(ilk, loc);
|
KMP_SET_I_LOCK_LOCATION(ilk, loc);
|
||||||
DYNA_SET_I_LOCK_FLAGS(ilk, kmp_lf_critical_section);
|
KMP_SET_I_LOCK_FLAGS(ilk, kmp_lf_critical_section);
|
||||||
KA_TRACE(20, ("__kmp_get_indirect_csptr: initialized indirect lock #%d\n", tag));
|
KA_TRACE(20, ("__kmp_get_indirect_csptr: initialized indirect lock #%d\n", tag));
|
||||||
#if USE_ITT_BUILD
|
#if USE_ITT_BUILD
|
||||||
__kmp_itt_critical_creating(ilk->lock, loc);
|
__kmp_itt_critical_creating(ilk->lock, loc);
|
||||||
|
@ -942,7 +942,7 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
__kmp_itt_critical_destroyed(ilk->lock);
|
__kmp_itt_critical_destroyed(ilk->lock);
|
||||||
#endif
|
#endif
|
||||||
// Postponing destroy, to avoid costly dispatch here.
|
// Postponing destroy, to avoid costly dispatch here.
|
||||||
//DYNA_D_LOCK_FUNC(&idx, destroy)((kmp_dyna_lock_t *)&idx);
|
//KMP_D_LOCK_FUNC(&idx, destroy)((kmp_dyna_lock_t *)&idx);
|
||||||
ret = (kmp_indirect_lock_t *)TCR_PTR(*lck);
|
ret = (kmp_indirect_lock_t *)TCR_PTR(*lck);
|
||||||
KMP_DEBUG_ASSERT(ret != NULL);
|
KMP_DEBUG_ASSERT(ret != NULL);
|
||||||
}
|
}
|
||||||
|
@ -951,10 +951,10 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fast-path acquire tas lock
|
// Fast-path acquire tas lock
|
||||||
#define DYNA_ACQUIRE_TAS_LOCK(lock, gtid) { \
|
#define KMP_ACQUIRE_TAS_LOCK(lock, gtid) { \
|
||||||
kmp_tas_lock_t *l = (kmp_tas_lock_t *)lock; \
|
kmp_tas_lock_t *l = (kmp_tas_lock_t *)lock; \
|
||||||
if (l->lk.poll != DYNA_LOCK_FREE(tas) || \
|
if (l->lk.poll != KMP_LOCK_FREE(tas) || \
|
||||||
! KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas))) { \
|
! KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas))) { \
|
||||||
kmp_uint32 spins; \
|
kmp_uint32 spins; \
|
||||||
KMP_FSYNC_PREPARE(l); \
|
KMP_FSYNC_PREPARE(l); \
|
||||||
KMP_INIT_YIELD(spins); \
|
KMP_INIT_YIELD(spins); \
|
||||||
|
@ -963,8 +963,8 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
} else { \
|
} else { \
|
||||||
KMP_YIELD_SPIN(spins); \
|
KMP_YIELD_SPIN(spins); \
|
||||||
} \
|
} \
|
||||||
while (l->lk.poll != DYNA_LOCK_FREE(tas) || \
|
while (l->lk.poll != KMP_LOCK_FREE(tas) || \
|
||||||
! KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas))) { \
|
! KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas))) { \
|
||||||
if (TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) { \
|
if (TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)) { \
|
||||||
KMP_YIELD(TRUE); \
|
KMP_YIELD(TRUE); \
|
||||||
} else { \
|
} else { \
|
||||||
|
@ -976,19 +976,19 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fast-path test tas lock
|
// Fast-path test tas lock
|
||||||
#define DYNA_TEST_TAS_LOCK(lock, gtid, rc) { \
|
#define KMP_TEST_TAS_LOCK(lock, gtid, rc) { \
|
||||||
kmp_tas_lock_t *l = (kmp_tas_lock_t *)lock; \
|
kmp_tas_lock_t *l = (kmp_tas_lock_t *)lock; \
|
||||||
rc = l->lk.poll == DYNA_LOCK_FREE(tas) && \
|
rc = l->lk.poll == KMP_LOCK_FREE(tas) && \
|
||||||
KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas)); \
|
KMP_COMPARE_AND_STORE_ACQ32(&(l->lk.poll), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fast-path release tas lock
|
// Fast-path release tas lock
|
||||||
#define DYNA_RELEASE_TAS_LOCK(lock, gtid) { \
|
#define KMP_RELEASE_TAS_LOCK(lock, gtid) { \
|
||||||
TCW_4(((kmp_tas_lock_t *)lock)->lk.poll, DYNA_LOCK_FREE(tas)); \
|
TCW_4(((kmp_tas_lock_t *)lock)->lk.poll, KMP_LOCK_FREE(tas)); \
|
||||||
KMP_MB(); \
|
KMP_MB(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DYNA_HAS_FUTEX
|
#if KMP_HAS_FUTEX
|
||||||
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <sys/syscall.h>
|
# include <sys/syscall.h>
|
||||||
|
@ -1000,20 +1000,20 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Fast-path acquire futex lock
|
// Fast-path acquire futex lock
|
||||||
#define DYNA_ACQUIRE_FUTEX_LOCK(lock, gtid) { \
|
#define KMP_ACQUIRE_FUTEX_LOCK(lock, gtid) { \
|
||||||
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
||||||
kmp_int32 gtid_code = (gtid+1) << 1; \
|
kmp_int32 gtid_code = (gtid+1) << 1; \
|
||||||
KMP_MB(); \
|
KMP_MB(); \
|
||||||
KMP_FSYNC_PREPARE(ftx); \
|
KMP_FSYNC_PREPARE(ftx); \
|
||||||
kmp_int32 poll_val; \
|
kmp_int32 poll_val; \
|
||||||
while ((poll_val = KMP_COMPARE_AND_STORE_RET32(&(ftx->lk.poll), DYNA_LOCK_FREE(futex), \
|
while ((poll_val = KMP_COMPARE_AND_STORE_RET32(&(ftx->lk.poll), KMP_LOCK_FREE(futex), \
|
||||||
DYNA_LOCK_BUSY(gtid_code, futex))) != DYNA_LOCK_FREE(futex)) { \
|
KMP_LOCK_BUSY(gtid_code, futex))) != KMP_LOCK_FREE(futex)) { \
|
||||||
kmp_int32 cond = DYNA_LOCK_STRIP(poll_val) & 1; \
|
kmp_int32 cond = KMP_LOCK_STRIP(poll_val) & 1; \
|
||||||
if (!cond) { \
|
if (!cond) { \
|
||||||
if (!KMP_COMPARE_AND_STORE_RET32(&(ftx->lk.poll), poll_val, poll_val | DYNA_LOCK_BUSY(1, futex))) { \
|
if (!KMP_COMPARE_AND_STORE_RET32(&(ftx->lk.poll), poll_val, poll_val | KMP_LOCK_BUSY(1, futex))) { \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
poll_val |= DYNA_LOCK_BUSY(1, futex); \
|
poll_val |= KMP_LOCK_BUSY(1, futex); \
|
||||||
} \
|
} \
|
||||||
kmp_int32 rc; \
|
kmp_int32 rc; \
|
||||||
if ((rc = syscall(__NR_futex, &(ftx->lk.poll), FUTEX_WAIT, poll_val, NULL, NULL, 0)) != 0) { \
|
if ((rc = syscall(__NR_futex, &(ftx->lk.poll), FUTEX_WAIT, poll_val, NULL, NULL, 0)) != 0) { \
|
||||||
|
@ -1025,9 +1025,9 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fast-path test futex lock
|
// Fast-path test futex lock
|
||||||
#define DYNA_TEST_FUTEX_LOCK(lock, gtid, rc) { \
|
#define KMP_TEST_FUTEX_LOCK(lock, gtid, rc) { \
|
||||||
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
||||||
if (KMP_COMPARE_AND_STORE_ACQ32(&(ftx->lk.poll), DYNA_LOCK_FREE(futex), DYNA_LOCK_BUSY(gtid+1, futex) << 1)) { \
|
if (KMP_COMPARE_AND_STORE_ACQ32(&(ftx->lk.poll), KMP_LOCK_FREE(futex), KMP_LOCK_BUSY(gtid+1, futex) << 1)) { \
|
||||||
KMP_FSYNC_ACQUIRED(ftx); \
|
KMP_FSYNC_ACQUIRED(ftx); \
|
||||||
rc = TRUE; \
|
rc = TRUE; \
|
||||||
} else { \
|
} else { \
|
||||||
|
@ -1036,19 +1036,19 @@ __kmp_get_indirect_csptr(kmp_critical_name * crit, ident_t const * loc, kmp_int3
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fast-path release futex lock
|
// Fast-path release futex lock
|
||||||
#define DYNA_RELEASE_FUTEX_LOCK(lock, gtid) { \
|
#define KMP_RELEASE_FUTEX_LOCK(lock, gtid) { \
|
||||||
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
kmp_futex_lock_t *ftx = (kmp_futex_lock_t *)lock; \
|
||||||
KMP_MB(); \
|
KMP_MB(); \
|
||||||
KMP_FSYNC_RELEASING(ftx); \
|
KMP_FSYNC_RELEASING(ftx); \
|
||||||
kmp_int32 poll_val = KMP_XCHG_FIXED32(&(ftx->lk.poll), DYNA_LOCK_FREE(futex)); \
|
kmp_int32 poll_val = KMP_XCHG_FIXED32(&(ftx->lk.poll), KMP_LOCK_FREE(futex)); \
|
||||||
if (DYNA_LOCK_STRIP(poll_val) & 1) { \
|
if (KMP_LOCK_STRIP(poll_val) & 1) { \
|
||||||
syscall(__NR_futex, &(ftx->lk.poll), FUTEX_WAKE, DYNA_LOCK_BUSY(1, futex), NULL, NULL, 0); \
|
syscall(__NR_futex, &(ftx->lk.poll), FUTEX_WAKE, KMP_LOCK_BUSY(1, futex), NULL, NULL, 0); \
|
||||||
} \
|
} \
|
||||||
KMP_MB(); \
|
KMP_MB(); \
|
||||||
KMP_YIELD(TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)); \
|
KMP_YIELD(TCR_4(__kmp_nth) > (__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DYNA_HAS_FUTEX
|
#endif // KMP_HAS_FUTEX
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
|
@ -1126,11 +1126,11 @@ __kmpc_critical( ident_t * loc, kmp_int32 global_tid, kmp_critical_name * crit )
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
// Assumption: all direct locks fit in OMP_CRITICAL_SIZE.
|
// Assumption: all direct locks fit in OMP_CRITICAL_SIZE.
|
||||||
// The global sequence __kmp_user_lock_seq is used unless compiler pushes a value.
|
// The global sequence __kmp_user_lock_seq is used unless compiler pushes a value.
|
||||||
if (DYNA_IS_D_LOCK(__kmp_user_lock_seq)) {
|
if (KMP_IS_D_LOCK(__kmp_user_lock_seq)) {
|
||||||
lck = (kmp_user_lock_p)crit;
|
lck = (kmp_user_lock_p)crit;
|
||||||
// The thread that reaches here first needs to tag the lock word.
|
// The thread that reaches here first needs to tag the lock word.
|
||||||
if (*((kmp_dyna_lock_t *)lck) == 0) {
|
if (*((kmp_dyna_lock_t *)lck) == 0) {
|
||||||
KMP_COMPARE_AND_STORE_ACQ32((volatile kmp_int32 *)lck, 0, DYNA_GET_D_TAG(__kmp_user_lock_seq));
|
KMP_COMPARE_AND_STORE_ACQ32((volatile kmp_int32 *)lck, 0, KMP_GET_D_TAG(__kmp_user_lock_seq));
|
||||||
}
|
}
|
||||||
if (__kmp_env_consistency_check) {
|
if (__kmp_env_consistency_check) {
|
||||||
__kmp_push_sync(global_tid, ct_critical, loc, lck, __kmp_user_lock_seq);
|
__kmp_push_sync(global_tid, ct_critical, loc, lck, __kmp_user_lock_seq);
|
||||||
|
@ -1138,17 +1138,17 @@ __kmpc_critical( ident_t * loc, kmp_int32 global_tid, kmp_critical_name * crit )
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_critical_acquiring(lck);
|
__kmp_itt_critical_acquiring(lck);
|
||||||
# endif
|
# endif
|
||||||
# if DYNA_USE_FAST_TAS
|
# if KMP_USE_FAST_TAS
|
||||||
if (__kmp_user_lock_seq == lockseq_tas && !__kmp_env_consistency_check) {
|
if (__kmp_user_lock_seq == lockseq_tas && !__kmp_env_consistency_check) {
|
||||||
DYNA_ACQUIRE_TAS_LOCK(lck, global_tid);
|
KMP_ACQUIRE_TAS_LOCK(lck, global_tid);
|
||||||
} else
|
} else
|
||||||
# elif DYNA_USE_FAST_FUTEX
|
# elif KMP_USE_FAST_FUTEX
|
||||||
if (__kmp_user_lock_seq == lockseq_futex && !__kmp_env_consistency_check) {
|
if (__kmp_user_lock_seq == lockseq_futex && !__kmp_env_consistency_check) {
|
||||||
DYNA_ACQUIRE_FUTEX_LOCK(lck, global_tid);
|
KMP_ACQUIRE_FUTEX_LOCK(lck, global_tid);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
DYNA_D_LOCK_FUNC(lck, set)((kmp_dyna_lock_t *)lck, global_tid);
|
KMP_D_LOCK_FUNC(lck, set)((kmp_dyna_lock_t *)lck, global_tid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
kmp_indirect_lock_t *ilk = __kmp_get_indirect_csptr(crit, loc, global_tid, __kmp_user_lock_seq);
|
kmp_indirect_lock_t *ilk = __kmp_get_indirect_csptr(crit, loc, global_tid, __kmp_user_lock_seq);
|
||||||
|
@ -1159,7 +1159,7 @@ __kmpc_critical( ident_t * loc, kmp_int32 global_tid, kmp_critical_name * crit )
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_critical_acquiring(lck);
|
__kmp_itt_critical_acquiring(lck);
|
||||||
# endif
|
# endif
|
||||||
DYNA_I_LOCK_FUNC(ilk, set)(lck, global_tid);
|
KMP_I_LOCK_FUNC(ilk, set)(lck, global_tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
@ -1223,7 +1223,7 @@ __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid, kmp_critical_name *crit)
|
||||||
KC_TRACE( 10, ("__kmpc_end_critical: called T#%d\n", global_tid ));
|
KC_TRACE( 10, ("__kmpc_end_critical: called T#%d\n", global_tid ));
|
||||||
|
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
if (DYNA_IS_D_LOCK(__kmp_user_lock_seq)) {
|
if (KMP_IS_D_LOCK(__kmp_user_lock_seq)) {
|
||||||
lck = (kmp_user_lock_p)crit;
|
lck = (kmp_user_lock_p)crit;
|
||||||
KMP_ASSERT(lck != NULL);
|
KMP_ASSERT(lck != NULL);
|
||||||
if (__kmp_env_consistency_check) {
|
if (__kmp_env_consistency_check) {
|
||||||
|
@ -1232,17 +1232,17 @@ __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid, kmp_critical_name *crit)
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_critical_releasing( lck );
|
__kmp_itt_critical_releasing( lck );
|
||||||
# endif
|
# endif
|
||||||
# if DYNA_USE_FAST_TAS
|
# if KMP_USE_FAST_TAS
|
||||||
if (__kmp_user_lock_seq == lockseq_tas && !__kmp_env_consistency_check) {
|
if (__kmp_user_lock_seq == lockseq_tas && !__kmp_env_consistency_check) {
|
||||||
DYNA_RELEASE_TAS_LOCK(lck, global_tid);
|
KMP_RELEASE_TAS_LOCK(lck, global_tid);
|
||||||
} else
|
} else
|
||||||
# elif DYNA_USE_FAST_FUTEX
|
# elif KMP_USE_FAST_FUTEX
|
||||||
if (__kmp_user_lock_seq == lockseq_futex && !__kmp_env_consistency_check) {
|
if (__kmp_user_lock_seq == lockseq_futex && !__kmp_env_consistency_check) {
|
||||||
DYNA_RELEASE_FUTEX_LOCK(lck, global_tid);
|
KMP_RELEASE_FUTEX_LOCK(lck, global_tid);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
DYNA_D_LOCK_FUNC(lck, unset)((kmp_dyna_lock_t *)lck, global_tid);
|
KMP_D_LOCK_FUNC(lck, unset)((kmp_dyna_lock_t *)lck, global_tid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
kmp_indirect_lock_t *ilk = (kmp_indirect_lock_t *)TCR_PTR(*((kmp_indirect_lock_t **)crit));
|
kmp_indirect_lock_t *ilk = (kmp_indirect_lock_t *)TCR_PTR(*((kmp_indirect_lock_t **)crit));
|
||||||
|
@ -1254,7 +1254,7 @@ __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid, kmp_critical_name *crit)
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_critical_releasing( lck );
|
__kmp_itt_critical_releasing( lck );
|
||||||
# endif
|
# endif
|
||||||
DYNA_I_LOCK_FUNC(ilk, unset)(lck, global_tid);
|
KMP_I_LOCK_FUNC(ilk, unset)(lck, global_tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
@ -1757,15 +1757,15 @@ __kmpc_init_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
if (__kmp_env_consistency_check && user_lock == NULL) {
|
if (__kmp_env_consistency_check && user_lock == NULL) {
|
||||||
KMP_FATAL(LockIsUninitialized, "omp_init_lock");
|
KMP_FATAL(LockIsUninitialized, "omp_init_lock");
|
||||||
}
|
}
|
||||||
if (DYNA_IS_D_LOCK(__kmp_user_lock_seq)) {
|
if (KMP_IS_D_LOCK(__kmp_user_lock_seq)) {
|
||||||
DYNA_INIT_D_LOCK(user_lock, __kmp_user_lock_seq);
|
KMP_INIT_D_LOCK(user_lock, __kmp_user_lock_seq);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_creating((kmp_user_lock_p)user_lock, NULL);
|
__kmp_itt_lock_creating((kmp_user_lock_p)user_lock, NULL);
|
||||||
# endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
DYNA_INIT_I_LOCK(user_lock, __kmp_user_lock_seq);
|
KMP_INIT_I_LOCK(user_lock, __kmp_user_lock_seq);
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(user_lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(user_lock);
|
||||||
DYNA_SET_I_LOCK_LOCATION(ilk, loc);
|
KMP_SET_I_LOCK_LOCATION(ilk, loc);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_creating(ilk->lock, loc);
|
__kmp_itt_lock_creating(ilk->lock, loc);
|
||||||
# endif
|
# endif
|
||||||
|
@ -1828,7 +1828,7 @@ __kmpc_init_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
kmp_dyna_lockseq_t nested_seq;
|
kmp_dyna_lockseq_t nested_seq;
|
||||||
switch (__kmp_user_lock_seq) {
|
switch (__kmp_user_lock_seq) {
|
||||||
case lockseq_tas: nested_seq = lockseq_nested_tas; break;
|
case lockseq_tas: nested_seq = lockseq_nested_tas; break;
|
||||||
#if DYNA_HAS_FUTEX
|
#if KMP_HAS_FUTEX
|
||||||
case lockseq_futex: nested_seq = lockseq_nested_futex; break;
|
case lockseq_futex: nested_seq = lockseq_nested_futex; break;
|
||||||
#endif
|
#endif
|
||||||
case lockseq_ticket: nested_seq = lockseq_nested_ticket; break;
|
case lockseq_ticket: nested_seq = lockseq_nested_ticket; break;
|
||||||
|
@ -1837,10 +1837,10 @@ __kmpc_init_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
default: nested_seq = lockseq_nested_queuing; break;
|
default: nested_seq = lockseq_nested_queuing; break;
|
||||||
// Use nested queuing lock for lock kinds without "nested" implementation.
|
// Use nested queuing lock for lock kinds without "nested" implementation.
|
||||||
}
|
}
|
||||||
DYNA_INIT_I_LOCK(user_lock, nested_seq);
|
KMP_INIT_I_LOCK(user_lock, nested_seq);
|
||||||
// All nested locks are indirect locks.
|
// All nested locks are indirect locks.
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(user_lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(user_lock);
|
||||||
DYNA_SET_I_LOCK_LOCATION(ilk, loc);
|
KMP_SET_I_LOCK_LOCATION(ilk, loc);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_creating(ilk->lock, loc);
|
__kmp_itt_lock_creating(ilk->lock, loc);
|
||||||
# endif
|
# endif
|
||||||
|
@ -1897,14 +1897,14 @@ __kmpc_destroy_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
|
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
kmp_user_lock_p lck;
|
kmp_user_lock_p lck;
|
||||||
if (DYNA_EXTRACT_D_TAG(user_lock) == 0) {
|
if (KMP_EXTRACT_D_TAG(user_lock) == 0) {
|
||||||
lck = ((kmp_indirect_lock_t *)DYNA_LOOKUP_I_LOCK(user_lock))->lock;
|
lck = ((kmp_indirect_lock_t *)KMP_LOOKUP_I_LOCK(user_lock))->lock;
|
||||||
} else {
|
} else {
|
||||||
lck = (kmp_user_lock_p)user_lock;
|
lck = (kmp_user_lock_p)user_lock;
|
||||||
}
|
}
|
||||||
__kmp_itt_lock_destroyed(lck);
|
__kmp_itt_lock_destroyed(lck);
|
||||||
# endif
|
# endif
|
||||||
DYNA_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
|
KMP_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
|
||||||
#else
|
#else
|
||||||
kmp_user_lock_p lck;
|
kmp_user_lock_p lck;
|
||||||
|
|
||||||
|
@ -1956,10 +1956,10 @@ __kmpc_destroy_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(user_lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(user_lock);
|
||||||
__kmp_itt_lock_destroyed(ilk->lock);
|
__kmp_itt_lock_destroyed(ilk->lock);
|
||||||
# endif
|
# endif
|
||||||
DYNA_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
|
KMP_D_LOCK_FUNC(user_lock, destroy)((kmp_dyna_lock_t *)user_lock);
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
|
@ -2014,17 +2014,17 @@ void
|
||||||
__kmpc_set_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
__kmpc_set_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
KMP_COUNT_BLOCK(OMP_set_lock);
|
KMP_COUNT_BLOCK(OMP_set_lock);
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
int tag = DYNA_EXTRACT_D_TAG(user_lock);
|
int tag = KMP_EXTRACT_D_TAG(user_lock);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock); // itt function will get to the right lock object.
|
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock); // itt function will get to the right lock object.
|
||||||
# endif
|
# endif
|
||||||
# if DYNA_USE_FAST_TAS
|
# if KMP_USE_FAST_TAS
|
||||||
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
||||||
DYNA_ACQUIRE_TAS_LOCK(user_lock, gtid);
|
KMP_ACQUIRE_TAS_LOCK(user_lock, gtid);
|
||||||
} else
|
} else
|
||||||
# elif DYNA_USE_FAST_FUTEX
|
# elif KMP_USE_FAST_FUTEX
|
||||||
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
||||||
DYNA_ACQUIRE_FUTEX_LOCK(user_lock, gtid);
|
KMP_ACQUIRE_FUTEX_LOCK(user_lock, gtid);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
|
@ -2079,7 +2079,7 @@ __kmpc_set_nest_lock( ident_t * loc, kmp_int32 gtid, void ** user_lock ) {
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
||||||
# endif
|
# endif
|
||||||
DYNA_D_LOCK_FUNC(user_lock, set)((kmp_dyna_lock_t *)user_lock, gtid);
|
KMP_D_LOCK_FUNC(user_lock, set)((kmp_dyna_lock_t *)user_lock, gtid);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_acquired((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_acquired((kmp_user_lock_p)user_lock);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2132,17 +2132,17 @@ __kmpc_unset_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
|
||||||
{
|
{
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
int tag = DYNA_EXTRACT_D_TAG(user_lock);
|
int tag = KMP_EXTRACT_D_TAG(user_lock);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_releasing((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_releasing((kmp_user_lock_p)user_lock);
|
||||||
# endif
|
# endif
|
||||||
# if DYNA_USE_FAST_TAS
|
# if KMP_USE_FAST_TAS
|
||||||
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
||||||
DYNA_RELEASE_TAS_LOCK(user_lock, gtid);
|
KMP_RELEASE_TAS_LOCK(user_lock, gtid);
|
||||||
} else
|
} else
|
||||||
# elif DYNA_USE_FAST_FUTEX
|
# elif KMP_USE_FAST_FUTEX
|
||||||
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
||||||
DYNA_RELEASE_FUTEX_LOCK(user_lock, gtid);
|
KMP_RELEASE_FUTEX_LOCK(user_lock, gtid);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
|
@ -2205,7 +2205,7 @@ __kmpc_unset_nest_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_releasing((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_releasing((kmp_user_lock_p)user_lock);
|
||||||
# endif
|
# endif
|
||||||
DYNA_D_LOCK_FUNC(user_lock, unset)((kmp_dyna_lock_t *)user_lock, gtid);
|
KMP_D_LOCK_FUNC(user_lock, unset)((kmp_dyna_lock_t *)user_lock, gtid);
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
|
@ -2272,17 +2272,17 @@ __kmpc_test_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
|
||||||
|
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
int rc;
|
int rc;
|
||||||
int tag = DYNA_EXTRACT_D_TAG(user_lock);
|
int tag = KMP_EXTRACT_D_TAG(user_lock);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
||||||
# endif
|
# endif
|
||||||
# if DYNA_USE_FAST_TAS
|
# if KMP_USE_FAST_TAS
|
||||||
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
if (tag == locktag_tas && !__kmp_env_consistency_check) {
|
||||||
DYNA_TEST_TAS_LOCK(user_lock, gtid, rc);
|
KMP_TEST_TAS_LOCK(user_lock, gtid, rc);
|
||||||
} else
|
} else
|
||||||
# elif DYNA_USE_FAST_FUTEX
|
# elif KMP_USE_FAST_FUTEX
|
||||||
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
if (tag == locktag_futex && !__kmp_env_consistency_check) {
|
||||||
DYNA_TEST_FUTEX_LOCK(user_lock, gtid, rc);
|
KMP_TEST_FUTEX_LOCK(user_lock, gtid, rc);
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
|
@ -2347,7 +2347,7 @@ __kmpc_test_nest_lock( ident_t *loc, kmp_int32 gtid, void **user_lock )
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_acquiring((kmp_user_lock_p)user_lock);
|
||||||
# endif
|
# endif
|
||||||
rc = DYNA_D_LOCK_FUNC(user_lock, test)((kmp_dyna_lock_t *)user_lock, gtid);
|
rc = KMP_D_LOCK_FUNC(user_lock, test)((kmp_dyna_lock_t *)user_lock, gtid);
|
||||||
# if USE_ITT_BUILD
|
# if USE_ITT_BUILD
|
||||||
if (rc) {
|
if (rc) {
|
||||||
__kmp_itt_lock_acquired((kmp_user_lock_p)user_lock);
|
__kmp_itt_lock_acquired((kmp_user_lock_p)user_lock);
|
||||||
|
@ -2427,23 +2427,23 @@ __kmp_enter_critical_section_reduce_block( ident_t * loc, kmp_int32 global_tid,
|
||||||
|
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
if (DYNA_IS_D_LOCK(__kmp_user_lock_seq)) {
|
if (KMP_IS_D_LOCK(__kmp_user_lock_seq)) {
|
||||||
lck = (kmp_user_lock_p)crit;
|
lck = (kmp_user_lock_p)crit;
|
||||||
if (*((kmp_dyna_lock_t *)lck) == 0) {
|
if (*((kmp_dyna_lock_t *)lck) == 0) {
|
||||||
KMP_COMPARE_AND_STORE_ACQ32((volatile kmp_int32 *)lck, 0, DYNA_GET_D_TAG(__kmp_user_lock_seq));
|
KMP_COMPARE_AND_STORE_ACQ32((volatile kmp_int32 *)lck, 0, KMP_GET_D_TAG(__kmp_user_lock_seq));
|
||||||
}
|
}
|
||||||
KMP_DEBUG_ASSERT(lck != NULL);
|
KMP_DEBUG_ASSERT(lck != NULL);
|
||||||
if (__kmp_env_consistency_check) {
|
if (__kmp_env_consistency_check) {
|
||||||
__kmp_push_sync(global_tid, ct_critical, loc, lck, __kmp_user_lock_seq);
|
__kmp_push_sync(global_tid, ct_critical, loc, lck, __kmp_user_lock_seq);
|
||||||
}
|
}
|
||||||
DYNA_D_LOCK_FUNC(lck, set)((kmp_dyna_lock_t *)lck, global_tid);
|
KMP_D_LOCK_FUNC(lck, set)((kmp_dyna_lock_t *)lck, global_tid);
|
||||||
} else {
|
} else {
|
||||||
kmp_indirect_lock_t *ilk = __kmp_get_indirect_csptr(crit, loc, global_tid, __kmp_user_lock_seq);
|
kmp_indirect_lock_t *ilk = __kmp_get_indirect_csptr(crit, loc, global_tid, __kmp_user_lock_seq);
|
||||||
KMP_DEBUG_ASSERT(ilk != NULL);
|
KMP_DEBUG_ASSERT(ilk != NULL);
|
||||||
if (__kmp_env_consistency_check) {
|
if (__kmp_env_consistency_check) {
|
||||||
__kmp_push_sync(global_tid, ct_critical, loc, ilk->lock, __kmp_user_lock_seq);
|
__kmp_push_sync(global_tid, ct_critical, loc, ilk->lock, __kmp_user_lock_seq);
|
||||||
}
|
}
|
||||||
DYNA_I_LOCK_FUNC(ilk, set)(ilk->lock, global_tid);
|
KMP_I_LOCK_FUNC(ilk, set)(ilk->lock, global_tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
@ -2475,16 +2475,16 @@ __kmp_end_critical_section_reduce_block( ident_t * loc, kmp_int32 global_tid, km
|
||||||
|
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
if (DYNA_IS_D_LOCK(__kmp_user_lock_seq)) {
|
if (KMP_IS_D_LOCK(__kmp_user_lock_seq)) {
|
||||||
lck = (kmp_user_lock_p)crit;
|
lck = (kmp_user_lock_p)crit;
|
||||||
if (__kmp_env_consistency_check)
|
if (__kmp_env_consistency_check)
|
||||||
__kmp_pop_sync(global_tid, ct_critical, loc);
|
__kmp_pop_sync(global_tid, ct_critical, loc);
|
||||||
DYNA_D_LOCK_FUNC(lck, unset)((kmp_dyna_lock_t *)lck, global_tid);
|
KMP_D_LOCK_FUNC(lck, unset)((kmp_dyna_lock_t *)lck, global_tid);
|
||||||
} else {
|
} else {
|
||||||
kmp_indirect_lock_t *ilk = (kmp_indirect_lock_t *)TCR_PTR(*((kmp_indirect_lock_t **)crit));
|
kmp_indirect_lock_t *ilk = (kmp_indirect_lock_t *)TCR_PTR(*((kmp_indirect_lock_t **)crit));
|
||||||
if (__kmp_env_consistency_check)
|
if (__kmp_env_consistency_check)
|
||||||
__kmp_pop_sync(global_tid, ct_critical, loc);
|
__kmp_pop_sync(global_tid, ct_critical, loc);
|
||||||
DYNA_I_LOCK_FUNC(ilk, unset)(ilk->lock, global_tid);
|
KMP_I_LOCK_FUNC(ilk, unset)(ilk->lock, global_tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
|
@ -798,8 +798,8 @@ __kmp_itt_lock_acquiring( kmp_user_lock_p lock ) {
|
||||||
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
||||||
// postpone lock object access
|
// postpone lock object access
|
||||||
if ( __itt_sync_prepare_ptr ) {
|
if ( __itt_sync_prepare_ptr ) {
|
||||||
if ( DYNA_EXTRACT_D_TAG(lock) == 0 ) {
|
if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__itt_sync_prepare( ilk->lock );
|
__itt_sync_prepare( ilk->lock );
|
||||||
} else {
|
} else {
|
||||||
__itt_sync_prepare( lock );
|
__itt_sync_prepare( lock );
|
||||||
|
@ -815,8 +815,8 @@ __kmp_itt_lock_acquired( kmp_user_lock_p lock ) {
|
||||||
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
||||||
// postpone lock object access
|
// postpone lock object access
|
||||||
if ( __itt_sync_acquired_ptr ) {
|
if ( __itt_sync_acquired_ptr ) {
|
||||||
if ( DYNA_EXTRACT_D_TAG(lock) == 0 ) {
|
if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__itt_sync_acquired( ilk->lock );
|
__itt_sync_acquired( ilk->lock );
|
||||||
} else {
|
} else {
|
||||||
__itt_sync_acquired( lock );
|
__itt_sync_acquired( lock );
|
||||||
|
@ -831,8 +831,8 @@ void
|
||||||
__kmp_itt_lock_releasing( kmp_user_lock_p lock ) {
|
__kmp_itt_lock_releasing( kmp_user_lock_p lock ) {
|
||||||
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
||||||
if ( __itt_sync_releasing_ptr ) {
|
if ( __itt_sync_releasing_ptr ) {
|
||||||
if ( DYNA_EXTRACT_D_TAG(lock) == 0 ) {
|
if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__itt_sync_releasing( ilk->lock );
|
__itt_sync_releasing( ilk->lock );
|
||||||
} else {
|
} else {
|
||||||
__itt_sync_releasing( lock );
|
__itt_sync_releasing( lock );
|
||||||
|
@ -847,8 +847,8 @@ void
|
||||||
__kmp_itt_lock_cancelled( kmp_user_lock_p lock ) {
|
__kmp_itt_lock_cancelled( kmp_user_lock_p lock ) {
|
||||||
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
#if KMP_USE_DYNAMIC_LOCK && USE_ITT_NOTIFY
|
||||||
if ( __itt_sync_cancel_ptr ) {
|
if ( __itt_sync_cancel_ptr ) {
|
||||||
if ( DYNA_EXTRACT_D_TAG(lock) == 0 ) {
|
if ( KMP_EXTRACT_D_TAG(lock) == 0 ) {
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__itt_sync_cancel( ilk->lock );
|
__itt_sync_cancel( ilk->lock );
|
||||||
} else {
|
} else {
|
||||||
__itt_sync_cancel( lock );
|
__itt_sync_cancel( lock );
|
||||||
|
|
|
@ -75,7 +75,7 @@ __kmp_validate_locks( void )
|
||||||
static kmp_int32
|
static kmp_int32
|
||||||
__kmp_get_tas_lock_owner( kmp_tas_lock_t *lck )
|
__kmp_get_tas_lock_owner( kmp_tas_lock_t *lck )
|
||||||
{
|
{
|
||||||
return DYNA_LOCK_STRIP(TCR_4( lck->lk.poll )) - 1;
|
return KMP_LOCK_STRIP(TCR_4( lck->lk.poll )) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -96,8 +96,8 @@ __kmp_acquire_tas_lock_timed_template( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
/* else __kmp_printf( "." );*/
|
/* else __kmp_printf( "." );*/
|
||||||
#endif /* USE_LOCK_PROFILE */
|
#endif /* USE_LOCK_PROFILE */
|
||||||
|
|
||||||
if ( ( lck->lk.poll == DYNA_LOCK_FREE(tas) )
|
if ( ( lck->lk.poll == KMP_LOCK_FREE(tas) )
|
||||||
&& KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas) ) ) {
|
&& KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas) ) ) {
|
||||||
KMP_FSYNC_ACQUIRED(lck);
|
KMP_FSYNC_ACQUIRED(lck);
|
||||||
return KMP_LOCK_ACQUIRED_FIRST;
|
return KMP_LOCK_ACQUIRED_FIRST;
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,8 @@ __kmp_acquire_tas_lock_timed_template( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
KMP_YIELD_SPIN( spins );
|
KMP_YIELD_SPIN( spins );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( ( lck->lk.poll != DYNA_LOCK_FREE(tas) ) ||
|
while ( ( lck->lk.poll != KMP_LOCK_FREE(tas) ) ||
|
||||||
( ! KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas) ) ) ) {
|
( ! KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas) ) ) ) {
|
||||||
//
|
//
|
||||||
// FIXME - use exponential backoff here
|
// FIXME - use exponential backoff here
|
||||||
//
|
//
|
||||||
|
@ -153,8 +153,8 @@ __kmp_acquire_tas_lock_with_checks( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
int
|
int
|
||||||
__kmp_test_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
__kmp_test_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
{
|
{
|
||||||
if ( ( lck->lk.poll == DYNA_LOCK_FREE(tas) )
|
if ( ( lck->lk.poll == KMP_LOCK_FREE(tas) )
|
||||||
&& KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), DYNA_LOCK_FREE(tas), DYNA_LOCK_BUSY(gtid+1, tas) ) ) {
|
&& KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(tas), KMP_LOCK_BUSY(gtid+1, tas) ) ) {
|
||||||
KMP_FSYNC_ACQUIRED( lck );
|
KMP_FSYNC_ACQUIRED( lck );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ __kmp_release_tas_lock( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
KMP_MB(); /* Flush all pending memory write invalidates. */
|
KMP_MB(); /* Flush all pending memory write invalidates. */
|
||||||
|
|
||||||
KMP_FSYNC_RELEASING(lck);
|
KMP_FSYNC_RELEASING(lck);
|
||||||
KMP_ST_REL32( &(lck->lk.poll), DYNA_LOCK_FREE(tas) );
|
KMP_ST_REL32( &(lck->lk.poll), KMP_LOCK_FREE(tas) );
|
||||||
KMP_MB(); /* Flush all pending memory write invalidates. */
|
KMP_MB(); /* Flush all pending memory write invalidates. */
|
||||||
|
|
||||||
KMP_YIELD( TCR_4( __kmp_nth ) > ( __kmp_avail_proc ? __kmp_avail_proc :
|
KMP_YIELD( TCR_4( __kmp_nth ) > ( __kmp_avail_proc ? __kmp_avail_proc :
|
||||||
|
@ -208,7 +208,7 @@ __kmp_release_tas_lock_with_checks( kmp_tas_lock_t *lck, kmp_int32 gtid )
|
||||||
void
|
void
|
||||||
__kmp_init_tas_lock( kmp_tas_lock_t * lck )
|
__kmp_init_tas_lock( kmp_tas_lock_t * lck )
|
||||||
{
|
{
|
||||||
TCW_4( lck->lk.poll, DYNA_LOCK_FREE(tas) );
|
TCW_4( lck->lk.poll, KMP_LOCK_FREE(tas) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -375,7 +375,7 @@ __kmp_destroy_nested_tas_lock_with_checks( kmp_tas_lock_t *lck )
|
||||||
static kmp_int32
|
static kmp_int32
|
||||||
__kmp_get_futex_lock_owner( kmp_futex_lock_t *lck )
|
__kmp_get_futex_lock_owner( kmp_futex_lock_t *lck )
|
||||||
{
|
{
|
||||||
return DYNA_LOCK_STRIP(( TCR_4( lck->lk.poll ) >> 1 )) - 1;
|
return KMP_LOCK_STRIP(( TCR_4( lck->lk.poll ) >> 1 )) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -404,10 +404,10 @@ __kmp_acquire_futex_lock_timed_template( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
|
|
||||||
kmp_int32 poll_val;
|
kmp_int32 poll_val;
|
||||||
|
|
||||||
while ( ( poll_val = KMP_COMPARE_AND_STORE_RET32( & ( lck->lk.poll ), DYNA_LOCK_FREE(futex),
|
while ( ( poll_val = KMP_COMPARE_AND_STORE_RET32( & ( lck->lk.poll ), KMP_LOCK_FREE(futex),
|
||||||
DYNA_LOCK_BUSY(gtid_code, futex) ) ) != DYNA_LOCK_FREE(futex) ) {
|
KMP_LOCK_BUSY(gtid_code, futex) ) ) != KMP_LOCK_FREE(futex) ) {
|
||||||
|
|
||||||
kmp_int32 cond = DYNA_LOCK_STRIP(poll_val) & 1;
|
kmp_int32 cond = KMP_LOCK_STRIP(poll_val) & 1;
|
||||||
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p, T#%d poll_val = 0x%x cond = 0x%x\n",
|
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p, T#%d poll_val = 0x%x cond = 0x%x\n",
|
||||||
lck, gtid, poll_val, cond ) );
|
lck, gtid, poll_val, cond ) );
|
||||||
|
|
||||||
|
@ -424,12 +424,12 @@ __kmp_acquire_futex_lock_timed_template( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
// Try to set the lsb in the poll to indicate to the owner
|
// Try to set the lsb in the poll to indicate to the owner
|
||||||
// thread that they need to wake this thread up.
|
// thread that they need to wake this thread up.
|
||||||
//
|
//
|
||||||
if ( ! KMP_COMPARE_AND_STORE_REL32( & ( lck->lk.poll ), poll_val, poll_val | DYNA_LOCK_BUSY(1, futex) ) ) {
|
if ( ! KMP_COMPARE_AND_STORE_REL32( & ( lck->lk.poll ), poll_val, poll_val | KMP_LOCK_BUSY(1, futex) ) ) {
|
||||||
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p(0x%x), T#%d can't set bit 0\n",
|
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p(0x%x), T#%d can't set bit 0\n",
|
||||||
lck, lck->lk.poll, gtid ) );
|
lck, lck->lk.poll, gtid ) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
poll_val |= DYNA_LOCK_BUSY(1, futex);
|
poll_val |= KMP_LOCK_BUSY(1, futex);
|
||||||
|
|
||||||
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p(0x%x), T#%d bit 0 set\n",
|
KA_TRACE( 1000, ("__kmp_acquire_futex_lock: lck:%p(0x%x), T#%d bit 0 set\n",
|
||||||
lck, lck->lk.poll, gtid ) );
|
lck, lck->lk.poll, gtid ) );
|
||||||
|
@ -486,7 +486,7 @@ __kmp_acquire_futex_lock_with_checks( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
int
|
int
|
||||||
__kmp_test_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
__kmp_test_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
{
|
{
|
||||||
if ( KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), DYNA_LOCK_FREE(futex), DYNA_LOCK_BUSY(gtid+1, futex) << 1 ) ) {
|
if ( KMP_COMPARE_AND_STORE_ACQ32( & ( lck->lk.poll ), KMP_LOCK_FREE(futex), KMP_LOCK_BUSY(gtid+1, futex) << 1 ) ) {
|
||||||
KMP_FSYNC_ACQUIRED( lck );
|
KMP_FSYNC_ACQUIRED( lck );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -514,15 +514,15 @@ __kmp_release_futex_lock( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
|
|
||||||
KMP_FSYNC_RELEASING(lck);
|
KMP_FSYNC_RELEASING(lck);
|
||||||
|
|
||||||
kmp_int32 poll_val = KMP_XCHG_FIXED32( & ( lck->lk.poll ), DYNA_LOCK_FREE(futex) );
|
kmp_int32 poll_val = KMP_XCHG_FIXED32( & ( lck->lk.poll ), KMP_LOCK_FREE(futex) );
|
||||||
|
|
||||||
KA_TRACE( 1000, ("__kmp_release_futex_lock: lck:%p, T#%d released poll_val = 0x%x\n",
|
KA_TRACE( 1000, ("__kmp_release_futex_lock: lck:%p, T#%d released poll_val = 0x%x\n",
|
||||||
lck, gtid, poll_val ) );
|
lck, gtid, poll_val ) );
|
||||||
|
|
||||||
if ( DYNA_LOCK_STRIP(poll_val) & 1 ) {
|
if ( KMP_LOCK_STRIP(poll_val) & 1 ) {
|
||||||
KA_TRACE( 1000, ("__kmp_release_futex_lock: lck:%p, T#%d futex_wake 1 thread\n",
|
KA_TRACE( 1000, ("__kmp_release_futex_lock: lck:%p, T#%d futex_wake 1 thread\n",
|
||||||
lck, gtid ) );
|
lck, gtid ) );
|
||||||
syscall( __NR_futex, & ( lck->lk.poll ), FUTEX_WAKE, DYNA_LOCK_BUSY(1, futex), NULL, NULL, 0 );
|
syscall( __NR_futex, & ( lck->lk.poll ), FUTEX_WAKE, KMP_LOCK_BUSY(1, futex), NULL, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
KMP_MB(); /* Flush all pending memory write invalidates. */
|
KMP_MB(); /* Flush all pending memory write invalidates. */
|
||||||
|
@ -557,7 +557,7 @@ __kmp_release_futex_lock_with_checks( kmp_futex_lock_t *lck, kmp_int32 gtid )
|
||||||
void
|
void
|
||||||
__kmp_init_futex_lock( kmp_futex_lock_t * lck )
|
__kmp_init_futex_lock( kmp_futex_lock_t * lck )
|
||||||
{
|
{
|
||||||
TCW_4( lck->lk.poll, DYNA_LOCK_FREE(futex) );
|
TCW_4( lck->lk.poll, KMP_LOCK_FREE(futex) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3019,13 +3019,13 @@ typedef enum kmp_lock_hint_t {
|
||||||
// Direct lock initializers. It simply writes a tag to the low 8 bits of the lock word.
|
// Direct lock initializers. It simply writes a tag to the low 8 bits of the lock word.
|
||||||
#define expand_init_lock(l, a) \
|
#define expand_init_lock(l, a) \
|
||||||
static void init_##l##_lock(kmp_dyna_lock_t *lck, kmp_dyna_lockseq_t seq) { \
|
static void init_##l##_lock(kmp_dyna_lock_t *lck, kmp_dyna_lockseq_t seq) { \
|
||||||
*lck = DYNA_LOCK_FREE(l); \
|
*lck = KMP_LOCK_FREE(l); \
|
||||||
KA_TRACE(20, ("Initialized direct lock, tag = %x\n", *lck)); \
|
KA_TRACE(20, ("Initialized direct lock, tag = %x\n", *lck)); \
|
||||||
}
|
}
|
||||||
FOREACH_D_LOCK(expand_init_lock, 0)
|
FOREACH_D_LOCK(expand_init_lock, 0)
|
||||||
#undef expand_init_lock
|
#undef expand_init_lock
|
||||||
|
|
||||||
#if DYNA_HAS_HLE
|
#if KMP_HAS_HLE
|
||||||
|
|
||||||
// HLE lock functions - imported from the testbed runtime.
|
// HLE lock functions - imported from the testbed runtime.
|
||||||
#if KMP_MIC
|
#if KMP_MIC
|
||||||
|
@ -3055,16 +3055,16 @@ __kmp_destroy_hle_lock(kmp_dyna_lock_t *lck)
|
||||||
static void
|
static void
|
||||||
__kmp_acquire_hle_lock(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
__kmp_acquire_hle_lock(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
// Use gtid for DYNA_LOCK_BUSY if necessary
|
// Use gtid for KMP_LOCK_BUSY if necessary
|
||||||
if (swap4(lck, DYNA_LOCK_BUSY(1, hle)) != DYNA_LOCK_FREE(hle)) {
|
if (swap4(lck, KMP_LOCK_BUSY(1, hle)) != KMP_LOCK_FREE(hle)) {
|
||||||
int delay = 1;
|
int delay = 1;
|
||||||
do {
|
do {
|
||||||
while (*(kmp_uint32 volatile *)lck != DYNA_LOCK_FREE(hle)) {
|
while (*(kmp_uint32 volatile *)lck != KMP_LOCK_FREE(hle)) {
|
||||||
for (int i = delay; i != 0; --i)
|
for (int i = delay; i != 0; --i)
|
||||||
machine_pause();
|
machine_pause();
|
||||||
delay = ((delay << 1) | 1) & 7;
|
delay = ((delay << 1) | 1) & 7;
|
||||||
}
|
}
|
||||||
} while (swap4(lck, DYNA_LOCK_BUSY(1, hle)) != DYNA_LOCK_FREE(hle));
|
} while (swap4(lck, KMP_LOCK_BUSY(1, hle)) != KMP_LOCK_FREE(hle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3079,7 +3079,7 @@ __kmp_release_hle_lock(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
__asm__ volatile(HLE_RELEASE "movl %1,%0"
|
__asm__ volatile(HLE_RELEASE "movl %1,%0"
|
||||||
: "=m"(*lck)
|
: "=m"(*lck)
|
||||||
: "r"(DYNA_LOCK_FREE(hle))
|
: "r"(KMP_LOCK_FREE(hle))
|
||||||
: "memory");
|
: "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3092,7 +3092,7 @@ __kmp_release_hle_lock_with_checks(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
||||||
static int
|
static int
|
||||||
__kmp_test_hle_lock(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
__kmp_test_hle_lock(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
return swap4(lck, DYNA_LOCK_BUSY(1, hle)) == DYNA_LOCK_FREE(hle);
|
return swap4(lck, KMP_LOCK_BUSY(1, hle)) == KMP_LOCK_FREE(hle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -3101,7 +3101,7 @@ __kmp_test_hle_lock_with_checks(kmp_dyna_lock_t *lck, kmp_int32 gtid)
|
||||||
return __kmp_test_hle_lock(lck, gtid); // TODO: add checks
|
return __kmp_test_hle_lock(lck, gtid); // TODO: add checks
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DYNA_HAS_HLE
|
#endif // KMP_HAS_HLE
|
||||||
|
|
||||||
// Entry functions for indirect locks (first element of direct_*_ops[]).
|
// Entry functions for indirect locks (first element of direct_*_ops[]).
|
||||||
static void __kmp_init_indirect_lock(kmp_dyna_lock_t * l, kmp_dyna_lockseq_t tag);
|
static void __kmp_init_indirect_lock(kmp_dyna_lock_t * l, kmp_dyna_lockseq_t tag);
|
||||||
|
@ -3128,16 +3128,16 @@ void (*__kmp_direct_destroy_ops[])(kmp_dyna_lock_t *)
|
||||||
// Differentiates *lock and *lock_with_checks.
|
// Differentiates *lock and *lock_with_checks.
|
||||||
#define expand_func2(l, op) 0,(void (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock,
|
#define expand_func2(l, op) 0,(void (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock,
|
||||||
#define expand_func2c(l, op) 0,(void (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
#define expand_func2c(l, op) 0,(void (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
||||||
static void (*direct_set_tab[][DYNA_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
static void (*direct_set_tab[][KMP_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
||||||
= { { __kmp_set_indirect_lock, 0, FOREACH_D_LOCK(expand_func2, acquire) },
|
= { { __kmp_set_indirect_lock, 0, FOREACH_D_LOCK(expand_func2, acquire) },
|
||||||
{ __kmp_set_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func2c, acquire) } };
|
{ __kmp_set_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func2c, acquire) } };
|
||||||
static void (*direct_unset_tab[][DYNA_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
static void (*direct_unset_tab[][KMP_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
||||||
= { { __kmp_unset_indirect_lock, 0, FOREACH_D_LOCK(expand_func2, release) },
|
= { { __kmp_unset_indirect_lock, 0, FOREACH_D_LOCK(expand_func2, release) },
|
||||||
{ __kmp_unset_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func2c, release) } };
|
{ __kmp_unset_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func2c, release) } };
|
||||||
|
|
||||||
#define expand_func3(l, op) 0,(int (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock,
|
#define expand_func3(l, op) 0,(int (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock,
|
||||||
#define expand_func3c(l, op) 0,(int (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
#define expand_func3c(l, op) 0,(int (*)(kmp_dyna_lock_t *, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
||||||
static int (*direct_test_tab[][DYNA_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
static int (*direct_test_tab[][KMP_NUM_D_LOCKS*2+2])(kmp_dyna_lock_t *, kmp_int32)
|
||||||
= { { __kmp_test_indirect_lock, 0, FOREACH_D_LOCK(expand_func3, test) },
|
= { { __kmp_test_indirect_lock, 0, FOREACH_D_LOCK(expand_func3, test) },
|
||||||
{ __kmp_test_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func3c, test) } };
|
{ __kmp_test_indirect_lock_with_checks, 0, FOREACH_D_LOCK(expand_func3c, test) } };
|
||||||
|
|
||||||
|
@ -3158,16 +3158,16 @@ void (*__kmp_indirect_destroy_ops[])(kmp_user_lock_p)
|
||||||
// Differentiates *lock and *lock_with_checks.
|
// Differentiates *lock and *lock_with_checks.
|
||||||
#define expand_func5(l, op) (void (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock,
|
#define expand_func5(l, op) (void (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock,
|
||||||
#define expand_func5c(l, op) (void (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
#define expand_func5c(l, op) (void (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
||||||
static void (*indirect_set_tab[][DYNA_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
static void (*indirect_set_tab[][KMP_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
||||||
= { { FOREACH_I_LOCK(expand_func5, acquire) },
|
= { { FOREACH_I_LOCK(expand_func5, acquire) },
|
||||||
{ FOREACH_I_LOCK(expand_func5c, acquire) } };
|
{ FOREACH_I_LOCK(expand_func5c, acquire) } };
|
||||||
static void (*indirect_unset_tab[][DYNA_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
static void (*indirect_unset_tab[][KMP_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
||||||
= { { FOREACH_I_LOCK(expand_func5, release) },
|
= { { FOREACH_I_LOCK(expand_func5, release) },
|
||||||
{ FOREACH_I_LOCK(expand_func5c, release) } };
|
{ FOREACH_I_LOCK(expand_func5c, release) } };
|
||||||
|
|
||||||
#define expand_func6(l, op) (int (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock,
|
#define expand_func6(l, op) (int (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock,
|
||||||
#define expand_func6c(l, op) (int (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
#define expand_func6c(l, op) (int (*)(kmp_user_lock_p, kmp_int32))__kmp_##op##_##l##_##lock_with_checks,
|
||||||
static int (*indirect_test_tab[][DYNA_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
static int (*indirect_test_tab[][KMP_NUM_I_LOCKS])(kmp_user_lock_p, kmp_int32)
|
||||||
= { { FOREACH_I_LOCK(expand_func6, test) },
|
= { { FOREACH_I_LOCK(expand_func6, test) },
|
||||||
{ FOREACH_I_LOCK(expand_func6c, test) } };
|
{ FOREACH_I_LOCK(expand_func6c, test) } };
|
||||||
|
|
||||||
|
@ -3182,14 +3182,14 @@ kmp_lock_index_t __kmp_indirect_lock_table_size;
|
||||||
kmp_lock_index_t __kmp_indirect_lock_table_next;
|
kmp_lock_index_t __kmp_indirect_lock_table_next;
|
||||||
|
|
||||||
// Size of indirect locks.
|
// Size of indirect locks.
|
||||||
static kmp_uint32 __kmp_indirect_lock_size[DYNA_NUM_I_LOCKS] = {
|
static kmp_uint32 __kmp_indirect_lock_size[KMP_NUM_I_LOCKS] = {
|
||||||
sizeof(kmp_ticket_lock_t), sizeof(kmp_queuing_lock_t),
|
sizeof(kmp_ticket_lock_t), sizeof(kmp_queuing_lock_t),
|
||||||
#if KMP_USE_ADAPTIVE_LOCKS
|
#if KMP_USE_ADAPTIVE_LOCKS
|
||||||
sizeof(kmp_adaptive_lock_t),
|
sizeof(kmp_adaptive_lock_t),
|
||||||
#endif
|
#endif
|
||||||
sizeof(kmp_drdpa_lock_t),
|
sizeof(kmp_drdpa_lock_t),
|
||||||
sizeof(kmp_tas_lock_t),
|
sizeof(kmp_tas_lock_t),
|
||||||
#if DYNA_HAS_FUTEX
|
#if KMP_HAS_FUTEX
|
||||||
sizeof(kmp_futex_lock_t),
|
sizeof(kmp_futex_lock_t),
|
||||||
#endif
|
#endif
|
||||||
sizeof(kmp_ticket_lock_t), sizeof(kmp_queuing_lock_t),
|
sizeof(kmp_ticket_lock_t), sizeof(kmp_queuing_lock_t),
|
||||||
|
@ -3197,13 +3197,13 @@ static kmp_uint32 __kmp_indirect_lock_size[DYNA_NUM_I_LOCKS] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Jump tables for lock accessor/modifier.
|
// Jump tables for lock accessor/modifier.
|
||||||
void (*__kmp_indirect_set_location[DYNA_NUM_I_LOCKS])(kmp_user_lock_p, const ident_t *) = { 0 };
|
void (*__kmp_indirect_set_location[KMP_NUM_I_LOCKS])(kmp_user_lock_p, const ident_t *) = { 0 };
|
||||||
void (*__kmp_indirect_set_flags[DYNA_NUM_I_LOCKS])(kmp_user_lock_p, kmp_lock_flags_t) = { 0 };
|
void (*__kmp_indirect_set_flags[KMP_NUM_I_LOCKS])(kmp_user_lock_p, kmp_lock_flags_t) = { 0 };
|
||||||
const ident_t * (*__kmp_indirect_get_location[DYNA_NUM_I_LOCKS])(kmp_user_lock_p) = { 0 };
|
const ident_t * (*__kmp_indirect_get_location[KMP_NUM_I_LOCKS])(kmp_user_lock_p) = { 0 };
|
||||||
kmp_lock_flags_t (*__kmp_indirect_get_flags[DYNA_NUM_I_LOCKS])(kmp_user_lock_p) = { 0 };
|
kmp_lock_flags_t (*__kmp_indirect_get_flags[KMP_NUM_I_LOCKS])(kmp_user_lock_p) = { 0 };
|
||||||
|
|
||||||
// Use different lock pools for different lock types.
|
// Use different lock pools for different lock types.
|
||||||
static kmp_indirect_lock_t * __kmp_indirect_lock_pool[DYNA_NUM_I_LOCKS] = { 0 };
|
static kmp_indirect_lock_t * __kmp_indirect_lock_pool[KMP_NUM_I_LOCKS] = { 0 };
|
||||||
|
|
||||||
// Inserts the given lock ptr to the lock table.
|
// Inserts the given lock ptr to the lock table.
|
||||||
kmp_lock_index_t
|
kmp_lock_index_t
|
||||||
|
@ -3271,7 +3271,7 @@ __kmp_lookup_indirect_lock(void **user_lock, const char *func)
|
||||||
KMP_FATAL(LockIsUninitialized, func);
|
KMP_FATAL(LockIsUninitialized, func);
|
||||||
}
|
}
|
||||||
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
||||||
kmp_lock_index_t idx = DYNA_EXTRACT_I_INDEX(user_lock);
|
kmp_lock_index_t idx = KMP_EXTRACT_I_INDEX(user_lock);
|
||||||
if (idx < 0 || idx >= __kmp_indirect_lock_table_size) {
|
if (idx < 0 || idx >= __kmp_indirect_lock_table_size) {
|
||||||
KMP_FATAL(LockIsUninitialized, func);
|
KMP_FATAL(LockIsUninitialized, func);
|
||||||
}
|
}
|
||||||
|
@ -3285,7 +3285,7 @@ __kmp_lookup_indirect_lock(void **user_lock, const char *func)
|
||||||
return lck;
|
return lck;
|
||||||
} else {
|
} else {
|
||||||
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
||||||
return __kmp_indirect_lock_table[DYNA_EXTRACT_I_INDEX(user_lock)];
|
return __kmp_indirect_lock_table[KMP_EXTRACT_I_INDEX(user_lock)];
|
||||||
} else {
|
} else {
|
||||||
return *((kmp_indirect_lock_t **)user_lock);
|
return *((kmp_indirect_lock_t **)user_lock);
|
||||||
}
|
}
|
||||||
|
@ -3301,9 +3301,9 @@ __kmp_init_indirect_lock(kmp_dyna_lock_t * lock, kmp_dyna_lockseq_t seq)
|
||||||
seq = lockseq_queuing;
|
seq = lockseq_queuing;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
kmp_indirect_locktag_t tag = DYNA_GET_I_TAG(seq);
|
kmp_indirect_locktag_t tag = KMP_GET_I_TAG(seq);
|
||||||
kmp_indirect_lock_t *l = __kmp_allocate_indirect_lock((void **)lock, __kmp_entry_gtid(), tag);
|
kmp_indirect_lock_t *l = __kmp_allocate_indirect_lock((void **)lock, __kmp_entry_gtid(), tag);
|
||||||
DYNA_I_LOCK_FUNC(l, init)(l->lock);
|
KMP_I_LOCK_FUNC(l, init)(l->lock);
|
||||||
KA_TRACE(20, ("__kmp_init_indirect_lock: initialized indirect lock, tag = %x\n", l->type));
|
KA_TRACE(20, ("__kmp_init_indirect_lock: initialized indirect lock, tag = %x\n", l->type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3312,7 +3312,7 @@ __kmp_destroy_indirect_lock(kmp_dyna_lock_t * lock)
|
||||||
{
|
{
|
||||||
kmp_uint32 gtid = __kmp_entry_gtid();
|
kmp_uint32 gtid = __kmp_entry_gtid();
|
||||||
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_destroy_lock");
|
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_destroy_lock");
|
||||||
DYNA_I_LOCK_FUNC(l, destroy)(l->lock);
|
KMP_I_LOCK_FUNC(l, destroy)(l->lock);
|
||||||
kmp_indirect_locktag_t tag = l->type;
|
kmp_indirect_locktag_t tag = l->type;
|
||||||
|
|
||||||
__kmp_acquire_lock(&__kmp_global_lock, gtid);
|
__kmp_acquire_lock(&__kmp_global_lock, gtid);
|
||||||
|
@ -3320,7 +3320,7 @@ __kmp_destroy_indirect_lock(kmp_dyna_lock_t * lock)
|
||||||
// Use the base lock's space to keep the pool chain.
|
// Use the base lock's space to keep the pool chain.
|
||||||
l->lock->pool.next = (kmp_user_lock_p)__kmp_indirect_lock_pool[tag];
|
l->lock->pool.next = (kmp_user_lock_p)__kmp_indirect_lock_pool[tag];
|
||||||
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
if (OMP_LOCK_T_SIZE < sizeof(void *)) {
|
||||||
l->lock->pool.index = DYNA_EXTRACT_I_INDEX(lock);
|
l->lock->pool.index = KMP_EXTRACT_I_INDEX(lock);
|
||||||
}
|
}
|
||||||
__kmp_indirect_lock_pool[tag] = l;
|
__kmp_indirect_lock_pool[tag] = l;
|
||||||
|
|
||||||
|
@ -3330,43 +3330,43 @@ __kmp_destroy_indirect_lock(kmp_dyna_lock_t * lock)
|
||||||
static void
|
static void
|
||||||
__kmp_set_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_set_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *l = KMP_LOOKUP_I_LOCK(lock);
|
||||||
DYNA_I_LOCK_FUNC(l, set)(l->lock, gtid);
|
KMP_I_LOCK_FUNC(l, set)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__kmp_unset_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_unset_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *l = KMP_LOOKUP_I_LOCK(lock);
|
||||||
DYNA_I_LOCK_FUNC(l, unset)(l->lock, gtid);
|
KMP_I_LOCK_FUNC(l, unset)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__kmp_test_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_test_indirect_lock(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *l = KMP_LOOKUP_I_LOCK(lock);
|
||||||
return DYNA_I_LOCK_FUNC(l, test)(l->lock, gtid);
|
return KMP_I_LOCK_FUNC(l, test)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__kmp_set_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_set_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_set_lock");
|
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_set_lock");
|
||||||
DYNA_I_LOCK_FUNC(l, set)(l->lock, gtid);
|
KMP_I_LOCK_FUNC(l, set)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
__kmp_unset_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_unset_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_unset_lock");
|
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_unset_lock");
|
||||||
DYNA_I_LOCK_FUNC(l, unset)(l->lock, gtid);
|
KMP_I_LOCK_FUNC(l, unset)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__kmp_test_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
__kmp_test_indirect_lock_with_checks(kmp_dyna_lock_t * lock, kmp_int32 gtid)
|
||||||
{
|
{
|
||||||
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_test_lock");
|
kmp_indirect_lock_t *l = __kmp_lookup_indirect_lock((void **)lock, "omp_test_lock");
|
||||||
return DYNA_I_LOCK_FUNC(l, test)(l->lock, gtid);
|
return KMP_I_LOCK_FUNC(l, test)(l->lock, gtid);
|
||||||
}
|
}
|
||||||
|
|
||||||
kmp_dyna_lockseq_t __kmp_user_lock_seq = lockseq_queuing;
|
kmp_dyna_lockseq_t __kmp_user_lock_seq = lockseq_queuing;
|
||||||
|
@ -3381,7 +3381,7 @@ __kmp_init_lock_hinted(void **lock, int hint)
|
||||||
seq = lockseq_tas;
|
seq = lockseq_tas;
|
||||||
break;
|
break;
|
||||||
case kmp_lock_hint_speculative:
|
case kmp_lock_hint_speculative:
|
||||||
#if DYNA_HAS_HLE
|
#if KMP_HAS_HLE
|
||||||
seq = lockseq_hle;
|
seq = lockseq_hle;
|
||||||
#else
|
#else
|
||||||
seq = lockseq_tas;
|
seq = lockseq_tas;
|
||||||
|
@ -3401,15 +3401,15 @@ __kmp_init_lock_hinted(void **lock, int hint)
|
||||||
seq = lockseq_queuing;
|
seq = lockseq_queuing;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DYNA_IS_D_LOCK(seq)) {
|
if (KMP_IS_D_LOCK(seq)) {
|
||||||
DYNA_INIT_D_LOCK(lock, seq);
|
KMP_INIT_D_LOCK(lock, seq);
|
||||||
#if USE_ITT_BUILD
|
#if USE_ITT_BUILD
|
||||||
__kmp_itt_lock_creating((kmp_user_lock_p)lock, NULL);
|
__kmp_itt_lock_creating((kmp_user_lock_p)lock, NULL);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
DYNA_INIT_I_LOCK(lock, seq);
|
KMP_INIT_I_LOCK(lock, seq);
|
||||||
#if USE_ITT_BUILD
|
#if USE_ITT_BUILD
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__kmp_itt_lock_creating(ilk->lock, NULL);
|
__kmp_itt_lock_creating(ilk->lock, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3423,7 +3423,7 @@ __kmp_get_user_lock_owner(kmp_user_lock_p lck, kmp_uint32 seq)
|
||||||
case lockseq_tas:
|
case lockseq_tas:
|
||||||
case lockseq_nested_tas:
|
case lockseq_nested_tas:
|
||||||
return __kmp_get_tas_lock_owner((kmp_tas_lock_t *)lck);
|
return __kmp_get_tas_lock_owner((kmp_tas_lock_t *)lck);
|
||||||
#if DYNA_HAS_FUTEX
|
#if KMP_HAS_FUTEX
|
||||||
case lockseq_futex:
|
case lockseq_futex:
|
||||||
case lockseq_nested_futex:
|
case lockseq_nested_futex:
|
||||||
return __kmp_get_futex_lock_owner((kmp_futex_lock_t *)lck);
|
return __kmp_get_futex_lock_owner((kmp_futex_lock_t *)lck);
|
||||||
|
@ -3462,9 +3462,9 @@ __kmp_init_nest_lock_hinted(void **lock, int hint)
|
||||||
seq = lockseq_nested_queuing;
|
seq = lockseq_nested_queuing;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DYNA_INIT_I_LOCK(lock, seq);
|
KMP_INIT_I_LOCK(lock, seq);
|
||||||
#if USE_ITT_BUILD
|
#if USE_ITT_BUILD
|
||||||
kmp_indirect_lock_t *ilk = DYNA_LOOKUP_I_LOCK(lock);
|
kmp_indirect_lock_t *ilk = KMP_LOOKUP_I_LOCK(lock);
|
||||||
__kmp_itt_lock_creating(ilk->lock, NULL);
|
__kmp_itt_lock_creating(ilk->lock, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3539,7 +3539,7 @@ __kmp_cleanup_indirect_user_locks()
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
// Clean up locks in the pools first (they were already destroyed before going into the pools).
|
// Clean up locks in the pools first (they were already destroyed before going into the pools).
|
||||||
for (k = 0; k < DYNA_NUM_I_LOCKS; ++k) {
|
for (k = 0; k < KMP_NUM_I_LOCKS; ++k) {
|
||||||
kmp_indirect_lock_t *l = __kmp_indirect_lock_pool[k];
|
kmp_indirect_lock_t *l = __kmp_indirect_lock_pool[k];
|
||||||
while (l != NULL) {
|
while (l != NULL) {
|
||||||
kmp_indirect_lock_t *ll = l;
|
kmp_indirect_lock_t *ll = l;
|
||||||
|
@ -3556,7 +3556,7 @@ __kmp_cleanup_indirect_user_locks()
|
||||||
kmp_indirect_lock_t *l = __kmp_indirect_lock_table[i];
|
kmp_indirect_lock_t *l = __kmp_indirect_lock_table[i];
|
||||||
if (l != NULL) {
|
if (l != NULL) {
|
||||||
// Locks not destroyed explicitly need to be destroyed here.
|
// Locks not destroyed explicitly need to be destroyed here.
|
||||||
DYNA_I_LOCK_FUNC(l, destroy)(l->lock);
|
KMP_I_LOCK_FUNC(l, destroy)(l->lock);
|
||||||
__kmp_free(l->lock);
|
__kmp_free(l->lock);
|
||||||
__kmp_free(l);
|
__kmp_free(l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1030,22 +1030,22 @@ extern void __kmp_cleanup_user_locks();
|
||||||
|
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
#define DYNA_HAS_FUTEX (KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM))
|
#define KMP_HAS_FUTEX (KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM))
|
||||||
#define DYNA_HAS_HLE (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_MIC)
|
#define KMP_HAS_HLE (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_MIC)
|
||||||
#define DYNA_USE_FAST_FUTEX 0 && DYNA_HAS_FUTEX
|
#define KMP_USE_FAST_FUTEX 0 && KMP_HAS_FUTEX
|
||||||
#define DYNA_USE_FAST_TAS 1 && DYNA_HAS_FUTEX
|
#define KMP_USE_FAST_TAS 1 && KMP_HAS_FUTEX
|
||||||
|
|
||||||
// List of lock definitions; all nested locks are indirect locks.
|
// List of lock definitions; all nested locks are indirect locks.
|
||||||
// hle lock is xchg lock prefixed with XACQUIRE/XRELEASE.
|
// hle lock is xchg lock prefixed with XACQUIRE/XRELEASE.
|
||||||
// All nested locks are indirect lock types.
|
// All nested locks are indirect lock types.
|
||||||
#if DYNA_HAS_FUTEX
|
#if KMP_HAS_FUTEX
|
||||||
# if DYNA_HAS_HLE
|
# if KMP_HAS_HLE
|
||||||
# define FOREACH_D_LOCK(m, a) m(tas, a) m(futex, a) m(hle, a)
|
# define FOREACH_D_LOCK(m, a) m(tas, a) m(futex, a) m(hle, a)
|
||||||
# define DYNA_LAST_D_LOCK_SEQ lockseq_hle
|
# define KMP_LAST_D_LOCK_SEQ lockseq_hle
|
||||||
# else
|
# else
|
||||||
# define FOREACH_D_LOCK(m, a) m(tas, a) m(futex, a)
|
# define FOREACH_D_LOCK(m, a) m(tas, a) m(futex, a)
|
||||||
# define DYNA_LAST_D_LOCK_SEQ lockseq_futex
|
# define KMP_LAST_D_LOCK_SEQ lockseq_futex
|
||||||
# endif // DYNA_HAS_HLE
|
# endif // KMP_HAS_HLE
|
||||||
# if KMP_USE_ADAPTIVE_LOCKS
|
# if KMP_USE_ADAPTIVE_LOCKS
|
||||||
# define FOREACH_I_LOCK(m, a) m(ticket, a) m(queuing, a) m(adaptive, a) m(drdpa, a) \
|
# define FOREACH_I_LOCK(m, a) m(ticket, a) m(queuing, a) m(adaptive, a) m(drdpa, a) \
|
||||||
m(nested_tas, a) m(nested_futex, a) m(nested_ticket, a) \
|
m(nested_tas, a) m(nested_futex, a) m(nested_ticket, a) \
|
||||||
|
@ -1056,13 +1056,13 @@ extern void __kmp_cleanup_user_locks();
|
||||||
m(nested_queuing, a) m(nested_drdpa, a)
|
m(nested_queuing, a) m(nested_drdpa, a)
|
||||||
# endif // KMP_USE_ADAPTIVE_LOCKS
|
# endif // KMP_USE_ADAPTIVE_LOCKS
|
||||||
#else
|
#else
|
||||||
# if DYNA_HAS_HLE
|
# if KMP_HAS_HLE
|
||||||
# define FOREACH_D_LOCK(m, a) m(tas, a) m(hle, a)
|
# define FOREACH_D_LOCK(m, a) m(tas, a) m(hle, a)
|
||||||
# define DYNA_LAST_D_LOCK_SEQ lockseq_hle
|
# define KMP_LAST_D_LOCK_SEQ lockseq_hle
|
||||||
# else
|
# else
|
||||||
# define FOREACH_D_LOCK(m, a) m(tas, a)
|
# define FOREACH_D_LOCK(m, a) m(tas, a)
|
||||||
# define DYNA_LAST_D_LOCK_SEQ lockseq_tas
|
# define KMP_LAST_D_LOCK_SEQ lockseq_tas
|
||||||
# endif // DYNA_HAS_HLE
|
# endif // KMP_HAS_HLE
|
||||||
# if KMP_USE_ADAPTIVE_LOCKS
|
# if KMP_USE_ADAPTIVE_LOCKS
|
||||||
# define FOREACH_I_LOCK(m, a) m(ticket, a) m(queuing, a) m(adaptive, a) m(drdpa, a) \
|
# define FOREACH_I_LOCK(m, a) m(ticket, a) m(queuing, a) m(adaptive, a) m(drdpa, a) \
|
||||||
m(nested_tas, a) m(nested_ticket, a) \
|
m(nested_tas, a) m(nested_ticket, a) \
|
||||||
|
@ -1072,13 +1072,13 @@ extern void __kmp_cleanup_user_locks();
|
||||||
m(nested_tas, a) m(nested_ticket, a) \
|
m(nested_tas, a) m(nested_ticket, a) \
|
||||||
m(nested_queuing, a) m(nested_drdpa, a)
|
m(nested_queuing, a) m(nested_drdpa, a)
|
||||||
# endif // KMP_USE_ADAPTIVE_LOCKS
|
# endif // KMP_USE_ADAPTIVE_LOCKS
|
||||||
#endif // DYNA_HAS_FUTEX
|
#endif // KMP_HAS_FUTEX
|
||||||
|
|
||||||
// Information used in dynamic dispatch
|
// Information used in dynamic dispatch
|
||||||
#define DYNA_LOCK_VALUE_SHIFT 8
|
#define KMP_LOCK_VALUE_SHIFT 8
|
||||||
#define DYNA_LOCK_TYPE_MASK ((1<<DYNA_LOCK_VALUE_SHIFT)-1)
|
#define KMP_LOCK_TYPE_MASK ((1<<KMP_LOCK_VALUE_SHIFT)-1)
|
||||||
#define DYNA_NUM_D_LOCKS DYNA_LAST_D_LOCK_SEQ
|
#define KMP_NUM_D_LOCKS KMP_LAST_D_LOCK_SEQ
|
||||||
#define DYNA_NUM_I_LOCKS (locktag_nested_drdpa+1)
|
#define KMP_NUM_I_LOCKS (locktag_nested_drdpa+1)
|
||||||
|
|
||||||
// Base type for dynamic locks.
|
// Base type for dynamic locks.
|
||||||
typedef kmp_uint32 kmp_dyna_lock_t;
|
typedef kmp_uint32 kmp_dyna_lock_t;
|
||||||
|
@ -1101,14 +1101,14 @@ typedef enum {
|
||||||
} kmp_indirect_locktag_t;
|
} kmp_indirect_locktag_t;
|
||||||
|
|
||||||
// Utility macros that extract information from lock sequences.
|
// Utility macros that extract information from lock sequences.
|
||||||
#define DYNA_IS_D_LOCK(seq) (seq >= lockseq_tas && seq <= DYNA_LAST_D_LOCK_SEQ)
|
#define KMP_IS_D_LOCK(seq) (seq >= lockseq_tas && seq <= KMP_LAST_D_LOCK_SEQ)
|
||||||
#define DYNA_IS_I_LOCK(seq) (seq >= lockseq_ticket && seq <= lockseq_nested_drdpa)
|
#define KMP_IS_I_LOCK(seq) (seq >= lockseq_ticket && seq <= lockseq_nested_drdpa)
|
||||||
#define DYNA_GET_I_TAG(seq) (kmp_indirect_locktag_t)(seq - lockseq_ticket)
|
#define KMP_GET_I_TAG(seq) (kmp_indirect_locktag_t)(seq - lockseq_ticket)
|
||||||
#define DYNA_GET_D_TAG(seq) (seq<<1 | 1)
|
#define KMP_GET_D_TAG(seq) (seq<<1 | 1)
|
||||||
|
|
||||||
// Enumerates direct lock tags starting from indirect tag.
|
// Enumerates direct lock tags starting from indirect tag.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#define expand_tag(l,a) locktag_##l = DYNA_GET_D_TAG(lockseq_##l),
|
#define expand_tag(l,a) locktag_##l = KMP_GET_D_TAG(lockseq_##l),
|
||||||
FOREACH_D_LOCK(expand_tag, 0)
|
FOREACH_D_LOCK(expand_tag, 0)
|
||||||
#undef expand_tag
|
#undef expand_tag
|
||||||
} kmp_direct_locktag_t;
|
} kmp_direct_locktag_t;
|
||||||
|
@ -1134,34 +1134,34 @@ extern void (*(*__kmp_indirect_unset_ops))(kmp_user_lock_p, kmp_int32);
|
||||||
extern int (*(*__kmp_indirect_test_ops))(kmp_user_lock_p, kmp_int32);
|
extern int (*(*__kmp_indirect_test_ops))(kmp_user_lock_p, kmp_int32);
|
||||||
|
|
||||||
// Extracts direct lock tag from a user lock pointer
|
// Extracts direct lock tag from a user lock pointer
|
||||||
#define DYNA_EXTRACT_D_TAG(l) (*((kmp_dyna_lock_t *)(l)) & DYNA_LOCK_TYPE_MASK & -(*((kmp_dyna_lock_t *)(l)) & 1))
|
#define KMP_EXTRACT_D_TAG(l) (*((kmp_dyna_lock_t *)(l)) & KMP_LOCK_TYPE_MASK & -(*((kmp_dyna_lock_t *)(l)) & 1))
|
||||||
|
|
||||||
// Extracts indirect lock index from a user lock pointer
|
// Extracts indirect lock index from a user lock pointer
|
||||||
#define DYNA_EXTRACT_I_INDEX(l) (*(kmp_lock_index_t *)(l) >> 1)
|
#define KMP_EXTRACT_I_INDEX(l) (*(kmp_lock_index_t *)(l) >> 1)
|
||||||
|
|
||||||
// Returns function pointer to the direct lock function with l (kmp_dyna_lock_t *) and op (operation type).
|
// Returns function pointer to the direct lock function with l (kmp_dyna_lock_t *) and op (operation type).
|
||||||
#define DYNA_D_LOCK_FUNC(l, op) __kmp_direct_##op##_ops[DYNA_EXTRACT_D_TAG(l)]
|
#define KMP_D_LOCK_FUNC(l, op) __kmp_direct_##op##_ops[KMP_EXTRACT_D_TAG(l)]
|
||||||
|
|
||||||
// Returns function pointer to the indirect lock function with l (kmp_indirect_lock_t *) and op (operation type).
|
// Returns function pointer to the indirect lock function with l (kmp_indirect_lock_t *) and op (operation type).
|
||||||
#define DYNA_I_LOCK_FUNC(l, op) __kmp_indirect_##op##_ops[((kmp_indirect_lock_t *)(l))->type]
|
#define KMP_I_LOCK_FUNC(l, op) __kmp_indirect_##op##_ops[((kmp_indirect_lock_t *)(l))->type]
|
||||||
|
|
||||||
// Initializes a direct lock with the given lock pointer and lock sequence.
|
// Initializes a direct lock with the given lock pointer and lock sequence.
|
||||||
#define DYNA_INIT_D_LOCK(l, seq) __kmp_direct_init_ops[DYNA_GET_D_TAG(seq)]((kmp_dyna_lock_t *)l, seq)
|
#define KMP_INIT_D_LOCK(l, seq) __kmp_direct_init_ops[KMP_GET_D_TAG(seq)]((kmp_dyna_lock_t *)l, seq)
|
||||||
|
|
||||||
// Initializes an indirect lock with the given lock pointer and lock sequence.
|
// Initializes an indirect lock with the given lock pointer and lock sequence.
|
||||||
#define DYNA_INIT_I_LOCK(l, seq) __kmp_direct_init_ops[0]((kmp_dyna_lock_t *)(l), seq)
|
#define KMP_INIT_I_LOCK(l, seq) __kmp_direct_init_ops[0]((kmp_dyna_lock_t *)(l), seq)
|
||||||
|
|
||||||
// Returns "free" lock value for the given lock type.
|
// Returns "free" lock value for the given lock type.
|
||||||
#define DYNA_LOCK_FREE(type) (locktag_##type)
|
#define KMP_LOCK_FREE(type) (locktag_##type)
|
||||||
|
|
||||||
// Returns "busy" lock value for the given lock teyp.
|
// Returns "busy" lock value for the given lock teyp.
|
||||||
#define DYNA_LOCK_BUSY(v, type) ((v)<<DYNA_LOCK_VALUE_SHIFT | locktag_##type)
|
#define KMP_LOCK_BUSY(v, type) ((v)<<KMP_LOCK_VALUE_SHIFT | locktag_##type)
|
||||||
|
|
||||||
// Returns lock value after removing (shifting) lock tag.
|
// Returns lock value after removing (shifting) lock tag.
|
||||||
#define DYNA_LOCK_STRIP(v) ((v)>>DYNA_LOCK_VALUE_SHIFT)
|
#define KMP_LOCK_STRIP(v) ((v)>>KMP_LOCK_VALUE_SHIFT)
|
||||||
|
|
||||||
// Updates __kmp_user_lock_seq with the give lock type.
|
// Updates __kmp_user_lock_seq with the give lock type.
|
||||||
#define DYNA_STORE_LOCK_SEQ(type) (__kmp_user_lock_seq = lockseq_##type)
|
#define KMP_STORE_LOCK_SEQ(type) (__kmp_user_lock_seq = lockseq_##type)
|
||||||
|
|
||||||
// Internal entries for hinted lock initializers.
|
// Internal entries for hinted lock initializers.
|
||||||
extern void __kmp_init_lock_hinted(void **, int);
|
extern void __kmp_init_lock_hinted(void **, int);
|
||||||
|
@ -1180,28 +1180,28 @@ extern void __kmp_cleanup_indirect_user_locks();
|
||||||
extern kmp_dyna_lockseq_t __kmp_user_lock_seq;
|
extern kmp_dyna_lockseq_t __kmp_user_lock_seq;
|
||||||
|
|
||||||
// Jump table for "set lock location", available only for indirect locks.
|
// Jump table for "set lock location", available only for indirect locks.
|
||||||
extern void (*__kmp_indirect_set_location[DYNA_NUM_I_LOCKS])(kmp_user_lock_p, const ident_t *);
|
extern void (*__kmp_indirect_set_location[KMP_NUM_I_LOCKS])(kmp_user_lock_p, const ident_t *);
|
||||||
#define DYNA_SET_I_LOCK_LOCATION(lck, loc) { \
|
#define KMP_SET_I_LOCK_LOCATION(lck, loc) { \
|
||||||
if (__kmp_indirect_set_location[(lck)->type] != NULL) \
|
if (__kmp_indirect_set_location[(lck)->type] != NULL) \
|
||||||
__kmp_indirect_set_location[(lck)->type]((lck)->lock, loc); \
|
__kmp_indirect_set_location[(lck)->type]((lck)->lock, loc); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump table for "set lock flags", available only for indirect locks.
|
// Jump table for "set lock flags", available only for indirect locks.
|
||||||
extern void (*__kmp_indirect_set_flags[DYNA_NUM_I_LOCKS])(kmp_user_lock_p, kmp_lock_flags_t);
|
extern void (*__kmp_indirect_set_flags[KMP_NUM_I_LOCKS])(kmp_user_lock_p, kmp_lock_flags_t);
|
||||||
#define DYNA_SET_I_LOCK_FLAGS(lck, flag) { \
|
#define KMP_SET_I_LOCK_FLAGS(lck, flag) { \
|
||||||
if (__kmp_indirect_set_flags[(lck)->type] != NULL) \
|
if (__kmp_indirect_set_flags[(lck)->type] != NULL) \
|
||||||
__kmp_indirect_set_flags[(lck)->type]((lck)->lock, flag); \
|
__kmp_indirect_set_flags[(lck)->type]((lck)->lock, flag); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump table for "get lock location", available only for indirect locks.
|
// Jump table for "get lock location", available only for indirect locks.
|
||||||
extern const ident_t * (*__kmp_indirect_get_location[DYNA_NUM_I_LOCKS])(kmp_user_lock_p);
|
extern const ident_t * (*__kmp_indirect_get_location[KMP_NUM_I_LOCKS])(kmp_user_lock_p);
|
||||||
#define DYNA_GET_I_LOCK_LOCATION(lck) ( __kmp_indirect_get_location[(lck)->type] != NULL \
|
#define KMP_GET_I_LOCK_LOCATION(lck) ( __kmp_indirect_get_location[(lck)->type] != NULL \
|
||||||
? __kmp_indirect_get_location[(lck)->type]((lck)->lock) \
|
? __kmp_indirect_get_location[(lck)->type]((lck)->lock) \
|
||||||
: NULL )
|
: NULL )
|
||||||
|
|
||||||
// Jump table for "get lock flags", available only for indirect locks.
|
// Jump table for "get lock flags", available only for indirect locks.
|
||||||
extern kmp_lock_flags_t (*__kmp_indirect_get_flags[DYNA_NUM_I_LOCKS])(kmp_user_lock_p);
|
extern kmp_lock_flags_t (*__kmp_indirect_get_flags[KMP_NUM_I_LOCKS])(kmp_user_lock_p);
|
||||||
#define DYNA_GET_I_LOCK_FLAGS(lck) ( __kmp_indirect_get_flags[(lck)->type] != NULL \
|
#define KMP_GET_I_LOCK_FLAGS(lck) ( __kmp_indirect_get_flags[(lck)->type] != NULL \
|
||||||
? __kmp_indirect_get_flags[(lck)->type]((lck)->lock) \
|
? __kmp_indirect_get_flags[(lck)->type]((lck)->lock) \
|
||||||
: NULL )
|
: NULL )
|
||||||
|
|
||||||
|
@ -1220,8 +1220,8 @@ extern kmp_lock_index_t __kmp_indirect_lock_table_next;
|
||||||
extern int __kmp_num_locks_in_block;
|
extern int __kmp_num_locks_in_block;
|
||||||
|
|
||||||
// Fast lock table lookup without consistency checking
|
// Fast lock table lookup without consistency checking
|
||||||
#define DYNA_LOOKUP_I_LOCK(l) ( (OMP_LOCK_T_SIZE < sizeof(void *)) \
|
#define KMP_LOOKUP_I_LOCK(l) ( (OMP_LOCK_T_SIZE < sizeof(void *)) \
|
||||||
? __kmp_indirect_lock_table[DYNA_EXTRACT_I_INDEX(l)] \
|
? __kmp_indirect_lock_table[KMP_EXTRACT_I_INDEX(l)] \
|
||||||
: *((kmp_indirect_lock_t **)l) )
|
: *((kmp_indirect_lock_t **)l) )
|
||||||
|
|
||||||
// Used once in kmp_error.c
|
// Used once in kmp_error.c
|
||||||
|
@ -1230,10 +1230,10 @@ __kmp_get_user_lock_owner(kmp_user_lock_p, kmp_uint32);
|
||||||
|
|
||||||
#else // KMP_USE_DYNAMIC_LOCK
|
#else // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
# define DYNA_LOCK_BUSY(v, type) (v)
|
# define KMP_LOCK_BUSY(v, type) (v)
|
||||||
# define DYNA_LOCK_FREE(type) 0
|
# define KMP_LOCK_FREE(type) 0
|
||||||
# define DYNA_LOCK_STRIP(v) (v)
|
# define KMP_LOCK_STRIP(v) (v)
|
||||||
# define DYNA_STORE_LOCK_SEQ(seq)
|
# define KMP_STORE_LOCK_SEQ(seq)
|
||||||
|
|
||||||
#endif // KMP_USE_DYNAMIC_LOCK
|
#endif // KMP_USE_DYNAMIC_LOCK
|
||||||
|
|
||||||
|
|
|
@ -3892,13 +3892,13 @@ __kmp_stg_parse_lock_kind( char const * name, char const * value, void * data )
|
||||||
|| __kmp_str_match( "testand-set", 2, value )
|
|| __kmp_str_match( "testand-set", 2, value )
|
||||||
|| __kmp_str_match( "testandset", 2, value ) ) {
|
|| __kmp_str_match( "testandset", 2, value ) ) {
|
||||||
__kmp_user_lock_kind = lk_tas;
|
__kmp_user_lock_kind = lk_tas;
|
||||||
DYNA_STORE_LOCK_SEQ(tas);
|
KMP_STORE_LOCK_SEQ(tas);
|
||||||
}
|
}
|
||||||
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
|
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)
|
||||||
else if ( __kmp_str_match( "futex", 1, value ) ) {
|
else if ( __kmp_str_match( "futex", 1, value ) ) {
|
||||||
if ( __kmp_futex_determine_capable() ) {
|
if ( __kmp_futex_determine_capable() ) {
|
||||||
__kmp_user_lock_kind = lk_futex;
|
__kmp_user_lock_kind = lk_futex;
|
||||||
DYNA_STORE_LOCK_SEQ(futex);
|
KMP_STORE_LOCK_SEQ(futex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KMP_WARNING( FutexNotSupported, name, value );
|
KMP_WARNING( FutexNotSupported, name, value );
|
||||||
|
@ -3907,12 +3907,12 @@ __kmp_stg_parse_lock_kind( char const * name, char const * value, void * data )
|
||||||
#endif
|
#endif
|
||||||
else if ( __kmp_str_match( "ticket", 2, value ) ) {
|
else if ( __kmp_str_match( "ticket", 2, value ) ) {
|
||||||
__kmp_user_lock_kind = lk_ticket;
|
__kmp_user_lock_kind = lk_ticket;
|
||||||
DYNA_STORE_LOCK_SEQ(ticket);
|
KMP_STORE_LOCK_SEQ(ticket);
|
||||||
}
|
}
|
||||||
else if ( __kmp_str_match( "queuing", 1, value )
|
else if ( __kmp_str_match( "queuing", 1, value )
|
||||||
|| __kmp_str_match( "queue", 1, value ) ) {
|
|| __kmp_str_match( "queue", 1, value ) ) {
|
||||||
__kmp_user_lock_kind = lk_queuing;
|
__kmp_user_lock_kind = lk_queuing;
|
||||||
DYNA_STORE_LOCK_SEQ(queuing);
|
KMP_STORE_LOCK_SEQ(queuing);
|
||||||
}
|
}
|
||||||
else if ( __kmp_str_match( "drdpa ticket", 1, value )
|
else if ( __kmp_str_match( "drdpa ticket", 1, value )
|
||||||
|| __kmp_str_match( "drdpa_ticket", 1, value )
|
|| __kmp_str_match( "drdpa_ticket", 1, value )
|
||||||
|
@ -3920,23 +3920,23 @@ __kmp_stg_parse_lock_kind( char const * name, char const * value, void * data )
|
||||||
|| __kmp_str_match( "drdpaticket", 1, value )
|
|| __kmp_str_match( "drdpaticket", 1, value )
|
||||||
|| __kmp_str_match( "drdpa", 1, value ) ) {
|
|| __kmp_str_match( "drdpa", 1, value ) ) {
|
||||||
__kmp_user_lock_kind = lk_drdpa;
|
__kmp_user_lock_kind = lk_drdpa;
|
||||||
DYNA_STORE_LOCK_SEQ(drdpa);
|
KMP_STORE_LOCK_SEQ(drdpa);
|
||||||
}
|
}
|
||||||
#if KMP_USE_ADAPTIVE_LOCKS
|
#if KMP_USE_ADAPTIVE_LOCKS
|
||||||
else if ( __kmp_str_match( "adaptive", 1, value ) ) {
|
else if ( __kmp_str_match( "adaptive", 1, value ) ) {
|
||||||
if( __kmp_cpuinfo.rtm ) { // ??? Is cpuinfo available here?
|
if( __kmp_cpuinfo.rtm ) { // ??? Is cpuinfo available here?
|
||||||
__kmp_user_lock_kind = lk_adaptive;
|
__kmp_user_lock_kind = lk_adaptive;
|
||||||
DYNA_STORE_LOCK_SEQ(adaptive);
|
KMP_STORE_LOCK_SEQ(adaptive);
|
||||||
} else {
|
} else {
|
||||||
KMP_WARNING( AdaptiveNotSupported, name, value );
|
KMP_WARNING( AdaptiveNotSupported, name, value );
|
||||||
__kmp_user_lock_kind = lk_queuing;
|
__kmp_user_lock_kind = lk_queuing;
|
||||||
DYNA_STORE_LOCK_SEQ(queuing);
|
KMP_STORE_LOCK_SEQ(queuing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // KMP_USE_ADAPTIVE_LOCKS
|
#endif // KMP_USE_ADAPTIVE_LOCKS
|
||||||
#if KMP_USE_DYNAMIC_LOCK
|
#if KMP_USE_DYNAMIC_LOCK
|
||||||
else if ( __kmp_str_match("hle", 1, value) ) {
|
else if ( __kmp_str_match("hle", 1, value) ) {
|
||||||
DYNA_STORE_LOCK_SEQ(hle);
|
KMP_STORE_LOCK_SEQ(hle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue