Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
ggml: fix review comments
* drop vxe feature
* add nnpa feature

Signed-off-by: Aaron Teo <[email protected]>
  • Loading branch information
taronaeo committed Nov 1, 2025
commit b62c93efc811e4302ac16535c7332f6e79c71db8
8 changes: 6 additions & 2 deletions ggml/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ function(ggml_add_cpu_backend_variant tag_name)
set(GGML_INTERNAL_${feat} ON)
endforeach()
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
foreach (feat VXE2 NNPA)
set(GGML_INTERNAL_${feat} OFF)
endforeach()

foreach (feat ${ARGN})
set(GGML_INTERNAL_${feat} ON)
endforeach()
Expand Down Expand Up @@ -377,8 +381,8 @@ if (GGML_CPU_ALL_VARIANTS)
endif()
elseif (GGML_SYSTEM_ARCH STREQUAL "s390x")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
ggml_add_cpu_backend_variant(z15 Z15 VXE)
ggml_add_cpu_backend_variant(z16 Z16 VXE)
ggml_add_cpu_backend_variant(z15 Z15 VXE2)
ggml_add_cpu_backend_variant(z16 Z16 VXE2 NNPA)
else()
message(FATAL_ERROR "Unsupported s390x target OS: ${CMAKE_SYSTEM_NAME}")
endif()
Expand Down
11 changes: 8 additions & 3 deletions ggml/src/ggml-cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,15 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
endforeach()
endif()

if (GGML_VXE OR GGML_INTERNAL_VXE)
message(STATUS "VX/VXE/VXE2 enabled")
if (GGML_VXE OR GGML_INTERNAL_VXE2)
message(STATUS "VXE2 enabled")
list(APPEND ARCH_FLAGS -mvx -mzvector)
list(APPEND ARCH_DEFINITIONS GGML_VXE)
list(APPEND ARCH_DEFINITIONS GGML_USE_VXE2)
endif()

if (GGML_INTERNAL_NNPA)
message(STATUS "NNPA enabled")
list(APPEND ARCH_DEFINITIONS GGML_USE_NNPA)
endif()

ggml_add_cpu_backend_features(${GGML_CPU_NAME} s390 ${ARCH_DEFINITIONS})
Expand Down
17 changes: 5 additions & 12 deletions ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#include <sys/auxv.h>

// find hwcap bits in asm/elf.h
#ifndef HWCAP_VXRS_EXT
#define HWCAP_VXRS_EXT (1 << 13)
#endif

#ifndef HWCAP_VXRS_EXT2
#define HWCAP_VXRS_EXT2 (1 << 15)
#endif
Expand All @@ -17,7 +13,6 @@
#endif

struct s390x_features {
bool has_vxe = false;
bool has_vxe2 = false;
bool has_nnpa = false;

Expand All @@ -26,7 +21,6 @@ struct s390x_features {
// NOTE: use hwcap2 with DFLT for z17 and later
// uint32_t hwcap2 = getauxval(AT_HWCAP2);

has_vxe = !!(hwcap & HWCAP_VXRS_EXT);
has_vxe2 = !!(hwcap & HWCAP_VXRS_EXT2);
has_nnpa = !!(hwcap & HWCAP_NNPA);
}
Expand All @@ -36,17 +30,16 @@ static int ggml_backend_cpu_s390x_score() {
int score = 1;
s390x_features sf;

#ifdef GGML_USE_VXE
if (!sf.has_vxe) { return 0; }
score += 1 << 1;
#endif
// IBM z15 / LinuxONE 3
#ifdef GGML_USE_VXE2
if (!sf.has_vxe2) { return 0; }
score += 1 << 2;
score += 1 << 1;
#endif

// IBM z16 / LinuxONE 4 and z17 / LinuxONE 5
#ifdef GGML_USE_NNPA
if (!sf.has_nnpa) { return 0; }
score += 1 << 3;
score += 1 << 2;
#endif

return score;
Expand Down
Loading