Repository navigation
fix(hip): load dispatch table slots atomically in the entry points #13259
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
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
f399f10
fix(hip): load dispatch table slots atomically in the entry points
andraghetti 021b19d
fix(hrr): test and document the dispatch slot load contract
andraghetti e9476b9
fix(hrr): wait for both slot values before the TSan stress loop
andraghetti 3176370
docs(hrr): scope the dispatch table contract to HRR's writer
andraghetti 15ec889
docs(hrr): scope the race-free table contract to HRR's writer
andraghetti d93435c
Merge branch 'develop' into users/andraghetti/hrr-dispatch-atomic-loads
andraghetti 30b19d7
fix(hip): load the hipKernelSetAttributeForDevice slot atomically
andraghetti 1f476af
test(hrr): let the dispatch-readers check see reads split across lines
andraghetti 5e39361
Merge branch 'develop' into users/andraghetti/hrr-dispatch-atomic-loads
andraghetti e368ff1
Merge remote-tracking branch 'origin/develop' into users/andraghetti/…
andraghetti 905ed7b
Merge remote-tracking branch 'origin/develop' into users/andraghetti/…
andraghetti 550f8e4
test(hrr): require hip::LoadDispatchSlot in both entry-point macros
andraghetti bd99b45
test(hrr): build the TSan slot test from hip_dispatch_load.hpp alone
andraghetti 43044f1
ci(hip): run the dispatch slot checks on CLR pull requests
andraghetti 29df209
Merge develop 5b4535b7ba into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti 1c39618
fix(hrr): skip the TSan slot test on Windows, run it under setarch -R
andraghetti 7b3cc82
Merge develop 08c6e8f7c9 into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti bb5230e
refactor(hip): drop unreached checks and repeated text from the dispa…
andraghetti bbd4ef9
Merge develop 77796e3e36 into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti 81b7789
Merge remote-tracking branch 'origin/develop' into HEAD
andraghetti 6f29507
docs(hip): name the slot store contract, not its location
andraghetti e938e13
Merge commit '6b8765e512' into HEAD
andraghetti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # The dispatch slot load contract of projects/hrr/DESIGN.md, checked without a GPU or ROCm. | ||
|
|
||
| name: "HIP dispatch slot loads" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [develop] | ||
| paths: | ||
| - 'projects/clr/hipamd/src/hip_table_interface.cpp' | ||
| - 'projects/clr/hipamd/src/hip_dispatch_load.hpp' | ||
| - 'projects/hrr/tests/unit/check_dispatch_readers.cmake' | ||
| - 'projects/hrr/tests/unit/hrr_dispatch_load_tsan_test.cc' | ||
| - '.github/workflows/hip-dispatch-slot-loads.yml' | ||
| pull_request: | ||
| paths: | ||
| - 'projects/clr/hipamd/src/hip_table_interface.cpp' | ||
| - 'projects/clr/hipamd/src/hip_dispatch_load.hpp' | ||
| - 'projects/hrr/tests/unit/check_dispatch_readers.cmake' | ||
| - 'projects/hrr/tests/unit/hrr_dispatch_load_tsan_test.cc' | ||
| - '.github/workflows/hip-dispatch-slot-loads.yml' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| slot-loads: | ||
| name: "HIP dispatch slot loads" | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| sparse-checkout: | | ||
| projects/clr/hipamd/src | ||
| projects/hrr/tests/unit | ||
| persist-credentials: false | ||
|
|
||
| - name: Every entry point loads its slot through hip::LoadDispatchSlot | ||
| run: >- | ||
| cmake -DSOURCE=projects/clr/hipamd/src/hip_table_interface.cpp | ||
| -P projects/hrr/tests/unit/check_dispatch_readers.cmake | ||
|
|
||
| # setarch -R: GCC's TSan runtime aborts at startup under high-entropy ASLR. | ||
| - name: The load races HRR's slot store cleanly under ThreadSanitizer | ||
| run: | | ||
| set -euo pipefail | ||
| g++ -std=c++17 -O1 -g -pthread -fsanitize=thread \ | ||
| -I projects/clr/hipamd/src \ | ||
| projects/hrr/tests/unit/hrr_dispatch_load_tsan_test.cc -o hrr-unit-tests-tsan | ||
| setarch "$(uname -m)" -R ./hrr-unit-tests-tsan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #if defined(_WIN32) | ||
| #include <atomic> | ||
| #endif | ||
|
|
||
| namespace hip { | ||
|
|
||
| // Acquire load of one slot of a live HIP dispatch table, pairing with the release store | ||
| // HRR capture installs its shims with (projects/hrr/DESIGN.md, "Core Mechanism"). | ||
| template <typename Fn> inline Fn LoadDispatchSlot(const Fn& slot) { | ||
| #if defined(_WIN32) | ||
| // Same std::atomic_ref view as the contract's release store of a slot on Windows. | ||
| void*& raw = reinterpret_cast<void*&>(const_cast<Fn&>(slot)); | ||
| return reinterpret_cast<Fn>(std::atomic_ref<void*>(raw).load(std::memory_order_acquire)); | ||
| #else | ||
| return __atomic_load_n(&slot, __ATOMIC_ACQUIRE); | ||
| #endif | ||
| } | ||
|
|
||
| } // namespace hip | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.