okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fea8a3e63
main
1// (asserts stay on in a Release build: the test is its own check) 2#undef NDEBUG 3#include "strata/core/lookup_default.hpp" 4#include <cassert> 5#include <iostream> 6 7using strata::core::LookupDefaultIn ; 8using strata::core::default_lookup_max_t ; 9 10int main () { 11LookupDefaultIn cuda ;// the 8-row CUDA serve on one card, the case the owner decided 12cuda .narrow_window = cuda .serve = cuda .suffix_draft = cuda .spec_at_least_2 = true; 13assert (default_lookup_max_t (cuda )== 12 ); 14 15LookupDefaultIn metal = cuda ;// Metal also has 8-row windows, but no 12-row window: the option stays off 16metal .metal_build = true; 17assert (default_lookup_max_t (metal )== 0 ); 18 19LookupDefaultIn wide = cuda ;// HIP (16 rows) keeps its old windows 20wide .narrow_window = false; 21assert (default_lookup_max_t (wide )== 0 ); 22 23// every other condition turns it off on its own 24bool LookupDefaultIn ::* off_when_true []= {& LookupDefaultIn ::env_off ,& LookupDefaultIn ::multi_gpu ,& LookupDefaultIn ::layer_split , 25& LookupDefaultIn ::batch ,& LookupDefaultIn ::dflash2 ,& LookupDefaultIn ::lookup_chain }; 26for (auto m :off_when_true ) { 27LookupDefaultIn x = cuda ; 28x .*m = true; 29assert (default_lookup_max_t (x )== 0 ); 30 } 31bool LookupDefaultIn ::* off_when_false []= {& LookupDefaultIn ::narrow_window ,& LookupDefaultIn ::serve ,& LookupDefaultIn ::suffix_draft , 32& LookupDefaultIn ::spec_at_least_2 }; 33for (auto m :off_when_false ) { 34LookupDefaultIn x = cuda ; 35x .*m = false; 36assert (default_lookup_max_t (x )== 0 ); 37 } 38 std::cout <<"lookup_default_test: ok\n" ; 39return 0 ; 40}