@@ -82,8 +82,8 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
82
82
if (MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" )
83
83
message (FATAL_ERROR "MSVC is not supported for ARM, use clang" )
84
84
else ()
85
- check_cxx_compiler_flag (-mfp16-format=ieee COMPILER_SUPPORTS_FP16_FORMAT_I3E )
86
- if (NOT "${COMPILER_SUPPORTS_FP16_FORMAT_I3E } " STREQUAL "" )
85
+ check_cxx_compiler_flag (-mfp16-format=ieee GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E )
86
+ if (NOT "${GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E } " STREQUAL "" )
87
87
list (APPEND ARCH_FLAGS -mfp16-format=ieee )
88
88
endif ()
89
89
@@ -106,28 +106,28 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
106
106
message (STATUS "ARM -mcpu not found, -mcpu=native will be used" )
107
107
endif ()
108
108
109
- set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS} )
110
109
include (CheckCXXSourceRuns )
111
110
112
- set (CMAKE_REQUIRED_FLAGS "${ARM_MCPU_FLAG} +dotprod" )
113
- check_cxx_source_runs (
114
- "#include <arm_neon.h>\n int main() { int8x16_t _a, _b; int32x4_t _s = vdotq_s32(_s, _a, _b); return 0; }"
115
- GGML_COMPILER_SUPPORT_DOTPROD )
116
- if (GGML_COMPILER_SUPPORT_DOTPROD )
117
- set (ARM_MCPU_FLAG_FIX "${ARM_MCPU_FLAG_FIX} +dotprod" )
118
- endif ()
111
+ function (check_arm_feature tag code )
112
+ set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS} )
113
+ set (CMAKE_REQUIRED_FLAGS "${ARM_MCPU_FLAG} +${tag} " )
114
+ check_cxx_source_runs (
115
+ "${code} "
116
+ GGML_MACHINE_SUPPORTS_${tag}
117
+ )
118
+ if (GGML_MACHINE_SUPPORTS_${tag} )
119
+ set (ARM_MCPU_FLAG_FIX "${ARM_MCPU_FLAG_FIX} +${tag} " PARENT_SCOPE )
120
+ else ()
121
+ set (ARM_MCPU_FLAG_FIX "${ARM_MCPU_FLAG_FIX} +no${tag} " PARENT_SCOPE )
122
+ endif ()
123
+ set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} )
124
+ endfunction ()
119
125
120
- set (CMAKE_REQUIRED_FLAGS "${ARM_MCPU_FLAG} +i8mm" )
121
- check_cxx_source_runs (
122
- "#include <arm_neon.h>\n int main() { int8x16_t _a, _b; int32x4_t _s = vmmlaq_s32(_s, _a, _b); return 0; }"
123
- GGML_COMPILER_SUPPORT_I8MM )
124
- if (GGML_COMPILER_SUPPORT_I8MM )
125
- set (ARM_MCPU_FLAG_FIX "${ARM_MCPU_FLAG_FIX} +i8mm" )
126
- endif ()
126
+ check_arm_feature (dotprod "#include <arm_neon.h>\n int main() { int8x16_t _a, _b; volatile int32x4_t _s = vdotq_s32(_s, _a, _b); return 0; }" )
127
+ check_arm_feature (i8mm "#include <arm_neon.h>\n int main() { int8x16_t _a, _b; volatile int32x4_t _s = vmmlaq_s32(_s, _a, _b); return 0; }" )
128
+ check_arm_feature (sve "#include <arm_sve.h>\n int main() { svfloat32_t _a, _b; volatile svfloat32_t _c = svadd_f32_z(svptrue_b8(), _a, _b); return 0; }" )
127
129
128
- set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} )
129
130
list (APPEND ARCH_FLAGS "${ARM_MCPU_FLAG}${ARM_MCPU_FLAG_FIX} " )
130
-
131
131
else ()
132
132
if (GGML_CPU_ARM_ARCH )
133
133
list (APPEND ARCH_FLAGS -march=${GGML_CPU_ARM_ARCH} )
0 commit comments