File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,12 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
312312 message (STATUS "Unknown architecture" )
313313 endif ()
314314
315+ include (CheckSymbolExists)
316+ check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
317+ if (HAVE_ELF_AUX_INFO)
318+ add_compile_definitions (HAVE_ELF_AUX_INFO)
319+ endif ()
320+
315321 if (GGML_CPU_AARCH64)
316322 target_compile_definitions (${GGML_CPU_NAME} PRIVATE GGML_USE_CPU_AARCH64)
317323 endif ()
Original file line number Diff line number Diff line change @@ -2371,7 +2371,7 @@ bool ggml_is_numa(void) {
23712371
23722372#if defined(__ARM_ARCH )
23732373
2374- #if defined(__linux__ ) && defined(__aarch64__ )
2374+ #if ( defined(__linux__ ) || defined( HAVE_ELF_AUX_INFO ) ) && defined(__aarch64__ )
23752375#include <sys/auxv.h>
23762376#elif defined(__APPLE__ )
23772377#include <sys/sysctl.h>
@@ -2382,9 +2382,16 @@ bool ggml_is_numa(void) {
23822382#endif
23832383
23842384static void ggml_init_arm_arch_features (void ) {
2385- #if defined(__linux__ ) && defined(__aarch64__ )
2385+ #if (defined(__linux__ ) || defined(HAVE_ELF_AUX_INFO )) && defined(__aarch64__ )
2386+ #if defined(HAVE_ELF_AUX_INFO )
2387+ uint32_t hwcap = 0 ;
2388+ uint32_t hwcap2 = 0 ;
2389+ elf_aux_info (AT_HWCAP , & hwcap , sizeof (hwcap ));
2390+ elf_aux_info (AT_HWCAP2 , & hwcap2 , sizeof (hwcap2 ));
2391+ #else
23862392 uint32_t hwcap = getauxval (AT_HWCAP );
23872393 uint32_t hwcap2 = getauxval (AT_HWCAP2 );
2394+ #endif
23882395
23892396 ggml_arm_arch_features .has_neon = !!(hwcap & HWCAP_ASIMD );
23902397 ggml_arm_arch_features .has_dotprod = !!(hwcap & HWCAP_ASIMDDP );
You can’t perform that action at this time.
0 commit comments