Skip to content

[OpenMP] Improve performance of ticket lock (x86)#143557

Merged
hansangbae merged 2 commits into
llvm:mainfrom
jpeyton52:remove-yield-in-ticket-lock
Jul 21, 2025
Merged

[OpenMP] Improve performance of ticket lock (x86)#143557
hansangbae merged 2 commits into
llvm:mainfrom
jpeyton52:remove-yield-in-ticket-lock

Conversation

@jpeyton52

@jpeyton52 jpeyton52 commented Jun 10, 2025

Copy link
Copy Markdown

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();                                                           \
  }

Ticket lock has a yield operation which degrades performance on larger
server machines due to an unconditional pause operation.
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Jun 10, 2025
Comment thread openmp/runtime/src/kmp_lock.cpp
@TerryLWilmarth

Copy link
Copy Markdown
Contributor

ping. @hansangbae please review and complete this. Thanks!

@jprotze jprotze left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, having the KMP_YIELD macro in the commit message would make it easier to understand the actual problem when just looking at the diff of the patch. After checking the define the issue is clear and the patch LGTM.

#define KMP_YIELD(cond)                                                        \
  {                                                                            \
    KMP_CPU_PAUSE();                                                           \
    if ((cond) && (KMP_TRY_YIELD))                                             \
      __kmp_yield();                                                           \
  }

@hansangbae hansangbae merged commit c9fe19a into llvm:main Jul 21, 2025
7 checks passed
@hansangbae

Copy link
Copy Markdown
Contributor

Merged the change with the suggested commit message.
Thanks!

mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
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();                                                           \
  }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants