okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6aae30348
main
1// The prompt path's K/V append under KV streaming (strata/core/kv_host_dma.hpp): CUDA copies the chunk's new cells to 2// the host copy by DMA by default, HIP keeps the kernel's own stores unless asked, STRATA_KV_HOST_DMA=1 / 0 forces 3// either way, and a layer without a staging pool always keeps the kernel's stores. 4#include "strata/core/kv_host_dma.hpp" 5 6#include <cstdio> 7 8using namespace strata::core ; 9 10namespace { 11int failed = 0 ; 12#define CHECK (x ) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0) 13}// namespace 14 15int main () { 16// unset: the backend's default (CUDA true, HIP false) 17CHECK (kv_host_dma_on (nullptr , true)); 18CHECK (!kv_host_dma_on (nullptr , false)); 19// "1" / "0" force it on both backends 20CHECK (kv_host_dma_on ("1" , false)); 21CHECK (kv_host_dma_on ("1" , true)); 22CHECK (!kv_host_dma_on ("0" , true)); 23CHECK (!kv_host_dma_on ("0" , false)); 24// HIP as before this header: only a value that starts with '1' turns it on 25CHECK (kv_host_dma_on ("1yes" , false)); 26CHECK (!kv_host_dma_on ("" , false)); 27CHECK (!kv_host_dma_on ("yes" , false)); 28CHECK (!kv_host_dma_on ("2" , false)); 29// CUDA: anything but a leading '0' keeps the default on 30CHECK (kv_host_dma_on ("" , true)); 31CHECK (kv_host_dma_on ("yes" , true)); 32CHECK (!kv_host_dma_on ("0n" , true)); 33// one append: the switch, a streamed (staged) layer, and its staging pool; any one missing -> the kernel's stores 34CHECK (kv_host_dma_use (true, true, true)); 35for (int on = 0 ;on < 2 ;++ on ) 36for (int staged = 0 ;staged < 2 ;++ staged ) 37for (int pool = 0 ;pool < 2 ;++ pool ) 38if (!(on && staged && pool ))CHECK (!kv_host_dma_use (on != 0 ,staged != 0 ,pool != 0 )); 39if (failed ) { 40 std::fprintf (stderr ,"kv_host_dma_test: %d failed\n" ,failed ); 41return 1 ; 42 } 43 std::printf ("kv_host_dma_test: ok\n" ); 44return 0 ; 45}