Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eba92d6

Browse filesBrowse files
cmake : fix PowerPC build (ggml-org#12241)
Closes ggml-org#12240
1 parent d9a1452 commit eba92d6
Copy full SHA for eba92d6

File tree

Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed

‎ggml/src/ggml-cpu/CMakeLists.txt

Copy file name to clipboardExpand all lines: ggml/src/ggml-cpu/CMakeLists.txt
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,25 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
287287
endif()
288288
endif()
289289
endif()
290-
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
290+
elseif ("${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "ppc64le " OR "${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "powerpc ")
291291
message(STATUS "PowerPC detected")
292-
execute_process(COMMAND bash -c "grep POWER /proc/cpuinfo | head -n 1" OUTPUT_VARIABLE POWER_M)
293-
if (${POWER_M} MATCHES "POWER10")
294-
list(APPEND ARCH_FLAGS -mcpu=power10)
295-
elseif (${POWER_M} MATCHES "POWER9")
296-
list(APPEND ARCH_FLAGS -mcpu=power9)
292+
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
293+
file(READ "/proc/cpuinfo" POWER10_M)
294+
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc")
295+
execute_process(COMMAND bash -c "prtconf |grep 'Implementation' | head -n 1" OUTPUT_VARIABLE POWER10_M)
296+
endif()
297+
298+
string(REGEX MATCHALL "POWER *([0-9]+)" MATCHED_STRING "${POWER10_M}")
299+
string(REGEX REPLACE "POWER *([0-9]+)" "\\1" EXTRACTED_NUMBER "${MATCHED_STRING}")
300+
301+
if (EXTRACTED_NUMBER GREATER_EQUAL 10)
302+
list(APPEND ARCH_FLAGS -mcpu=power10 -mpowerpc64)
303+
elseif (EXTRACTED_NUMBER EQUAL 9)
304+
list(APPEND ARCH_FLAGS -mcpu=power9 -mpowerpc64)
297305
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le")
298306
list(APPEND ARCH_FLAGS -mcpu=powerpc64le -mtune=native)
299307
else()
300-
list(APPEND ARCH_FLAGS -mcpu=powerpc64 -mtune=native)
308+
list(APPEND ARCH_FLAGS -mcpu=native -mtune=native -mpowerpc64)
301309
endif()
302310
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "loongarch64")
303311
message(STATUS "loongarch64 detected")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.