okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
4ea595bbe
main
1// plain_floor_rule.hpp: the long-prompt floor of the plain pack by card class and share state. No GPU, no model. 2// Classes: plain pack (build without MMQ, non-native pack) or not; discrete CUDA card (answered, not integrated) or integrated / not asked / HIP; share armed (limit 3,072 or 1,024) or not; switch. 3#include <cstdint> 4#include <cstdio> 5#include <initializer_list> 6 7#include "strata/prefill/plain_floor_rule.hpp" 8 9using strata::prefill::floor_with_share ; 10using strata::prefill::kPlainDiscreteFloor ; 11using strata::prefill::plain_floor_off ; 12using strata::prefill::plain_takes_discrete_floor ; 13 14static int failed = 0 ; 15#define CHECK (x ) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0) 16 17int main () { 18constexpr int64_t kFused = 64 ;// stream_floor_rule.hpp kFusedOnlyFloor, the plain pack's default floor 19constexpr int64_t kDefault = 1024 ;// kStreamFloorDefault 20// the way back: only "0" 21CHECK (!plain_floor_off (nullptr )); 22CHECK (!plain_floor_off ("" )); 23CHECK (!plain_floor_off ("00" )); 24CHECK (!plain_floor_off ("1" )); 25CHECK (!plain_floor_off ("off" )); 26CHECK (plain_floor_off ("0" )); 27// class: only (plain pack) x (discrete CUDA card) x (switch not "0") takes the discrete floor 28for (const char * env : {(const char * )nullptr ,"" ,"1" ,"x" }) { 29CHECK (plain_takes_discrete_floor (true, true,env )); 30CHECK (!plain_takes_discrete_floor (true, false,env ));// integrated / not asked yet / HIP: unchanged 31CHECK (!plain_takes_discrete_floor (false, true,env ));// a native pack or a build with MMQ: unchanged 32CHECK (!plain_takes_discrete_floor (false, false,env )); 33 } 34for (const bool plain : {false, true}) 35for (const bool disc : {false, true})CHECK (!plain_takes_discrete_floor (plain ,disc ,"0" ));// the way back, every class 36// the answer: the plain pack on a discrete card, share armed (3,072 / 1,024) or not, takes the discrete floor 37CHECK (floor_with_share (true,3072 ,kFused )== kPlainDiscreteFloor ); 38CHECK (floor_with_share (true,1024 ,kFused )== kPlainDiscreteFloor ); 39CHECK (floor_with_share (true,0 ,kFused )== kPlainDiscreteFloor ); 40CHECK (kPlainDiscreteFloor == 1536 );// the measured constant (RTX 5070); above the default floor and the plain pack's 64, below the share's limit 41CHECK (kPlainDiscreteFloor > kDefault && kPlainDiscreteFloor > kFused && kPlainDiscreteFloor < 3072 ); 42// a default floor above the constant is never lowered 43CHECK (floor_with_share (true,0 ,4096 )== 4096 ); 44CHECK (floor_with_share (true,3072 ,4096 )== 4096 ); 45// every other class keeps the old answer: the share's limit when armed, else the default floor 46CHECK (floor_with_share (false,3072 ,kFused )== 3072 );// integrated GPU / unknown card / HIP, plain pack, share armed 47CHECK (floor_with_share (false,1024 ,kFused )== 1024 ); 48CHECK (floor_with_share (false,0 ,kFused )== kFused );// integrated GPU, plain pack, no share: 64 stays 49CHECK (floor_with_share (false,3072 ,kDefault )== 3072 );// native pack, share armed 50CHECK (floor_with_share (false,0 ,kDefault )== kDefault );// native pack, no share 51CHECK (floor_with_share (false,-1 ,kDefault )== kDefault );// no share (negative = not armed) 52if (failed == 0 ) std::printf ("plain_floor_rule_test: ok\n" ); 53return failed == 0 ?0 :1 ; 54}