File tree Expand file tree Collapse file tree 3 files changed +19
-17
lines changed Expand file tree Collapse file tree 3 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,10 @@ function(ggml_add_cpu_backend_variant tag_name)
308308 set (GGML_INTERNAL_${feat} ON )
309309 endforeach ()
310310 elseif (GGML_SYSTEM_ARCH STREQUAL "s390x" )
311+ foreach (feat VXE2 NNPA)
312+ set (GGML_INTERNAL_${feat} OFF )
313+ endforeach ()
314+
311315 foreach (feat ${ARGN} )
312316 set (GGML_INTERNAL_${feat} ON )
313317 endforeach ()
@@ -377,8 +381,8 @@ if (GGML_CPU_ALL_VARIANTS)
377381 endif ()
378382 elseif (GGML_SYSTEM_ARCH STREQUAL "s390x" )
379383 if (CMAKE_SYSTEM_NAME MATCHES "Linux" )
380- ggml_add_cpu_backend_variant(z15 Z15 VXE )
381- ggml_add_cpu_backend_variant(z16 Z16 VXE )
384+ ggml_add_cpu_backend_variant(z15 Z15 VXE2 )
385+ ggml_add_cpu_backend_variant(z16 Z16 VXE2 NNPA )
382386 else ()
383387 message (FATAL_ERROR "Unsupported s390x target OS: ${CMAKE_SYSTEM_NAME} " )
384388 endif ()
Original file line number Diff line number Diff line change @@ -504,10 +504,15 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
504504 endforeach ()
505505 endif ()
506506
507- if (GGML_VXE OR GGML_INTERNAL_VXE )
508- message (STATUS "VX/VXE/ VXE2 enabled" )
507+ if (GGML_VXE OR GGML_INTERNAL_VXE2 )
508+ message (STATUS "VXE2 enabled" )
509509 list (APPEND ARCH_FLAGS -mvx -mzvector)
510- list (APPEND ARCH_DEFINITIONS GGML_VXE)
510+ list (APPEND ARCH_DEFINITIONS GGML_USE_VXE2)
511+ endif ()
512+
513+ if (GGML_INTERNAL_NNPA)
514+ message (STATUS "NNPA enabled" )
515+ list (APPEND ARCH_DEFINITIONS GGML_USE_NNPA)
511516 endif ()
512517
513518 ggml_add_cpu_backend_features(${GGML_CPU_NAME} s390 ${ARCH_DEFINITIONS} )
Original file line number Diff line number Diff line change 44#include < sys/auxv.h>
55
66// find hwcap bits in asm/elf.h
7- #ifndef HWCAP_VXRS_EXT
8- #define HWCAP_VXRS_EXT (1 << 13 )
9- #endif
10-
117#ifndef HWCAP_VXRS_EXT2
128#define HWCAP_VXRS_EXT2 (1 << 15 )
139#endif
1713#endif
1814
1915struct s390x_features {
20- bool has_vxe = false ;
2116 bool has_vxe2 = false ;
2217 bool has_nnpa = false ;
2318
@@ -26,7 +21,6 @@ struct s390x_features {
2621 // NOTE: use hwcap2 with DFLT for z17 and later
2722 // uint32_t hwcap2 = getauxval(AT_HWCAP2);
2823
29- has_vxe = !!(hwcap & HWCAP_VXRS_EXT);
3024 has_vxe2 = !!(hwcap & HWCAP_VXRS_EXT2);
3125 has_nnpa = !!(hwcap & HWCAP_NNPA);
3226 }
@@ -36,17 +30,16 @@ static int ggml_backend_cpu_s390x_score() {
3630 int score = 1 ;
3731 s390x_features sf;
3832
39- #ifdef GGML_USE_VXE
40- if (!sf.has_vxe ) { return 0 ; }
41- score += 1 << 1 ;
42- #endif
33+ // IBM z15 / LinuxONE 3
4334#ifdef GGML_USE_VXE2
4435 if (!sf.has_vxe2 ) { return 0 ; }
45- score += 1 << 2 ;
36+ score += 1 << 1 ;
4637#endif
38+
39+ // IBM z16 / LinuxONE 4 and z17 / LinuxONE 5
4740#ifdef GGML_USE_NNPA
4841 if (!sf.has_nnpa ) { return 0 ; }
49- score += 1 << 3 ;
42+ score += 1 << 2 ;
5043#endif
5144
5245 return score;
You can’t perform that action at this time.
0 commit comments