The RDNA4 offload campaign left three HIP probes and a driver sitting loose in $HOME, where the next agent cannot find them and a stray `rm -rf` ends them. They answer a recurring question on the R9700 box — is decode limited by the link or by the engine's read path — so they move into scripts/probes/ with a driver, tests, and a page. Two things changed in the code, not just the address: - The driver measures only after a guard that runs BEFORE anything is built: gpu_busy_percent over PCIE_PROBE_MAX_BUSY, or any process holding /dev/kfd, is a refusal (exit 3) rather than a measurement. A benchmark taken beside a live endpoint is both disruptive and worthless, and silently unloading a production service is not a tool's decision — --force is the human saying otherwise. The refusal-before-build ordering is pinned by a test, because the sysfs and kfd paths are overridable and a refusal is otherwise untestable off the card box. - hip_smoke.hip and pcie_probe.hip called hipGetDeviceProperties, which SEGFAULTS on this ROCm build even though hipGetDeviceCount works; only pcie_bw.hip avoided it, and that is the one that produced the campaign's numbers. Device identity now comes from the sysfs topology block the driver prints, so all three probes are runnable on the build we ship. Verified here: refusal on a real busy APU (exit 3), missing toolchain (exit 4), missing sources (exit 2). Compile-and-run still needs the box with hipcc. Refs #53
37 lines
1.6 KiB
Plaintext
37 lines
1.6 KiB
Plaintext
// Minimal HIP smoke test: is the host ROCm usable from a plain process?
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <hip/hip_runtime.h>
|
|
|
|
int main(void) {
|
|
int n = -1;
|
|
hipError_t e = hipGetDeviceCount(&n);
|
|
printf("hipGetDeviceCount -> %d (%s), count=%d\n",
|
|
(int)e, hipGetErrorString(e), n);
|
|
if (e != hipSuccess || n <= 0) return 1;
|
|
setvbuf(stdout, NULL, _IONBF, 0); /* an earlier crash lost the buffer, hiding the crash point */
|
|
// Device properties are deliberately NOT queried here: hipGetDeviceProperties segfaults on the
|
|
// ROCm build this probe was written for, even though hipGetDeviceCount above works fine. Card
|
|
// identity comes from sysfs anyway — scripts/pcie-probe.sh prints the link topology.
|
|
|
|
const size_t bytes = 2459136; /* 2.344 MiB: the engine's expert slab */
|
|
void *dev = NULL, *host = NULL;
|
|
if (hipMalloc(&dev, bytes) != hipSuccess) { printf("hipMalloc failed\n"); return 1; }
|
|
if (hipHostMalloc(&host, bytes, hipHostMallocDefault) != hipSuccess) {
|
|
printf("hipHostMalloc failed\n"); return 1;
|
|
}
|
|
memset(host, 0x5a, bytes);
|
|
|
|
hipEvent_t a, b; hipEventCreate(&a); hipEventCreate(&b);
|
|
hipDeviceSynchronize();
|
|
hipEventRecord(a, 0);
|
|
const int iters = 200;
|
|
for (int i = 0; i < iters; i++) hipMemcpy(dev, host, bytes, hipMemcpyHostToDevice);
|
|
hipEventRecord(b, 0); hipEventSynchronize(b);
|
|
float ms = 0; hipEventElapsedTime(&ms, a, b);
|
|
printf("\n %.3f MiB x %d iters in %.2f ms -> %.2f GB/s H2D (pinned)\n",
|
|
bytes/1048576.0, iters, ms, (double)bytes*iters/(ms/1000.0)/1e9);
|
|
printf(" Gen5 x8 ceiling = 31.5 GB/s\n");
|
|
return 0;
|
|
}
|