okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-0291-split-hip e3563ff3d: AMD split final candidate (batched draft layer, RCCL sums, strata-split-2/3/4-amd)95901fe8a

main
3.2 KiB46 linesraw
1// The kernel self-test rules (src/hip/selftest_policy.hpp): gfx1201 (run) goes without a word and without the test; any other architecture prints one experimental line with the
2// report link, runs the test, and says so when it passed; a failed (or forced-failed) test stops the engine with one plain line that the server turns into the layer split. CPU only.
3#include <cstdio>
4#include <string>
5
6#include "../src/hip/selftest_policy.hpp"
7
8static int bad = 0;
9#define CHECK(c) do { if (!(c)) { std::printf("FAIL line %d: %s\n", __LINE__, #c); ++bad; } } while (0)
10
11int main() {
12    using namespace fnx;
13    int calls = 0;
14    auto pass = [&](std::string& covered) { ++calls; covered = "card 0: wmma, expert tile against a scalar reference"; return std::string(); };
15    auto fail = [&](std::string& covered) { ++calls; covered.clear(); return std::string("card 1: wmma A row, B col (Q K^T): 37 of 512 values wrong"); };
16
17    // the tested architecture: nothing, no test, whatever the name carries after the colon
18    SelftestDecision d = selftest_decide("gfx1201:sramecc-:xnack-", nullptr, nullptr, pass);
19    CHECK(d.ok && !d.run && d.lines.empty() && calls == 0);
20    // ... unless FNX_SELFTEST=1 asks for it (no experimental line there)
21    d = selftest_decide("gfx1201:sramecc-:xnack-", "1", nullptr, pass);
22    CHECK(d.ok && d.run && calls == 1 && d.lines.size() == 1 && d.lines[0].rfind("The split engine's self-test passed on gfx1201 (", 0) == 0);
23    // an untested architecture: the experimental line with the link, then the test, then the pass line
24    calls = 0;
25    d = selftest_decide("gfx1100", nullptr, nullptr, pass);
26    CHECK(d.ok && d.run && calls == 1 && d.lines.size() == 2);
27    CHECK(d.lines[0] == std::string("The split engine is experimental on this card (gfx1100): Strata has not run it on this architecture. Please report whether it works: ") + SPLIT_REPORT_URL);
28    CHECK(d.lines[1] == "The split engine's self-test passed on gfx1100 (card 0: wmma, expert tile against a scalar reference).");
29    for (const std::string& l : d.lines) CHECK(l.find('\n') == std::string::npos);
30    // a failure: not ok, the second line says why in one plain sentence and what happens next
31    calls = 0;
32    d = selftest_decide("gfx1103", nullptr, nullptr, fail);
33    CHECK(!d.ok && d.run && calls == 1 && d.lines.size() == 2);
34    CHECK(d.lines[1] == "The split engine's self-test failed on gfx1103 (card 1: wmma A row, B col (Q K^T): 37 of 512 values wrong), so it does not run on this card: the normal layer split starts instead.");
35    // the forced failure (the tester hook) does not even call the test, on any architecture
36    calls = 0;
37    d = selftest_decide("gfx1201", "1", "1", pass);
38    CHECK(!d.ok && calls == 0 && d.lines.size() == 1 && d.lines[0].find("forced failure (FNX_SELFTEST_FAIL=1)") != std::string::npos);
39    d = selftest_decide("gfx1200", nullptr, "1", pass);
40    CHECK(!d.ok && calls == 0 && d.lines.size() == 2);
41    // FNX_SELFTEST_FAIL on a tested architecture without FNX_SELFTEST=1 changes nothing
42    d = selftest_decide("gfx1201", nullptr, "1", pass);
43    CHECK(d.ok && !d.run && d.lines.empty());
44    std::printf(bad ? "selftest_policy_test: %d FAILED\n" : "selftest_policy_test: ok\n", bad);
45    return bad ? 1 : 0;
46}