okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b1abdcf9b
main
1// the HIP rule of the fused trellis (Gyro) prompt kernels (include/strata/prefill/fused_tq_hip.hpp): gfx12 with STRATA_PF_FUSED_TQ=1 as before; gfx1151 by STRATA_PF_TQ_G1151 2// (1 on, other values off, unset = the Windows default unless STRATA_GFX1151_DEFAULTS=0); every other device off. Every input combination is checked. No GPU, no model. 3#include <cstdio> 4 5#include "strata/prefill/fused_tq_hip.hpp" 6 7using strata::prefill::fused_tq_hip::device_on ; 8using strata::prefill::fused_tq_hip::kG1151DefaultOn ; 9using strata::prefill::fused_tq_hip::pair_on ; 10using strata::prefill::fused_tq_hip::parse_switch ; 11 12static int failed = 0 ; 13#define CHECK (x ) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0) 14 15// the expected answer, written out apart from the header's form 16static bool want_device (bool w12 ,bool g1151 ,bool win ,bool tq ,int sw ,bool doff ,bool def ) { 17if (!tq )return false;// no STRATA_PF_FUSED_TQ=1 (a build with MMQ, nothing set): never 18if (w12 )return true;// gfx12: unchanged, the switch and the gfx1151 rules do not apply 19if (!g1151 )return false;// gfx1100-1103, gfx1150, gfx9: never 20if (sw == 1 )return true;// gfx1151, the switch at 1: on (Linux too) 21if (sw == 0 )return false;// gfx1151, the switch at another value: off 22return def && win && !doff ;// unset: the Windows default 23} 24 25int main () { 26// the variable's three readings 27CHECK (parse_switch (nullptr )== -1 && parse_switch ("" )== -1 ); 28CHECK (parse_switch ("1" )== 1 && parse_switch ("1x" )== 1 ); 29CHECK (parse_switch ("0" )== 0 && parse_switch ("2" )== 0 && parse_switch ("off" )== 0 ); 30 31// the shipped default for Windows gfx1151 32CHECK (kG1151DefaultOn == true); 33// with the shipped default: Windows gfx1151 on when unset; Linux, STRATA_GFX1151_DEFAULTS=0, the switch at 0 and a build without STRATA_PF_FUSED_TQ off 34CHECK (strata::prefill::fused_tq_hip::device_on (false, true, true, true,-1 , false,kG1151DefaultOn )); 35CHECK (!strata::prefill::fused_tq_hip::device_on (false, true, false, true,-1 , false,kG1151DefaultOn )); 36CHECK (!strata::prefill::fused_tq_hip::device_on (false, true, true, true,-1 , true,kG1151DefaultOn )); 37CHECK (!strata::prefill::fused_tq_hip::device_on (false, true, true, true,0 , false,kG1151DefaultOn )); 38CHECK (!strata::prefill::fused_tq_hip::device_on (false, true, true, false,-1 , false,kG1151DefaultOn )); 39 40const int sws []= {-1 ,0 ,1 }; 41for (int m = 0 ;m < 64 ;++ m ) { 42const bool w12 = m & 1 ,g1151 = m & 2 ,win = m & 4 ,tq = m & 8 ,doff = m & 16 ,def = m & 32 ; 43if (w12 && g1151 )continue ;// (one device is never both) 44for (int sw :sws ) { 45const bool dv = device_on (w12 ,g1151 ,win ,tq ,sw ,doff ,def ); 46CHECK (dv == want_device (w12 ,g1151 ,win ,tq ,sw ,doff ,def )); 47// Gyro-S's pair follows the device rule 48CHECK (pair_on (w12 ,g1151 ,win ,tq ,sw ,doff ,def , true, false)== dv ); 49// Gyro-M's pair: gfx12 as before; gfx1151 only with the switch at 1 50CHECK (pair_on (w12 ,g1151 ,win ,tq ,sw ,doff ,def , false, true)== (dv && (w12 || sw == 1 ))); 51// anything that is neither pair: never 52CHECK (!pair_on (w12 ,g1151 ,win ,tq ,sw ,doff ,def , false, false)); 53 } 54 } 55 56// spelled out: gfx12 under a build without MMQ keeps both pairs whatever the gfx1151 switch says 57CHECK (device_on (true, false, true, true,0 , true, false)&& pair_on (true, false, false, true,-1 , false, false, false, true)); 58// a build with MMQ (STRATA_PF_FUSED_TQ unset): gfx1151 stays off even with the switch at 1 59CHECK (!device_on (false, true, true, false,1 , false, true)); 60// gfx1100 (a 7900 XTX) and gfx1150: off with every switch 61CHECK (!device_on (false, false, true, true,1 , false, true)&& !device_on (false, false, false, true,-1 , false, true)); 62// Linux gfx1151 with the default on: off unless the switch is 1 63CHECK (!device_on (false, true, false, true,-1 , false, true)&& device_on (false, true, false, true,1 , false, true)); 64// Windows gfx1151 with the default on: STRATA_GFX1151_DEFAULTS=0 or the switch at 0 turns it off 65CHECK (device_on (false, true, true, true,-1 , false, true)&& !device_on (false, true, true, true,-1 , true, true)&& !device_on (false, true, true, true,0 , false, true)); 66 67if (failed ) { std::fprintf (stderr ,"fused_tq_hip_test: %d failed\n" ,failed );return 1 ; } 68 std::printf ("fused_tq_hip_test: ok\n" ); 69return 0 ; 70}