Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions projects/clr/hipamd/src/hrr/hip_capture_generated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7837,6 +7837,20 @@ static hipError_t capture_hipKernelSetAttributeForDevice(hipKernel_t kernel, hip
return r;
}

// Generated shim
static hipError_t capture_hipKernelSetCacheConfig(hipKernel_t kernel, hipFuncCache_t config, hipDevice_t dev) {
hipError_t r = g_real_table.hipKernelSetCacheConfig_fn(kernel, config, dev);
if (r == hipSuccess) {
hrr_args_hipKernelSetCacheConfig a{};
a.ret = static_cast<int32_t>(r);
a.kernel = reinterpret_cast<uint64_t>(kernel);
a.config = static_cast<decltype(a.config)>(config);
a.dev = static_cast<uint64_t>(static_cast<int>(dev));
hrr_cap::writer::write_event_raw(HRR_API_HIPKERNELSETCACHECONFIG, &a.hdr, sizeof(a));
}
return r;
}

// Generated shim
static hipError_t capture___hipPopCallConfiguration(dim3* gridDim, dim3* blockDim, size_t* sharedMem, hipStream_t* stream) {
hipError_t r = g_real_compiler_table.__hipPopCallConfiguration_fn(gridDim, blockDim, sharedMem, stream);
Expand Down Expand Up @@ -8575,6 +8589,7 @@ void hip_capture_build_table() {
g_cap_table.hipDeviceFlushGPUDirectRDMAWrites_fn = capture_hipDeviceFlushGPUDirectRDMAWrites;
g_cap_table.hipLibraryGetModule_fn = capture_hipLibraryGetModule;
g_cap_table.hipKernelSetAttributeForDevice_fn = capture_hipKernelSetAttributeForDevice;
g_cap_table.hipKernelSetCacheConfig_fn = capture_hipKernelSetCacheConfig;
}

void hip_capture_build_compiler_table() {
Expand Down
15 changes: 9 additions & 6 deletions projects/hrr/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ the parent that exited cleanly needs no repair. A sub-archive is skipped when
payloads, finds it complete in the sense `load_archive` uses. `--info` on a
root applies the same check before it shows a process as complete.

### Archive Format (v10)
### Archive Format (v11)
```
capture.hrr/
manifest.json { version, capture_mode, owner_pid, processes[] }
Expand Down Expand Up @@ -298,7 +298,7 @@ projects/hrr/ — standalone HRR project (portable layer)
Not used by capture — it is the format an
out-of-tree producer writes and playback reads
playback/
hrr_reader.h/.cpp — archive loader, v10 format; record framing
hrr_reader.h/.cpp — archive loader, v11 format; record framing
(read_raw_record / open_record_stream) shared
with the region sidecars
hrr_region_map.h/.cpp — region timeline: merge, cursor, live block set,
Expand Down Expand Up @@ -383,13 +383,13 @@ The generator classifies each API:
Generated capture shims for manual APIs are pass-throughs (no `write_event()`).
When adding HIP API support, update this script to classify the API in the appropriate capture and playback policy sets. APIs requiring non-trivial serialization or replay belong in `MANUAL_CAPTURE_APIS` and/or `MANUAL_PLAYBACK_APIS`; intentionally unsupported replay APIs belong in `NOOP_PLAYBACK_APIS`.

## Archive Format (v10)
## Archive Format (v11)

Single-authority definition in `hrr_api_args.h` (auto-generated):

```
HRR_MAGIC = 0x52524845 ("HRRE")
HRR_VERSION = 10
HRR_VERSION = 11
```

Version history, so an archive written by an older runtime can be placed:
Expand Down Expand Up @@ -429,12 +429,15 @@ Version history, so an archive written by an older runtime can be placed:
- **v10** puts pinned host snapshot records after a kernel launch's arguments
(`num_snapshots` was always 0). A v9 reader would not restore them. See
Pinned Host Snapshots below.
- **v11** records `hipKernelSetCacheConfig`, appended to
`HipDispatchTable`, which shifts the compiler API IDs up by one again. A v10
reader would decode those events as the wrong API.

```
<output_dir>/
manifest.json { version, capture_mode, owner_pid, processes[] }
(version here is the manifest schema = 1, distinct from the
events.bin HRR_VERSION = 10)
events.bin HRR_VERSION = 11)
pid-<pid>/
manifest.json { pid, parent_pid, complete, event_count, blob_count }
active one line naming the process instance (boot id and
Expand Down Expand Up @@ -1543,7 +1546,7 @@ The event wire format (finding H5):
shrinking `reserved` to 2 bytes), so kernel launches with large serialized payloads
(many args / long mangled names / large by-value structs) up to ~4 GiB are recorded
normally instead of being dropped at 65535 bytes. This is the change that bumped
`HRR_VERSION` to 4; the current version is 10, see Archive Format above. The
`HRR_VERSION` to 4; the current version is 11, see Archive Format above. The
writer's single-record buffer path now writes any oversized record straight through.
- **Per-argument size limit (64 KiB) now fails loudly.** Each kernel arg's size is still
a `uint16_t`. A by-value struct argument ≥ 64 KiB cannot be represented, so the launch
Expand Down
38 changes: 26 additions & 12 deletions projects/hrr/include/hrr/hrr_api_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@
* taking the first compiler ID and shifting the compiler API IDs up by one.
* A v8 reader would decode those events as the wrong API.
* v10: a kernel launch event carries pinned host snapshot records after its
* arguments (num_snapshots was always 0). A v9 reader would not restore them. */
#define HRR_VERSION ((uint16_t)10u)
* arguments (num_snapshots was always 0). A v9 reader would not restore them.
* v11: hipKernelSetCacheConfig was appended to HipDispatchTable, taking the
* first compiler ID and shifting the compiler API IDs up by one.
* A v10 reader would decode those events as the wrong API. */
#define HRR_VERSION ((uint16_t)11u)

/* Written once at byte 0 of events.bin. */
#pragma pack(push, 1)
Expand Down Expand Up @@ -5868,6 +5871,15 @@ typedef struct {
int32_t device;
} hrr_args_hipKernelSetAttributeForDevice;

/* hipError_t hipKernelSetCacheConfig(hipKernel_t kernel, hipFuncCache_t config, hipDevice_t dev) */
typedef struct {
hrr_event_header hdr;
int32_t ret;
uint64_t kernel;
int32_t config;
uint64_t dev;
} hrr_args_hipKernelSetCacheConfig;

/* ---- API id enumeration ---- */
typedef enum hrr_api_id {
HRR_API_HIPAPINAME = 0,
Expand Down Expand Up @@ -6418,16 +6430,17 @@ typedef enum hrr_api_id {
HRR_API_HIPDEVICEFLUSHGPUDIRECTRDMAWRITES = 545,
HRR_API_HIPLIBRARYGETMODULE = 546,
HRR_API_HIPKERNELSETATTRIBUTEFORDEVICE = 547,
HRR_API_HIPPOPCALLCONFIGURATION = 548,
HRR_API_HIPPUSHCALLCONFIGURATION = 549,
HRR_API_HIPREGISTERFATBINARY = 550,
HRR_API_HIPREGISTERFUNCTION = 551,
HRR_API_HIPREGISTERMANAGEDVAR = 552,
HRR_API_HIPREGISTERSURFACE = 553,
HRR_API_HIPREGISTERTEXTURE = 554,
HRR_API_HIPREGISTERVAR = 555,
HRR_API_HIPUNREGISTERFATBINARY = 556,
HRR_API_COUNT = 557
HRR_API_HIPKERNELSETCACHECONFIG = 548,
HRR_API_HIPPOPCALLCONFIGURATION = 549,
HRR_API_HIPPUSHCALLCONFIGURATION = 550,
HRR_API_HIPREGISTERFATBINARY = 551,
HRR_API_HIPREGISTERFUNCTION = 552,
HRR_API_HIPREGISTERMANAGEDVAR = 553,
HRR_API_HIPREGISTERSURFACE = 554,
HRR_API_HIPREGISTERTEXTURE = 555,
HRR_API_HIPREGISTERVAR = 556,
HRR_API_HIPUNREGISTERFATBINARY = 557,
HRR_API_COUNT = 558
} hrr_api_id_t;

/* Array of API names indexed by hrr_api_id_t */
Expand Down Expand Up @@ -6981,6 +6994,7 @@ const char* const hrr_api_names[HRR_API_COUNT] = {
"hipDeviceFlushGPUDirectRDMAWrites",
"hipLibraryGetModule",
"hipKernelSetAttributeForDevice",
"hipKernelSetCacheConfig",
"__hipPopCallConfiguration",
"__hipPushCallConfiguration",
"__hipRegisterFatBinary",
Expand Down
48 changes: 30 additions & 18 deletions projects/hrr/playback/hip_playback_generated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5490,6 +5490,16 @@ static hipError_t playback_hipKernelSetAttributeForDevice(PlaybackContext& ctx,
return hipSuccess;
}

static hipError_t playback_hipKernelSetCacheConfig(PlaybackContext& ctx, const uint8_t* payload) {
(void)ctx; (void)payload;
static std::atomic<bool> warned{false};
if (!warned.exchange(true)) {
fprintf(stderr, "[HRR] NOOP playback handler called for hipKernelSetCacheConfig — "
"this API is not replayed; results may differ from capture.\n");
}
return hipSuccess;
}

static hipError_t playback___hipPopCallConfiguration(PlaybackContext& ctx, const uint8_t* payload) {
(void)ctx; (void)payload;
return hipSuccess;
Expand Down Expand Up @@ -6084,15 +6094,16 @@ const uint32_t hrr_api_min_payload_size[HRR_API_COUNT] = {
static_cast<uint32_t>(sizeof(hrr_args_hipDeviceFlushGPUDirectRDMAWrites)), // [545] HRR_API_HIPDEVICEFLUSHGPUDIRECTRDMAWRITES
static_cast<uint32_t>(sizeof(hrr_args_hipLibraryGetModule)), // [546] HRR_API_HIPLIBRARYGETMODULE
static_cast<uint32_t>(sizeof(hrr_args_hipKernelSetAttributeForDevice)), // [547] HRR_API_HIPKERNELSETATTRIBUTEFORDEVICE
static_cast<uint32_t>(sizeof(hrr_args___hipPopCallConfiguration)), // [548] HRR_API_HIPPOPCALLCONFIGURATION
static_cast<uint32_t>(sizeof(hrr_args___hipPushCallConfiguration)), // [549] HRR_API_HIPPUSHCALLCONFIGURATION
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterFatBinary)), // [550] HRR_API_HIPREGISTERFATBINARY
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterFunction)), // [551] HRR_API_HIPREGISTERFUNCTION
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterManagedVar)), // [552] HRR_API_HIPREGISTERMANAGEDVAR
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterSurface)), // [553] HRR_API_HIPREGISTERSURFACE
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterTexture)), // [554] HRR_API_HIPREGISTERTEXTURE
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterVar)), // [555] HRR_API_HIPREGISTERVAR
static_cast<uint32_t>(sizeof(hrr_args___hipUnregisterFatBinary)), // [556] HRR_API_HIPUNREGISTERFATBINARY
static_cast<uint32_t>(sizeof(hrr_args_hipKernelSetCacheConfig)), // [548] HRR_API_HIPKERNELSETCACHECONFIG
static_cast<uint32_t>(sizeof(hrr_args___hipPopCallConfiguration)), // [549] HRR_API_HIPPOPCALLCONFIGURATION
static_cast<uint32_t>(sizeof(hrr_args___hipPushCallConfiguration)), // [550] HRR_API_HIPPUSHCALLCONFIGURATION
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterFatBinary)), // [551] HRR_API_HIPREGISTERFATBINARY
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterFunction)), // [552] HRR_API_HIPREGISTERFUNCTION
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterManagedVar)), // [553] HRR_API_HIPREGISTERMANAGEDVAR
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterSurface)), // [554] HRR_API_HIPREGISTERSURFACE
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterTexture)), // [555] HRR_API_HIPREGISTERTEXTURE
static_cast<uint32_t>(sizeof(hrr_args___hipRegisterVar)), // [556] HRR_API_HIPREGISTERVAR
static_cast<uint32_t>(sizeof(hrr_args___hipUnregisterFatBinary)), // [557] HRR_API_HIPUNREGISTERFATBINARY
};

// ============================================================
Expand Down Expand Up @@ -6647,13 +6658,14 @@ hrr_playback_fn_t hrr_playback_dispatch[HRR_API_COUNT] = {
playback_hipDeviceFlushGPUDirectRDMAWrites, // [545] HRR_API_HIPDEVICEFLUSHGPUDIRECTRDMAWRITES
playback_hipLibraryGetModule, // [546] HRR_API_HIPLIBRARYGETMODULE
playback_hipKernelSetAttributeForDevice, // [547] HRR_API_HIPKERNELSETATTRIBUTEFORDEVICE
playback___hipPopCallConfiguration, // [548] HRR_API_HIPPOPCALLCONFIGURATION
playback___hipPushCallConfiguration, // [549] HRR_API_HIPPUSHCALLCONFIGURATION
playback___hipRegisterFatBinary, // [550] HRR_API_HIPREGISTERFATBINARY
playback___hipRegisterFunction, // [551] HRR_API_HIPREGISTERFUNCTION
playback___hipRegisterManagedVar, // [552] HRR_API_HIPREGISTERMANAGEDVAR
playback___hipRegisterSurface, // [553] HRR_API_HIPREGISTERSURFACE
playback___hipRegisterTexture, // [554] HRR_API_HIPREGISTERTEXTURE
playback___hipRegisterVar, // [555] HRR_API_HIPREGISTERVAR
playback___hipUnregisterFatBinary, // [556] HRR_API_HIPUNREGISTERFATBINARY
playback_hipKernelSetCacheConfig, // [548] HRR_API_HIPKERNELSETCACHECONFIG
playback___hipPopCallConfiguration, // [549] HRR_API_HIPPOPCALLCONFIGURATION
playback___hipPushCallConfiguration, // [550] HRR_API_HIPPUSHCALLCONFIGURATION
playback___hipRegisterFatBinary, // [551] HRR_API_HIPREGISTERFATBINARY
playback___hipRegisterFunction, // [552] HRR_API_HIPREGISTERFUNCTION
playback___hipRegisterManagedVar, // [553] HRR_API_HIPREGISTERMANAGEDVAR
playback___hipRegisterSurface, // [554] HRR_API_HIPREGISTERSURFACE
playback___hipRegisterTexture, // [555] HRR_API_HIPREGISTERTEXTURE
playback___hipRegisterVar, // [556] HRR_API_HIPREGISTERVAR
playback___hipUnregisterFatBinary, // [557] HRR_API_HIPUNREGISTERFATBINARY
};
2 changes: 1 addition & 1 deletion projects/hrr/skills/enable-recording/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ What the archive holds, per process, and it is worth reading out to whoever has

Apart from the few exceptions in step 2, failed HIP calls are not recorded, and nothing that never crossed a HIP call is. The archive is exactly as sensitive as the data the workload handled, so where it may go has to be agreed before it is uploaded. [PRIVACY.md](../../PRIVACY.md) is the page to hand to whoever approves it.

`verify --json` gives each process's counts and sizes in a form you can attach to the request, and says whether any hardware identifier or code object build information is left (`hardware_ids`; `debug_info_files` for code objects still holding `.comment` or `.debug*` bytes; `path_files` for code objects whose loaded data holds an absolute path; `unchecked_fat_binaries` for the compressed ones it cannot read; `fat_binaries_scanned`, false when the archive's format version is not v8 to v10 and it cannot tell which blobs are fat binaries); the device details are in each `manifest.json`. For a multi-process archive, `hrr-playback --info` against the archive root prints a table covering every process at once. The cross-check in `verify` reports on one process, which is enough to judge the capture and not enough for a disclosure inventory.
`verify --json` gives each process's counts and sizes in a form you can attach to the request, and says whether any hardware identifier or code object build information is left (`hardware_ids`; `debug_info_files` for code objects still holding `.comment` or `.debug*` bytes; `path_files` for code objects whose loaded data holds an absolute path; `unchecked_fat_binaries` for the compressed ones it cannot read; `fat_binaries_scanned`, false when the archive's format version is not v8 to v11 and it cannot tell which blobs are fat binaries); the device details are in each `manifest.json`. For a multi-process archive, `hrr-playback --info` against the archive root prints a table covering every process at once. The cross-check in `verify` reports on one process, which is enough to judge the capture and not enough for a disclosure inventory.

If the content is the obstacle, three things exist and none of them is scrubbing. Re-capture the same failure driven by synthetic input, if it still reproduces. Replay the archive yourself and send only the finding, which is a few lines and carries no buffers. Or agree the handling of a production-data transfer before uploading, because that is what this is.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
# `blobs/` holds buffer contents as well as fat binaries, so the fat binaries
# are the blobs a `__hipRegisterFatBinary` record names: its hrr_api_id_t, and
# where the record keeps the hash after the event header and `uint64 ret`.
# The id is per archive format version (hrr_api_args.h): v8 put two compiler
# APIs ahead of it, v9 one more, and v10 left it where it was. A v7 archive may
# hold either numbering, so that and any other version leaves the fat binaries
# unscanned. tools/tests/test_skill_api_ids.py fails when HRR_VERSION moves
# past this table.
REGISTER_FAT_BINARY = {8: 549, 9: 550, 10: 550}
# The id is per archive format version (hrr_api_args.h): v8 put two runtime
# APIs ahead of it, v9 one more, v10 left it where it was and v11 one more. A v7
# archive may hold either numbering, so that and any other version leaves the
# fat binaries unscanned. tools/tests/test_skill_api_ids.py fails when
# HRR_VERSION moves past this table.
REGISTER_FAT_BINARY = {8: 549, 9: 550, 10: 550, 11: 551}
FAT_BINARY_HASH_OFFSET = EVENT_HEADER_BYTES + 8
HARDWARE_ID_FIELDS = ("pci", "uuid", "luid")
# Capture cannot zero what the GPU loads, so `verify` looks there for strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* what keeps the Catch2 tests and the matrix reporter from drifting into
* disagreeing about what an API is supposed to do at replay.
*
* Generated from 557 HIP APIs.
* Generated from 558 HIP APIs.
*/

#pragma once
Expand Down Expand Up @@ -394,6 +394,7 @@ inline constexpr HrrApiExpectation kHrrApiMatrix[] = {
{"hipKernelNameRefByPtr", "T4", 1, false, true, false, false},
{"hipKernelSetAttribute", "T4", 1, false, true, false, false},
{"hipKernelSetAttributeForDevice", "T4", 1, false, true, false, false},
{"hipKernelSetCacheConfig", "T4", 1, false, true, false, false},
{"hipLaunchCooperativeKernel_spt", "T4", 0, false, true, false, false},
{"hipLaunchHostFunc_spt", "T4", 5, false, true, false, false},
{"hipLaunchKernel_spt", "T4", 0, false, true, false, false},
Expand Down
10 changes: 5 additions & 5 deletions projects/hrr/tools/api-matrix/api_classes_baseline.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"capture_class.GENERATED": 500,
"capture_class.GENERATED": 501,
"capture_class.MANUAL": 56,
"capture_class.PASSTHROUGH_ONLY": 1,
"observable_class.ERROR_STUB": 4,
"observable_class.NOOP": 221,
"observable_class.NOOP": 222,
"observable_class.REAL": 320,
"observable_class.UNREPLAYABLE": 12,
"payload_loss.BIG_STRUCT_BY_VALUE": 8,
Expand All @@ -15,10 +15,10 @@
"replay_class.ERROR_STUB": 4,
"replay_class.GENERATED": 205,
"replay_class.MANUAL": 101,
"replay_class.NOOP": 221,
"replay_class.NOOP": 222,
"replay_class.SPECIAL": 6,
"replay_class.UNREPLAYABLE": 12,
"table.compiler": 9,
"table.runtime": 548,
"total": 557
"table.runtime": 549,
"total": 558
}
1 change: 1 addition & 0 deletions projects/hrr/tools/api-matrix/api_matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ unreachable:
- hipLibraryGetGlobal
- hipLibraryGetManaged
- hipKernelSetAttributeForDevice
- hipKernelSetCacheConfig
- hipOccupancyMaxActiveClusters
- hipOccupancyMaxPotentialClusterSize
- hipDeviceFlushGPUDirectRDMAWrites
Expand Down
7 changes: 5 additions & 2 deletions projects/hrr/tools/gen_hrr_api_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,8 +2061,11 @@ def validate_capture_coverage(entries: List[ApiEntry],
* taking the first compiler ID and shifting the compiler API IDs up by one.
* A v8 reader would decode those events as the wrong API.
* v10: a kernel launch event carries pinned host snapshot records after its
* arguments (num_snapshots was always 0). A v9 reader would not restore them. */
#define HRR_VERSION ((uint16_t)10u)
* arguments (num_snapshots was always 0). A v9 reader would not restore them.
* v11: hipKernelSetCacheConfig was appended to HipDispatchTable, taking the
* first compiler ID and shifting the compiler API IDs up by one.
* A v10 reader would decode those events as the wrong API. */
#define HRR_VERSION ((uint16_t)11u)

/* Written once at byte 0 of events.bin. */
#pragma pack(push, 1)
Expand Down
Loading