okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
95901fe8a
main
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 () { 12using namespace fnx ; 13int calls = 0 ; 14auto pass = [& ](std::string & covered ) {++ calls ;covered = "card 0: wmma, expert tile against a scalar reference" ;return std::string (); }; 15auto 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 18SelftestDecision d = selftest_decide ("gfx1201:sramecc-:xnack-" ,nullptr ,nullptr ,pass ); 19CHECK (d .ok && !d .run && d .lines .empty ()&& calls == 0 ); 20// ... unless FNX_SELFTEST=1 asks for it (no experimental line there) 21d = selftest_decide ("gfx1201:sramecc-:xnack-" ,"1" ,nullptr ,pass ); 22CHECK (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 24calls = 0 ; 25d = selftest_decide ("gfx1100" ,nullptr ,nullptr ,pass ); 26CHECK (d .ok && d .run && calls == 1 && d .lines .size ()== 2 ); 27CHECK (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 ); 28CHECK (d .lines [1 ]== "The split engine's self-test passed on gfx1100 (card 0: wmma, expert tile against a scalar reference)." ); 29for (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 31calls = 0 ; 32d = selftest_decide ("gfx1103" ,nullptr ,nullptr ,fail ); 33CHECK (!d .ok && d .run && calls == 1 && d .lines .size ()== 2 ); 34CHECK (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 36calls = 0 ; 37d = selftest_decide ("gfx1201" ,"1" ,"1" ,pass ); 38CHECK (!d .ok && calls == 0 && d .lines .size ()== 1 && d .lines [0 ].find ("forced failure (FNX_SELFTEST_FAIL=1)" )!= std::string::npos ); 39d = selftest_decide ("gfx1200" ,nullptr ,"1" ,pass ); 40CHECK (!d .ok && calls == 0 && d .lines .size ()== 2 ); 41// FNX_SELFTEST_FAIL on a tested architecture without FNX_SELFTEST=1 changes nothing 42d = selftest_decide ("gfx1201" ,nullptr ,"1" ,pass ); 43CHECK (d .ok && !d .run && d .lines .empty ()); 44 std::printf (bad ?"selftest_policy_test: %d FAILED\n" :"selftest_policy_test: ok\n" ,bad ); 45return bad ?1 :0 ; 46}