Files
strata/src/core/arch_defaults_test.cpp
T
Niko1221 9708b549a4 gfx1151: the exact (bitwise) Aurora switches are on by default on gfx1151 only (arch_defaults), the rounding-level ones stay opt-in
16 switches whose output was byte-identical to the switch off on Aurora (GDN head / PP / CONVL2 / NOY / SPLIT, QFUSE,
CVEC_FUSE, HCD_EXACT, PF_PAD, Q8 / Q6 packed, MMVF_ROWS, ATTN_LANECELL, EXPERT_V2, TSUM, LFUSE, PLE_BATCH) are set at
start-up when device 0 is gfx1151 and the user has not set them; STRATA_GFX1151_DEFAULTS=0 turns the table off.  The
GDN head kernels are AMD-only now (HIP builds; CUDA keeps its key-head kernel), and verify.cpp's namespace-scope env
reads became lazy so the table reaches them.
2026-10-05 11:15:33 +02:00

61 lines
2.3 KiB
C++

// src/core/arch_defaults_test.cpp - the per-architecture default table (no GPU needed).
#include "strata/core/arch_defaults.hpp"
#include <cstdio>
#include <cstdlib>
#include <string>
static int fails = 0;
#define CHECK(c) do { if (!(c)) { std::printf("FAIL line %d: %s\n", __LINE__, #c); ++fails; } } while (0)
static void unset(const char* k) {
#if defined(_WIN32)
_putenv_s(k, "");
#else
unsetenv(k);
#endif
}
static void put(const char* k, const char* v) {
#if defined(_WIN32)
_putenv_s(k, v);
#else
setenv(k, v, 1);
#endif
}
int main() {
using namespace strata::core;
unset("STRATA_GFX1151_DEFAULTS");
// other architectures (and CUDA, which passes an empty name): nothing
CHECK(arch_default_env("gfx1100").empty());
CHECK(arch_default_env("gfx1201:sramecc-:xnack-").empty());
CHECK(arch_default_env("gfx1150").empty());
CHECK(arch_default_env("gfx11510").empty()); // not a prefix match
CHECK(arch_default_env("").empty());
CHECK(arch_default_env(nullptr).empty());
// gfx1151, plain and with its feature suffix: the table, and no bit-changing switch in it
for (const char* a : {"gfx1151", "gfx1151:sramecc-:xnack-"}) {
const auto t = arch_default_env(a);
CHECK(t.size() >= 10);
for (const auto& kv : t) {
CHECK(kv.first.rfind("STRATA_", 0) == 0);
for (const char* bits : {"STRATA_PF_GEMM", "STRATA_PF_FUSED", "STRATA_HC_UPMIX", "STRATA_PA_FAST", "STRATA_HIP_WMMA",
"STRATA_SELECT_WMMA", "STRATA_HC_Q8", "STRATA_PF_HCDOWN", "STRATA_WMMA_GEMM"})
CHECK(kv.first != bits);
}
}
// a user's setting wins, whatever it is; the rest are set
put("STRATA_TSUM", "0");
unset("STRATA_QFUSE");
const auto set = apply_arch_defaults("gfx1151");
CHECK(std::getenv("STRATA_TSUM") != nullptr && std::string(std::getenv("STRATA_TSUM")) == "0");
CHECK(std::getenv("STRATA_QFUSE") != nullptr && std::string(std::getenv("STRATA_QFUSE")) == "1");
for (const auto& n : set) CHECK(n != "STRATA_TSUM");
// the opt-out
put("STRATA_GFX1151_DEFAULTS", "0");
CHECK(arch_default_env("gfx1151").empty());
CHECK(apply_arch_defaults("gfx1151").empty());
std::printf(fails ? "arch_defaults_test: %d FAILED\n" : "arch_defaults_test: OK\n", fails);
return fails ? 1 : 0;
}