[OpenMP] Improve performance of ticket lock (x86) (#143557)
Ticket lock has a yield operation (shown below) which degrades performance on larger server machines due to an unconditional pause operation. ``` #define KMP_YIELD(cond) \ { \ KMP_CPU_PAUSE(); \ if ((cond) && (KMP_TRY_YIELD)) \ __kmp_yield(); \ } ```
This commit is contained in:
parent
8ba341eec3
commit
c9fe19a99b
@ -712,16 +712,9 @@ static int __kmp_test_ticket_lock_with_checks(kmp_ticket_lock_t *lck,
|
||||
}
|
||||
|
||||
int __kmp_release_ticket_lock(kmp_ticket_lock_t *lck, kmp_int32 gtid) {
|
||||
kmp_uint32 distance = std::atomic_load_explicit(&lck->lk.next_ticket,
|
||||
std::memory_order_relaxed) -
|
||||
std::atomic_load_explicit(&lck->lk.now_serving,
|
||||
std::memory_order_relaxed);
|
||||
|
||||
std::atomic_fetch_add_explicit(&lck->lk.now_serving, 1U,
|
||||
std::memory_order_release);
|
||||
|
||||
KMP_YIELD(distance >
|
||||
(kmp_uint32)(__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc));
|
||||
return KMP_LOCK_RELEASED;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user