Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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 Oct 12, 2026
021b19d
fix(hrr): test and document the dispatch slot load contract
andraghetti Oct 12, 2026
e9476b9
fix(hrr): wait for both slot values before the TSan stress loop
andraghetti Oct 12, 2026
3176370
docs(hrr): scope the dispatch table contract to HRR's writer
andraghetti Oct 12, 2026
15ec889
docs(hrr): scope the race-free table contract to HRR's writer
andraghetti Oct 12, 2026
d93435c
Merge branch 'develop' into users/andraghetti/hrr-dispatch-atomic-loads
andraghetti Oct 14, 2026
30b19d7
fix(hip): load the hipKernelSetAttributeForDevice slot atomically
andraghetti Oct 14, 2026
1f476af
test(hrr): let the dispatch-readers check see reads split across lines
andraghetti Oct 14, 2026
5e39361
Merge branch 'develop' into users/andraghetti/hrr-dispatch-atomic-loads
andraghetti Oct 14, 2026
e368ff1
Merge remote-tracking branch 'origin/develop' into users/andraghetti/…
andraghetti Oct 15, 2026
905ed7b
Merge remote-tracking branch 'origin/develop' into users/andraghetti/…
andraghetti Oct 19, 2026
550f8e4
test(hrr): require hip::LoadDispatchSlot in both entry-point macros
andraghetti Oct 19, 2026
bd99b45
test(hrr): build the TSan slot test from hip_dispatch_load.hpp alone
andraghetti Oct 19, 2026
43044f1
ci(hip): run the dispatch slot checks on CLR pull requests
andraghetti Oct 19, 2026
29df209
Merge develop 5b4535b7ba into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti Oct 20, 2026
1c39618
fix(hrr): skip the TSan slot test on Windows, run it under setarch -R
andraghetti Oct 20, 2026
7b3cc82
Merge develop 08c6e8f7c9 into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti Oct 21, 2026
bb5230e
refactor(hip): drop unreached checks and repeated text from the dispa…
andraghetti Oct 26, 2026
bbd4ef9
Merge develop 77796e3e36 into users/andraghetti/hrr-dispatch-atomic-l…
andraghetti Oct 26, 2026
81b7789
Merge remote-tracking branch 'origin/develop' into HEAD
andraghetti Oct 28, 2026
6f29507
docs(hip): name the slot store contract, not its location
andraghetti Nov 2, 2026
e938e13
Merge commit '6b8765e512' into HEAD
andraghetti Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions projects/clr/hipamd/src/hip_dispatch_load.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/

#pragma once

#include <type_traits>
#if defined(_WIN32)
#include <atomic>
#endif

namespace hip {

// Loads one function-pointer slot of a live HIP dispatch table.
//
// Tools such as HRR capture write slots of the live table while other threads call
// through it. Each write is a single release store of one aligned pointer (see
// install_shims in hrr/hip_capture.cpp). The HIP entry points in hip_table_interface.cpp
// read each slot with the matching acquire load, so a caller gets either the old function
// or the new one, and the new function sees everything its tool wrote before installing
// it. An acquire load of a pointer is a plain load on x86-64 and LDAR on AArch64.
template <typename Fn> inline Fn LoadDispatchSlot(const Fn& slot) {
static_assert(std::is_pointer_v<Fn> && sizeof(Fn) == sizeof(void*),
"dispatch slots are function pointers the size of void*");
#if defined(_WIN32)
// Same view as the Windows store in hrr/hip_capture.cpp.
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
Comment thread
andraghetti marked this conversation as resolved.
Resolved
}

} // namespace hip
Loading
Loading