Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenMP][AIX] Affinity implementation for AIX #84984

Merged
merged 4 commits into from
Mar 22, 2024

Conversation

xingxue-ibm
Copy link
Contributor

This patch implements affinity for AIX, which is quite different from platforms such as Linux.

  • Setting CPU affinity through masks and related functions are not supported. System call bindprocessor() is used to bind a thread to one CPU per call.
  • There are no system routines to get the affinity info of a thread. The implementation of get_system_affinity() for AIX gets the mask of all available CPUs, to be used as the full mask only.
  • Topology is not available from the file system. It is obtained through system SRAD (Scheduler Resource Allocation Domain).

This patch has run through the libomp LIT tests successfully with affinity enabled.

@xingxue-ibm xingxue-ibm added the openmp:libomp OpenMP host runtime label Mar 12, 2024
@xingxue-ibm xingxue-ibm self-assigned this Mar 12, 2024
openmp/runtime/src/kmp_affinity.cpp Outdated Show resolved Hide resolved
openmp/runtime/src/kmp_affinity.cpp Show resolved Hide resolved
openmp/runtime/src/z_Linux_util.cpp Show resolved Hide resolved
@brad0
Copy link
Contributor

brad0 commented Mar 19, 2024

@xingxue-ibm Need to rebase this.

@xingxue-ibm
Copy link
Contributor Author

@xingxue-ibm Need to rebase this.

Done. Thanks for letting me know @brad0, appreciated!

openmp/runtime/src/kmp_affinity.h Show resolved Hide resolved
openmp/runtime/src/kmp_affinity.cpp Outdated Show resolved Hide resolved
* Update the comment of function __kmp_affinity_create_cpuinfo_map()
* Avoid compiler warning on unused argument abort_on_error of get_system_affinity
Copy link
Collaborator

@kkwli kkwli left a comment

Choose a reason for hiding this comment

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

LGTM

@xingxue-ibm xingxue-ibm merged commit d394f3a into llvm:main Mar 22, 2024
4 checks passed
chencha3 pushed a commit to chencha3/llvm-project that referenced this pull request Mar 23, 2024
This patch implements `affinity` for AIX, which is quite different from
platforms such as Linux.
- Setting CPU affinity through masks and related functions are not
supported. System call `bindprocessor()` is used to bind a thread to one
CPU per call.
- There are no system routines to get the affinity info of a thread. The
implementation of `get_system_affinity()` for AIX gets the mask of all
available CPUs, to be used as the full mask only.
- Topology is not available from the file system. It is obtained through
system SRAD (Scheduler Resource Allocation Domain).

This patch has run through the libomp LIT tests successfully with
`affinity` enabled.
@xingxue-ibm
Copy link
Contributor Author

Hi @brad0 @tstellar, We need to include this patch in the libomp of the next IBM OpenXL for AIX compiler deliverable which is built off LLVM v18. Can I request to cherry-pick this patch into release/18.x? Changes in this patch are guarded for AIX and should not affect other platforms. Thanks in advance!

@brad0
Copy link
Contributor

brad0 commented Mar 26, 2024

Hi @brad0 @tstellar, We need to include this patch in the libomp of the next IBM OpenXL for AIX compiler deliverable which is built off LLVM v18. Can I request to cherry-pick this patch into release/18.x? Changes in this patch are guarded for AIX and should not affect other platforms. Thanks in advance!

The patch would have to be rebased for the branch as it does not apply cleanly as is, but it is doable. You're right that it is limited to AIX specific changes and doesn't touch anything else. This would be up to the release manager @tstellar and @shiltian .

xingxue-ibm added a commit to xingxue-ibm/llvm-project that referenced this pull request Mar 26, 2024
This patch implements `affinity` for AIX, which is quite different from
platforms such as Linux.
- Setting CPU affinity through masks and related functions are not
supported. System call `bindprocessor()` is used to bind a thread to one
CPU per call.
- There are no system routines to get the affinity info of a thread. The
implementation of `get_system_affinity()` for AIX gets the mask of all
available CPUs, to be used as the full mask only.
- Topology is not available from the file system. It is obtained through
system SRAD (Scheduler Resource Allocation Domain).

This patch has run through the libomp LIT tests successfully with
`affinity` enabled.

(cherry picked from commit d394f3a)
@xingxue-ibm
Copy link
Contributor Author

Hi @brad0 @tstellar, We need to include this patch in the libomp of the next IBM OpenXL for AIX compiler deliverable which is built off LLVM v18. Can I request to cherry-pick this patch into release/18.x? Changes in this patch are guarded for AIX and should not affect other platforms. Thanks in advance!

The patch would have to be rebased for the branch as it does not apply cleanly as is, but it is doable. You're right that it is limited to AIX specific changes and doesn't touch anything else. This would be up to the release manager @tstellar and @shiltian .

Thanks, @brad0! I've rebased the patch on release/18.x and created PR 86695 for backporting.

xingxue-ibm added a commit to xingxue-ibm/llvm-project that referenced this pull request Mar 30, 2024
This patch implements `affinity` for AIX, which is quite different from
platforms such as Linux.
- Setting CPU affinity through masks and related functions are not
supported. System call `bindprocessor()` is used to bind a thread to one
CPU per call.
- There are no system routines to get the affinity info of a thread. The
implementation of `get_system_affinity()` for AIX gets the mask of all
available CPUs, to be used as the full mask only.
- Topology is not available from the file system. It is obtained through
system SRAD (Scheduler Resource Allocation Domain).

This patch has run through the libomp LIT tests successfully with
`affinity` enabled.

(cherry picked from commit d394f3a)
@pointhex pointhex mentioned this pull request May 7, 2024
@xingxue-ibm xingxue-ibm deleted the affinity branch May 24, 2024 21:17
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.

None yet

3 participants