|
| 1 | +// Standalone test for lemon::normalize_rocm_family (src/cpp/include/lemon/rocm_arch.h). |
| 2 | +// |
| 3 | +// Guards the regression in #2319: identify_rocm_arch_from_name() must return the |
| 4 | +// ROCm *family* download target (gfx103X / gfx110X / gfx120X) for RDNA2/3/4 dGPUs, |
| 5 | +// not the specific arch (gfx1030 / gfx1100 / gfx1201). Commit 2a7aa18c (#2093) |
| 6 | +// removed ROCM_ARCH_MAPPING, so the gfx-regex and KFD numeric-ISA detection paths |
| 7 | +// began returning the specific arch, which no longer matched the support set and |
| 8 | +// made ROCm report "Unsupported GPU: gfx1100" for e.g. an RX 7900 XT. This header |
| 9 | +// restores the specific->family normalization those paths apply. |
| 10 | +// |
| 11 | +// Compile with: cl /std:c++17 /EHsc /I src/cpp/include test/cpp/test_rocm_arch.cpp |
| 12 | +// or: g++ -std=c++17 -I src/cpp/include test/cpp/test_rocm_arch.cpp -o rocm_arch_test |
| 13 | + |
| 14 | +#include "lemon/rocm_arch.h" |
| 15 | + |
| 16 | +#include <cstdio> |
| 17 | +#include <string> |
| 18 | + |
| 19 | +using lemon::normalize_rocm_family; |
| 20 | + |
| 21 | +static int g_failures = 0; |
| 22 | + |
| 23 | +static void expect(const char* name, const std::string& got, const std::string& want) { |
| 24 | + bool ok = (got == want); |
| 25 | + if (!ok) ++g_failures; |
| 26 | + std::printf("[%s] %s (got \"%s\", want \"%s\")\n", |
| 27 | + ok ? "PASS" : "FAIL", name, got.c_str(), want.c_str()); |
| 28 | +} |
| 29 | + |
| 30 | +int main() { |
| 31 | + std::printf("=== normalize_rocm_family tests ===\n"); |
| 32 | + |
| 33 | + // RDNA3 (gfx110X) — the #2319 reporter's family + the ai3 RX 7900 XT repro. |
| 34 | + expect("gfx1100 -> gfx110X", normalize_rocm_family("gfx1100"), "gfx110X"); |
| 35 | + expect("gfx1101 -> gfx110X", normalize_rocm_family("gfx1101"), "gfx110X"); |
| 36 | + expect("gfx1102 -> gfx110X", normalize_rocm_family("gfx1102"), "gfx110X"); |
| 37 | + expect("gfx1103 -> gfx110X", normalize_rocm_family("gfx1103"), "gfx110X"); |
| 38 | + |
| 39 | + // RDNA2 (gfx103X) — the full gfx1030-gfx1036 range, all mapped to the |
| 40 | + // gfx103X-all archive in backend_versions.json (#2319 review: gfx1033/1035/1036 |
| 41 | + // must NOT be dropped, a published bundle covers them). |
| 42 | + expect("gfx1030 -> gfx103X", normalize_rocm_family("gfx1030"), "gfx103X"); |
| 43 | + expect("gfx1031 -> gfx103X", normalize_rocm_family("gfx1031"), "gfx103X"); |
| 44 | + expect("gfx1032 -> gfx103X", normalize_rocm_family("gfx1032"), "gfx103X"); |
| 45 | + expect("gfx1033 -> gfx103X", normalize_rocm_family("gfx1033"), "gfx103X"); |
| 46 | + expect("gfx1034 -> gfx103X", normalize_rocm_family("gfx1034"), "gfx103X"); |
| 47 | + expect("gfx1035 -> gfx103X", normalize_rocm_family("gfx1035"), "gfx103X"); |
| 48 | + expect("gfx1036 -> gfx103X", normalize_rocm_family("gfx1036"), "gfx103X"); |
| 49 | + |
| 50 | + // RDNA4 (gfx120X). |
| 51 | + expect("gfx1200 -> gfx120X", normalize_rocm_family("gfx1200"), "gfx120X"); |
| 52 | + expect("gfx1201 -> gfx120X", normalize_rocm_family("gfx1201"), "gfx120X"); |
| 53 | + |
| 54 | + // iGPU exact targets pass through unchanged (ship as exact binaries). |
| 55 | + expect("gfx1150 unchanged", normalize_rocm_family("gfx1150"), "gfx1150"); |
| 56 | + expect("gfx1151 unchanged", normalize_rocm_family("gfx1151"), "gfx1151"); |
| 57 | + expect("gfx1152 unchanged", normalize_rocm_family("gfx1152"), "gfx1152"); |
| 58 | + |
| 59 | + // Idempotent on an already-collapsed family (the name-heuristic paths already |
| 60 | + // return families) and pass-through for unrelated / empty input. |
| 61 | + expect("gfx110X idempotent", normalize_rocm_family("gfx110X"), "gfx110X"); |
| 62 | + expect("gfx90a unchanged", normalize_rocm_family("gfx90a"), "gfx90a"); |
| 63 | + expect("empty unchanged", normalize_rocm_family(""), ""); |
| 64 | + |
| 65 | + std::printf("\n%s\n", g_failures == 0 ? "ALL PASS" : "FAILURES PRESENT"); |
| 66 | + return g_failures == 0 ? 0 : 1; |
| 67 | +} |
0 commit comments