@@ -96,6 +96,39 @@ if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" OR
96
96
endif ()
97
97
98
98
set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_PREV} )
99
+ elseif (APPLE )
100
+ if (GGML_NATIVE )
101
+ set (USER_PROVIDED_MARCH FALSE )
102
+ foreach (flag_var IN ITEMS CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_REQUIRED_FLAGS )
103
+ if ("${${flag_var} }" MATCHES "-march=[a-zA-Z0-9+._-]+" )
104
+ set (USER_PROVIDED_MARCH TRUE )
105
+ break ()
106
+ endif ()
107
+ endforeach ()
108
+
109
+ if (NOT USER_PROVIDED_MARCH )
110
+ set (MARCH_FLAGS "-march=armv8.2a" )
111
+
112
+ check_cxx_source_compiles ("#include <arm_neon.h>\n int main() { int8x16_t _a, _b; int32x4_t _s = vdotq_s32(_s, _a, _b); return 0; }" GGML_COMPILER_SUPPORT_DOTPROD )
113
+ if (GGML_COMPILER_SUPPORT_DOTPROD )
114
+ set (MARCH_FLAGS "${MARCH_FLAGS} +dotprod" )
115
+ add_compile_definitions (__ARM_FEATURE_DOTPROD )
116
+ endif ()
117
+
118
+ set (TEST_I8MM_FLAGS "-march=armv8.2a+i8mm" )
119
+
120
+ set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS} )
121
+ set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${TEST_I8MM_FLAGS} " )
122
+ check_cxx_source_compiles ("#include <arm_neon.h>\n int main() { int8x16_t _a, _b; int32x4_t _s = vmmlaq_s32(_s, _a, _b); return 0; }" GGML_COMPILER_SUPPORT_MATMUL_INT8 )
123
+ if (GGML_COMPILER_SUPPORT_MATMUL_INT8 )
124
+ set (MARCH_FLAGS "${MARCH_FLAGS} +i8mm" )
125
+ add_compile_definitions (__ARM_FEATURE_MATMUL_INT8 )
126
+ endif ()
127
+ set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} )
128
+
129
+ list (APPEND ARCH_FLAGS "${MARCH_FLAGS} " )
130
+ endif ()
131
+ endif ()
99
132
else ()
100
133
check_cxx_compiler_flag (-mfp16-format=ieee COMPILER_SUPPORTS_FP16_FORMAT_I3E )
101
134
if (NOT "${COMPILER_SUPPORTS_FP16_FORMAT_I3E} " STREQUAL "" )
0 commit comments