Skip to content
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a85f881
feat(hrr): record pointed-to payloads and replay the handler families
danielbolsson Aug 24, 2026
6aca419
hrr: skip playback of APIs amdhip.def.in does not export
danielbolsson Aug 27, 2026
58399d3
feat(hrr): refuse the calls replay cannot reproduce, by name
danielbolsson Aug 24, 2026
ea84489
Merge branch 'users/danielbolsson/hrr-api-matrix' into users/danielbo…
danielbolsson Sep 1, 2026
25601a7
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 1, 2026
815d0cb
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 1, 2026
74a6796
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 1, 2026
31f50ec
Merge branch 'users/danielbolsson/hrr-api-matrix' into users/danielbo…
danielbolsson Sep 1, 2026
25174df
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 1, 2026
7a3e7d2
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 2, 2026
21560a7
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 2, 2026
5deaf9f
Merge branch 'users/danielbolsson/hrr-api-matrix' into users/danielbo…
danielbolsson Sep 7, 2026
1961354
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 7, 2026
87ac47a
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 8, 2026
847eb16
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 8, 2026
f477844
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 8, 2026
12e3ba9
Merge commit 'f47784457c' into hrr/10642
danielbolsson Sep 8, 2026
a5ab390
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 9, 2026
0267701
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 9, 2026
2de8a4a
fix(hrr): drop the NOOP entry the migration merge revived
danielbolsson Sep 9, 2026
20afbdb
Merge branch 'fix/hrr-noop-overlap' into fix/hrr-scope-exclusions
danielbolsson Sep 9, 2026
1c0f91a
chore(hrr): reject an API that names two replay classification sets
danielbolsson Sep 9, 2026
70106f0
Merge branch 'fix/hrr-noop-overlap' into fix/hrr-scope-exclusions
danielbolsson Sep 9, 2026
43d431c
chore(hrr): include UNREPLAYABLE in the replay-class overlap check
danielbolsson Sep 9, 2026
8f12c04
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 9, 2026
7d7df0b
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 9, 2026
ce28ac2
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 9, 2026
3630ee7
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 9, 2026
ba17745
fix(hrr): stop replay dereferencing capture-process pointers
danielbolsson Sep 9, 2026
5a661a3
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 10, 2026
604fe2d
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 10, 2026
5316cb2
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 10, 2026
9de5afe
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 10, 2026
85baac2
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 14, 2026
563b31d
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 14, 2026
91e4c84
Merge branch 'users/danielbolsson/hrr-api-matrix' into users/danielbo…
danielbolsson Sep 15, 2026
c3b4ee3
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 15, 2026
711171a
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 16, 2026
8faaa7b
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 16, 2026
3a7a59e
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 16, 2026
affec6a
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 16, 2026
b19cc53
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 16, 2026
9d4b11a
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 16, 2026
b72164a
fix(hrr): route clr capture diagnostics through clr's logging macros
danielbolsson Sep 16, 2026
61cc566
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 16, 2026
42b28e8
fix(hrr): route the unreplayable-API notice through clr's logging
danielbolsson Sep 17, 2026
d57f269
feat(hrr): record argument truncation as unreplayable in the manifest
danielbolsson Sep 17, 2026
77d3010
fix(hrr): declare the log-level flags the generated capture file uses
danielbolsson Sep 17, 2026
caedcb8
fix(hrr): declare the log-level flags the generated capture file uses
danielbolsson Sep 17, 2026
5a8b8b2
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 17, 2026
f410585
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 17, 2026
4686de5
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 17, 2026
587ee56
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 17, 2026
2fc2c3f
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 17, 2026
b28fa16
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 17, 2026
284ae9f
fix(hrr): re-apply the archive-incomplete logging conversion
danielbolsson Sep 17, 2026
f7b5414
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 17, 2026
1171979
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-matr…
danielbolsson Sep 17, 2026
01e9238
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
danielbolsson Sep 17, 2026
d413593
Merge branch 'develop' into users/danielbolsson/hrr-api-payloads
danielbolsson Sep 21, 2026
40600d0
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 21, 2026
85d616d
Merge branch 'develop' into users/danielbolsson/hrr-api-payloads
danielbolsson Sep 22, 2026
4ebf70a
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 22, 2026
df73fb5
Merge remote-tracking branch 'origin/develop' into users/danielbolsso…
danielbolsson Sep 23, 2026
d791c6f
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 23, 2026
abc0168
fix(hrr): note unreplayable APIs only when their event is recorded
danielbolsson Sep 23, 2026
51bd73f
Merge branch 'users/danielbolsson/hrr-api-payloads' into users/daniel…
danielbolsson Sep 25, 2026
aea07be
Merge branch 'develop' into users/danielbolsson/hrr-api-payloads
danielbolsson Sep 25, 2026
1395ec9
fix(hrr): report every unreplayable reason, JSON-escape the manifest …
danielbolsson Sep 25, 2026
5ffcb0c
Merge remote-tracking branch 'origin/develop' into users/danielbolsso…
cursoragent Sep 25, 2026
9c16927
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
cursoragent Sep 25, 2026
3260c11
Merge remote-tracking branch 'origin/develop' into users/danielbolsso…
cursoragent Sep 28, 2026
59e827d
Merge remote-tracking branch 'origin/users/danielbolsson/hrr-api-payl…
cursoragent Sep 28, 2026
7039999
Merge remote-tracking branch 'origin/develop' into cascade2-payloads
danielbolsson Sep 28, 2026
23142be
Merge branch 'cascade2-payloads' into c2-scope
danielbolsson Sep 28, 2026
b1aea34
Merge branch 'develop' into users/danielbolsson/hrr-scope-exclusions
danielbolsson Sep 28, 2026
37a37e6
Merge remote-tracking branch 'origin/develop' into hrr-scope-exclusions
danielbolsson Sep 29, 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
27 changes: 27 additions & 0 deletions projects/clr/hipamd/src/hip_code_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,4 +708,31 @@ void StatCO::ForEachFatBinaryBlob(void (*cb)(const void*)) const {
cb(data);
}
}

// ================================================================================================
void StatCO::ForEachGlobalVar(void (*cb)(const void*, const char*, size_t,
const void*)) {
std::scoped_lock lock(sclock_);
// Resolved here rather than by the caller: this sweep runs from HRR's
// capture init, which is inside hip::init(), and re-entering the runtime
// through hipGetSymbolAddress from there deadlocks on the init once-flag.
// No device is current that early, and GetGlobalVar asserts rather than
// erroring on a negative device id, so the address is reported as
// unresolved instead.
// No device is current this early in init, and GetGlobalVar asserts rather
// than erroring on a negative id, so fall back to device 0 — which is the
// device a recording resolves its globals on anyway.
int device_id = ihipGetDevice();
if (device_id < 0) device_id = 0;
const bool resolvable = static_cast<size_t>(device_id) < g_devices.size();
for (const auto& [host_var, var] : vars_) {
if (var == nullptr) continue;
hipDeviceptr_t dev_ptr = nullptr;
size_t sym_size = 0;
if (resolvable &&
GetGlobalVar(host_var, device_id, &dev_ptr, &sym_size) != hipSuccess)
dev_ptr = nullptr;
cb(host_var, var->GetName().c_str(), var->GetSize(), dev_ptr);
}
}
} // namespace hip
6 changes: 6 additions & 0 deletions projects/clr/hipamd/src/hip_code_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ class StatCO : public CodeObject {
// Iterate all registered fat binary data pointers — for HRR capture post-registration sweep.
void ForEachFatBinaryBlob(void (*cb)(const void*)) const;

// Iterate all registered __device__ globals as (host shadow address, symbol
// name, size, device address) — the same post-registration sweep for HRR,
// which otherwise never sees __hipRegisterVar because it fires at
// static-init time. The device address is null if it cannot be resolved yet.
void ForEachGlobalVar(void (*cb)(const void*, const char*, size_t, const void*));

private:
mutable std::recursive_mutex sclock_; //!< Guards Static Code object
const PlatformState& owner_; //!< Reference to owning PlatformState
Expand Down
700 changes: 696 additions & 4 deletions projects/clr/hipamd/src/hrr/hip_capture.cpp

Large diffs are not rendered by default.

1,211 changes: 850 additions & 361 deletions projects/clr/hipamd/src/hrr/hip_capture_generated.cpp

Large diffs are not rendered by default.

50 changes: 43 additions & 7 deletions projects/clr/hipamd/src/hrr/hip_capture_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <cerrno>
#include <filesystem>
#include <mutex>
#include <set>
#include <string>
#include <unordered_set>
#include <algorithm>
Expand Down Expand Up @@ -216,6 +217,12 @@ static std::atomic<uint64_t> g_blob_count{0};
static std::mutex g_blob_mu;
static std::unordered_set<std::string> g_written_blobs;

// APIs recorded in this archive that replay cannot reproduce (note_unreplayable).
// Listed in manifest.json so the gap is a property of the archive rather than
// something only visible in a replay log.
static std::mutex g_unreplayable_mu;
static std::set<std::string> g_unreplayable_apis;

// ---------------------------------------------------------------------------
// Low-level fd helpers
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -499,6 +506,18 @@ static void write_manifest_stdio(const char* output_dir, bool complete) {
complete ? "true" : "false",
static_cast<unsigned long long>(g_event_count.load()),
static_cast<unsigned long long>(g_blob_count.load()));
{
std::lock_guard<std::mutex> lk(g_unreplayable_mu);
if (!g_unreplayable_apis.empty()) {
fprintf(mf, ",\n \"unreplayable_apis\": [");
bool first = true;
for (const auto& api : g_unreplayable_apis) {
fprintf(mf, "%s\"%s\"", first ? "" : ", ", api.c_str());
first = false;
}
fprintf(mf, "]");
}
}
Comment thread
danielbolsson marked this conversation as resolved.
Resolved
if (g_metadata_json_len > 0) {
fprintf(mf, ",\n \"metadata\": %.*s\n",
static_cast<int>(g_metadata_json_len), g_metadata_json);
Expand Down Expand Up @@ -737,19 +756,36 @@ void checkpoint() {
void mark_incomplete(const char* reason) {
// Record once; the loud, AMD_LOG_LEVEL-routed message is emitted by the caller
// (e.g. serialize_kernel_launch) which has the relevant context. Here we only
// need the durable flag and a single stderr breadcrumb so a bare run still
// surfaces it.
// need the durable flag and a single breadcrumb so a bare run still surfaces
// it. Error level: the archive is not faithful and replay must not treat it
// as one. log_printf appends its own newline, so the format string omits it.
if (!g_capture_incomplete.exchange(true, std::memory_order_relaxed)) {
fprintf(stderr,
"[HRR capture] Archive marked INCOMPLETE: %s. The clean-shutdown "
"trailer will be omitted and manifest.complete=false so replay "
"cannot treat this capture as faithful.\n",
reason ? reason : "(unspecified)");
LogPrintfError(
"[HRR capture] Archive marked INCOMPLETE: %s. The clean-shutdown "
"trailer will be omitted and manifest.complete=false so replay "
"cannot treat this capture as faithful",
reason ? reason : "(unspecified)");
}
}

bool is_incomplete() { return g_capture_incomplete.load(std::memory_order_relaxed); }

void note_unreplayable(const char* api, const char* reason) {
if (!api) return;
{
std::lock_guard<std::mutex> lk(g_unreplayable_mu);
if (!g_unreplayable_apis.insert(api).second) return;
}
// Warning, not Error: unlike mark_incomplete() the archive is well-formed and
// every event is present — only the ability to re-execute this one call is
// lost. That is a degradation, not a failure.
// log_printf appends its own newline, so the format string omits it.
LogPrintfWarning(
"[HRR capture] %s cannot be replayed: %s. The call is recorded, but "
"replay will report it as unreplayable rather than reproduce it",
api, reason ? reason : "(unspecified)");
}
Comment thread
danielbolsson marked this conversation as resolved.
Resolved

void flush(const char* /*output_dir*/) {
// Always finalize the *effective* directory this process actually wrote to
// (g_output_dir), which is always a pid-<pid> sub-archive. The caller passes
Expand Down
14 changes: 14 additions & 0 deletions projects/clr/hipamd/src/hrr/hip_capture_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ void mark_incomplete(const char* reason);
// Returns true if mark_incomplete() has been called.
bool is_incomplete();

// Record that `api` was captured but cannot be replayed faithfully — the call
// is in the archive, its effect is not reproducible (a host callback belonging
// to this process, a handle only meaningful to another rank, ...). Warns once
// per API at capture time, so the gap is visible when the recording is made
// rather than only when someone tries to replay it, and lists the API under
// "unreplayable_apis" in manifest.json.
//
// Deliberately NOT mark_incomplete(): that means an event was dropped or torn
// and suppresses the clean-shutdown trailer. Here every event is present and
// the archive is well-formed; what is missing is the ability to re-execute
// this particular call. Thread-safe; the warning fires once per API per
// process.
void note_unreplayable(const char* api, const char* reason);

// Write a buffer as a content-addressed blob. Returns hash.
// Thread-safe. Skips write if blob already exists on disk.
Hash128 write_blob(const void* data, size_t len);
Expand Down
Loading
Loading