1- function (ggml_add_cpu_backend_features cpu_name arch)
2- # The feature detection code is compiled as a separate target so that
3- # it can be built without the architecture flags
4- # Since multiple variants of the CPU backend may be included in the same
5- # build, using set_source_files_properties() to set the arch flags is not possible
6- set (GGML_CPU_FEATS_NAME ${cpu_name} -feats)
7- add_library (${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/arch/${arch} /cpu-feats.cpp)
8- target_include_directories (${GGML_CPU_FEATS_NAME} PRIVATE . ../include )
9- target_compile_definitions (${GGML_CPU_FEATS_NAME} PRIVATE ${ARGN} )
10- target_compile_definitions (${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED)
11- set_target_properties (${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON )
12- target_link_libraries (${cpu_name} PRIVATE ${GGML_CPU_FEATS_NAME} )
13- endfunction ()
14-
151function (ggml_add_cpu_backend_variant_impl tag_name)
162 if (tag_name)
173 set (GGML_CPU_NAME ggml-cpu-${tag_name} )
@@ -157,49 +143,6 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
157143 else ()
158144 if (GGML_CPU_ARM_ARCH)
159145 list (APPEND ARCH_FLAGS -march=${GGML_CPU_ARM_ARCH} )
160- elseif (GGML_CPU_ALL_VARIANTS)
161- # Begin with the lowest baseline
162- set (ARM_MCPU "armv8-a" )
163- set (ARCH_TAGS "" )
164- set (ARCH_DEFINITIONS "" )
165-
166- # When a feature is selected, bump the MCPU to the first
167- # version that supported it
168- if (GGML_INTERNAL_DOTPROD)
169- set (ARM_MCPU "armv8.2-a" )
170- set (ARCH_TAGS "${ARCH_TAGS} +dotprod" )
171- list (APPEND ARCH_DEFINITIONS GGML_USE_DOTPROD)
172- endif ()
173- if (GGML_INTERNAL_FP16_VECTOR_ARITHMETIC)
174- set (ARM_MCPU "armv8.2-a" )
175- set (ARCH_TAGS "${ARCH_TAGS} +fp16" )
176- list (APPEND ARCH_DEFINITIONS GGML_USE_FP16_VECTOR_ARITHMETIC)
177- endif ()
178- if (GGML_INTERNAL_SVE)
179- set (ARM_MCPU "armv8.2-a" )
180- set (ARCH_TAGS "${ARCH_TAGS} +sve" )
181- list (APPEND ARCH_DEFINITIONS GGML_USE_SVE)
182- endif ()
183- if (GGML_INTERNAL_MATMUL_INT8)
184- set (ARM_MCPU "armv8.6-a" )
185- set (ARCH_TAGS "${ARCH_TAGS} +i8mm" )
186- list (APPEND ARCH_DEFINITIONS GGML_USE_MATMUL_INT8)
187- endif ()
188- if (GGML_INTERNAL_SVE2)
189- set (ARM_MCPU "armv8.6-a" )
190- set (ARCH_TAGS "${ARCH_TAGS} +sve2" )
191- list (APPEND ARCH_DEFINITIONS GGML_USE_SVE2)
192- endif ()
193- if (GGML_INTERNAL_NOSVE)
194- set (ARCH_TAGS "${ARCH_TAGS} +nosve" )
195- endif ()
196- if (GGML_INTERNAL_SME)
197- set (ARM_MCPU "armv9.2-a" )
198- set (ARCH_TAGS "${ARCH_TAGS} +sme" )
199- list (APPEND ARCH_DEFINITIONS GGML_USE_SME)
200- endif ()
201- list (APPEND ARCH_FLAGS "-march=${ARM_MCPU}${ARCH_TAGS} " )
202- ggml_add_cpu_backend_features(${GGML_CPU_NAME} arm ${ARCH_DEFINITIONS} )
203146 endif ()
204147 endif ()
205148
@@ -363,7 +306,18 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
363306 # the feature check relies on ARCH_DEFINITIONS, but it is not set with GGML_NATIVE
364307 message (FATAL_ERROR "GGML_NATIVE is not compatible with GGML_BACKEND_DL, consider using GGML_CPU_ALL_VARIANTS" )
365308 endif ()
366- ggml_add_cpu_backend_features(${GGML_CPU_NAME} x86 ${ARCH_DEFINITIONS} )
309+
310+ # The feature detection code is compiled as a separate target so that
311+ # it can be built without the architecture flags
312+ # Since multiple variants of the CPU backend may be included in the same
313+ # build, using set_source_files_properties() to set the arch flags is not possible
314+ set (GGML_CPU_FEATS_NAME ${GGML_CPU_NAME} -feats)
315+ add_library (${GGML_CPU_FEATS_NAME} OBJECT ggml-cpu/arch/x86/cpu-feats.cpp)
316+ target_include_directories (${GGML_CPU_FEATS_NAME} PRIVATE . .. ../include )
317+ target_compile_definitions (${GGML_CPU_FEATS_NAME} PRIVATE ${ARCH_DEFINITIONS} )
318+ target_compile_definitions (${GGML_CPU_FEATS_NAME} PRIVATE GGML_BACKEND_DL GGML_BACKEND_BUILD GGML_BACKEND_SHARED)
319+ set_target_properties (${GGML_CPU_FEATS_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON )
320+ target_link_libraries (${GGML_CPU_NAME} PRIVATE ${GGML_CPU_FEATS_NAME} )
367321 endif ()
368322 elseif (GGML_SYSTEM_ARCH STREQUAL "PowerPC" )
369323 message (STATUS "PowerPC detected" )
@@ -388,27 +342,6 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
388342 else ()
389343 list (APPEND ARCH_FLAGS -mcpu=native -mtune=native -mpowerpc64)
390344 endif ()
391- elseif (GGML_CPU_ALL_VARIANTS)
392- # Begin with the lowest baseline
393- set (ARCH_DEFINITIONS "" )
394-
395- # When a feature is selected, bump the MCPU to the first
396- # version that supported it
397- foreach (PVER RANGE 7 11)
398- if (DEFINED GGML_INTERNAL_POWER${PVER} )
399- set (POWERPC_MCPU "power${PVER} " )
400- list (APPEND ARCH_DEFINITIONS GGML_USE_POWER${PVER} )
401- endif ()
402- endforeach ()
403- if (GGML_INTERNAL_VSX)
404- list (APPEND ARCH_DEFINITIONS GGML_USE_VSX)
405- list (APPEND ARCH_FLAGS -mvsx)
406- endif ()
407-
408- if (DEFINED POWERPC_MCPU)
409- list (APPEND ARCH_FLAGS -mcpu=${POWERPC_MCPU} )
410- endif ()
411- ggml_add_cpu_backend_features(${GGML_CPU_NAME} powerpc ${ARCH_DEFINITIONS} )
412345 else ()
413346 if (GGML_CPU_POWERPC_CPUTYPE)
414347 list (APPEND ARCH_FLAGS -mcpu=${GGML_CPU_POWERPC_CPUTYPE} )
@@ -448,7 +381,6 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
448381
449382 # TODO: Separation to determine activation of VX/VXE/VXE2
450383 if (${S390X_M} MATCHES "8561|8562" )
451- set (GGML_NNPA OFF )
452384 message (STATUS "z15 target" )
453385 list (APPEND ARCH_FLAGS -march=z15)
454386 elseif (${S390X_M} MATCHES "3931" )
@@ -465,14 +397,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
465397 endif ()
466398
467399 if (GGML_VXE)
468- message (STATUS "VX/VXE/VXE2 enabled" )
469400 list (APPEND ARCH_FLAGS -mvx -mzvector)
470- list (APPEND ARCH_DEFINITIONS GGML_VXE)
471- endif ()
472-
473- if (GGML_NNPA)
474- message (STATUS "NNPA enabled" )
475- list (APPEND ARCH_DEFINITIONS GGML_NNPA)
476401 endif ()
477402 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "wasm" )
478403 message (STATUS "Wasm detected" )
@@ -494,9 +419,9 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
494419
495420 # Fetch KleidiAI sources:
496421 include (FetchContent)
497- set (KLEIDIAI_COMMIT_TAG "v1.9 .0" )
422+ set (KLEIDIAI_COMMIT_TAG "v1.6 .0" )
498423 set (KLEIDIAI_DOWNLOAD_URL "https://github.com/ARM-software/kleidiai/archive/refs/tags/${KLEIDIAI_COMMIT_TAG} .tar.gz" )
499- set (KLEIDIAI_ARCHIVE_MD5 "2a8e1bb55d201557553545536489a017 " )
424+ set (KLEIDIAI_ARCHIVE_MD5 "75b4ad68f25ab673dcc01065e5a0b05f " )
500425
501426 if (POLICY CMP0135)
502427 cmake_policy (SET CMP0135 NEW)
@@ -589,9 +514,4 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
589514 if (EMSCRIPTEN)
590515 set_target_properties (${GGML_CPU_NAME} PROPERTIES COMPILE_FLAGS "-msimd128" )
591516 endif ()
592-
593- if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" )
594- # The compiler automatically enables "-ffast-math" which can cause NaNs in tests due to "-fassociative-math"
595- target_compile_options (${GGML_CPU_NAME} PRIVATE "-fno-associative-math" )
596- endif ()
597517endfunction ()
0 commit comments