okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
d6aa6504e
main
1// tools/vision/gpu_arch.h - which GPU the HIP picture reader (strata-vision-hip) was compiled for, and whether the GPU it 2// found is one of them. ggml-hip prints " Device 0: AMD Radeon RX 9070 XT, gfx1201:sramecc-:xnack- (0x1201), ..." when it 3// starts; a card whose architecture is not in the build would fail at its first kernel ("no kernel image", an abort), so 4// the reader reads that line and refuses before any kernel runs. The server then starts the CPU reader (see 5// serve/server.py, Vision._start). Header only, so gpu_arch_test.cpp can check it without a GPU. 6#pragma once 7 8#include <cctype> 9#include <string> 10#include <vector> 11 12// "gfx1201" out of ggml's device line (or a gcnArchName: "gfx1201:sramecc-:xnack-"); "" when there is none 13inline std ::string strata_gfx_in (const std ::string & text ) { 14for (size_t at = text .find ("gfx" );at != std ::string ::npos ;at = text .find ("gfx" ,at + 1 )) { 15size_t end = at + 3 ; 16while (end < text .size ()&& std ::isxdigit ((unsigned char )text [end ]))++ end ; 17if (end > at + 3 )return text .substr (at ,end - at ); 18 } 19return "" ; 20} 21 22// "gfx1200,gfx1201" (the build's list; ',' or ';' between) holds `arch` 23inline bool strata_arch_listed (const std ::string & list ,const std ::string & arch ) { 24if (arch .empty ())return false; 25size_t start = 0 ; 26while (start <=list .size ()) { 27size_t end = list .find_first_of (",; " ,start ); 28if (end == std ::string ::npos )end = list .size (); 29if (list .compare (start ,end - start ,arch )== 0 && end - start == arch .size ())return true; 30start = end + 1 ; 31 } 32return false; 33}