@@ -157,30 +157,30 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
157157 elseif (GGML_CPU_ARM_ARCH)
158158 list (APPEND ARCH_FLAGS -march=${GGML_CPU_ARM_ARCH} )
159159 elseif (GGML_CPU_ALL_VARIANTS)
160- # Begin with the lowest baseline
161- set (ARM_MCPU "armv8-a" )
160+ # For the generic builds, begin with the lowest supported baseline
161+ set (ARM_GENERIC_ARCH "armv8-a" )
162162 set (ARCH_TAGS "" )
163163 set (ARCH_DEFINITIONS "" )
164164
165- # When a feature is selected, bump the MCPU to the first
166- # version that supported it
165+ # When a feature is selected, bump GENERIC_ARCH to the earliest
166+ # version which supported that feature
167167 if (GGML_INTERNAL_DOTPROD)
168- set (ARM_MCPU "armv8.2-a" )
168+ set (ARM_GENERIC_ARCH "armv8.2-a" )
169169 set (ARCH_TAGS "${ARCH_TAGS} +dotprod" )
170170 list (APPEND ARCH_DEFINITIONS GGML_USE_DOTPROD)
171171 endif ()
172172 if (GGML_INTERNAL_FP16_VECTOR_ARITHMETIC)
173- set (ARM_MCPU "armv8.2-a" )
173+ set (ARM_GENERIC_ARCH "armv8.2-a" )
174174 set (ARCH_TAGS "${ARCH_TAGS} +fp16" )
175175 list (APPEND ARCH_DEFINITIONS GGML_USE_FP16_VECTOR_ARITHMETIC)
176176 endif ()
177177 if (GGML_INTERNAL_SVE)
178- set (ARM_MCPU "armv8.2-a" )
178+ set (ARM_GENERIC_ARCH "armv8.2-a" )
179179 set (ARCH_TAGS "${ARCH_TAGS} +sve" )
180180 list (APPEND ARCH_DEFINITIONS GGML_USE_SVE)
181181 endif ()
182182 if (GGML_INTERNAL_MATMUL_INT8)
183- set (ARM_MCPU "armv8.6-a" )
183+ set (ARM_GENERIC_ARCH "armv8.6-a" )
184184 set (ARCH_TAGS "${ARCH_TAGS} +i8mm" )
185185 list (APPEND ARCH_DEFINITIONS GGML_USE_MATMUL_INT8)
186186 endif ()
@@ -197,7 +197,14 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
197197 set (ARCH_TAGS "${ARCH_TAGS} +sme" )
198198 list (APPEND ARCH_DEFINITIONS GGML_USE_SME)
199199 endif ()
200- list (APPEND ARCH_FLAGS "-march=${ARM_MCPU}${ARCH_TAGS} " )
200+
201+ # CPU targeted builds first, else do the generic build
202+ if (${tag_name} STREQUAL "neoverse-v2" )
203+ list (APPEND ARCH_FLAGS "-mcpu=neoverse-v2${ARCH_TAGS} " )
204+ list (APPEND ARCH_DEFINITIONS GGML_ARM_MCPU=NEOVERSE_V2)
205+ else ()
206+ list (APPEND ARCH_FLAGS "-march=${ARM_GENERIC_ARCH}${ARCH_TAGS} " )
207+ endif ()
201208 ggml_add_cpu_backend_features(${GGML_CPU_NAME} arm ${ARCH_DEFINITIONS} )
202209 endif ()
203210
0 commit comments