Skip to content

Commit 7e8713d

Browse files
committed
support HUAWEI Kunpeng 920 and add -DWHISPER_ARM_MARCH to let users override march option
1 parent a1867e0 commit 7e8713d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ set(GGML_SANITIZE_UNDEFINED ${WHISPER_SANITIZE_UNDEFINED})
9999
set(GGML_ALL_WARNINGS ${WHISPER_ALL_WARNINGS})
100100
set(GGML_FATAL_WARNINGS ${WHISPER_FATAL_WARNINGS})
101101

102+
# -------------------- KUNPENG / ARM64 friendly defaults --------------------
103+
# This block provides a safe default -march for Huawei Kunpeng 920 (aarch64)
104+
# and allows users to override via -DWHISPER_ARM_MARCH=... when running cmake.
105+
# Kunpeng 920 (ARMv8.2-A) typically supports: dotprod, crc, crypto, fp16
106+
# but does NOT support jscvt / fcma; avoid enabling those.
107+
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
108+
# If user didn't set a custom march, choose a conservative default compatible with Kunpeng 920
109+
if (NOT DEFINED WHISPER_ARM_MARCH)
110+
set(WHISPER_ARM_MARCH "armv8.2-a+dotprod+crc+crypto+fp16fml" CACHE STRING "ARM march to use for building on ARM64 (Kunpeng-friendly default)")
111+
endif()
112+
113+
# Allow opt-out: user can explicitly pass -DWHISPER_ARM_MARCH="native" or other value
114+
if (NOT WHISPER_ARM_MARCH STREQUAL "")
115+
# Only append march flags if they are not already present in CMAKE_C_FLAGS/CXX_FLAGS
116+
string(FIND "${CMAKE_C_FLAGS}" "-march" _found_c)
117+
if (_found_c EQUAL -1)
118+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${WHISPER_ARM_MARCH}")
119+
endif()
120+
string(FIND "${CMAKE_CXX_FLAGS}" "-march" _found_cxx)
121+
if (_found_cxx EQUAL -1)
122+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${WHISPER_ARM_MARCH}")
123+
endif()
124+
125+
endif()
126+
endif()
127+
# ---------------------------------------------------------------------------
128+
102129
# transition helpers
103130
function (whisper_option_depr TYPE OLD NEW)
104131
if (${OLD})

0 commit comments

Comments
 (0)