char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
6369be073
char/aliceai-t5-moe
1# include "ggml-backend-impl.h" 2 3#if defined(__powerpc64__ )|| defined(__ppc64__ )|| defined(__PPC64__ ) 4 5#if defined(__linux__ ) 6#include <sys/auxv.h> 7#endif 8 9#include <string> 10 11struct powerpc_features { 12 std::string platform = "" ; 13int power_version = -1 ; 14 15bool has_vsx = false; 16 17powerpc_features () { 18#if defined(__linux__ ) 19unsigned long auxval = getauxval (AT_PLATFORM ); 20if (auxval ) { 21platform = std::string (reinterpret_cast < const char *> (auxval )); 22// TBD: Do systems exist that return this in uppercase? 23if (platform .substr (0 ,5 )== "power" ) { 24// Extractt a numeric suffix, if one exists 25int vpos = -1 ; 26for (int i = platform .length ()- 1 ;i >=0 ;i -- ) { 27if (std::isdigit (platform [i ])) { 28vpos = i ; 29 }else { 30break ; 31 } 32 } 33if (vpos > -1 ) { 34power_version = std::stoi (platform .substr (vpos )); 35 } 36 } 37 } 38#endif 39if (power_version >=9 ) { 40has_vsx = true; 41 } 42 } 43}; 44 45static int ggml_backend_cpu_powerpc_score () { 46int score = 1 ; 47powerpc_features pf ; 48 49// Platform scores 50#if defined(GGML_USE_POWER7 ) 51if (pf .power_version < 7 ) {return 0 ; } 52score += 1 <<1 ; 53#endif 54#if defined(GGML_USE_POWER8 ) 55if (pf .power_version < 8 ) {return 0 ; } 56score += 1 <<2 ; 57#endif 58#if defined(GGML_USE_POWER9 ) 59if (pf .power_version < 9 ) {return 0 ; } 60score += 1 <<3 ; 61#endif 62#if defined(GGML_USE_POWER10 ) 63if (pf .power_version < 10 ) {return 0 ; } 64score += 1 <<4 ; 65#endif 66#if defined(GGML_USE_POWER11 ) 67if (pf .power_version < 11 ) {return 0 ; } 68score += 1 <<5 ; 69#endif 70 71// Feature scores 72#if defined(GGML_USE_VSX ) 73if (!pf .has_vsx ) {return 0 ; } 74score += 1 <<6 ; 75#endif 76 77return score ; 78} 79 80GGML_BACKEND_DL_SCORE_IMPL (ggml_backend_cpu_powerpc_score ) 81 82#endif // defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)