Skip to content

Commit c9fe19a

Browse files
author
Jonathan Peyton
authored
[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(); \ } ```
1 parent 8ba341e commit c9fe19a

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

openmp/runtime/src/kmp_lock.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -712,16 +712,9 @@ static int __kmp_test_ticket_lock_with_checks(kmp_ticket_lock_t *lck,
712712
}
713713

714714
int __kmp_release_ticket_lock(kmp_ticket_lock_t *lck, kmp_int32 gtid) {
715-
kmp_uint32 distance = std::atomic_load_explicit(&lck->lk.next_ticket,
716-
std::memory_order_relaxed) -
717-
std::atomic_load_explicit(&lck->lk.now_serving,
718-
std::memory_order_relaxed);
719-
720715
std::atomic_fetch_add_explicit(&lck->lk.now_serving, 1U,
721716
std::memory_order_release);
722717

723-
KMP_YIELD(distance >
724-
(kmp_uint32)(__kmp_avail_proc ? __kmp_avail_proc : __kmp_xproc));
725718
return KMP_LOCK_RELEASED;
726719
}
727720

0 commit comments

Comments
 (0)