Skip to content

Commit 1ee8d72

Browse files
committed
Add compile option soc type macro ASCEND_310P to ggml-cann lib
1 parent 6327369 commit 1ee8d72

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ggml/src/ggml-cann/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ if (CANN_INSTALL_DIR)
3939
target_include_directories(ggml-cann PRIVATE . .. ${CANN_INCLUDE_DIRS})
4040
target_link_directories(ggml-cann PRIVATE ${CANN_INSTALL_DIR}/lib64)
4141

42+
# set define macro for the special soc type, as function of some ascend kernel is different for different soc type.
43+
set(SOC_VERSION "")
44+
if(NOT SOC_TYPE)
45+
detect_ascend_soc_type(SOC_VERSION)
46+
set(SOC_TYPE "${SOC_VERSION}")
47+
endif()
48+
string(TOLOWER ${SOC_TYPE} SOC_VERSION)
49+
string(FIND "${SOC_VERSION}" "ascend310p" FIRST_310P_INDEX)
50+
if(FIRST_310P_INDEX GREATER -1)
51+
#add_compile_definitions(ASCEND_310P)
52+
target_compile_definitions(ggml-cann PRIVATE ASCEND_310P)
53+
endif()
54+
message(STATUS "CANN: Compile llama.cpp with ${SOC_TYPE}.")
55+
4256
message(STATUS "CANN: CANN_INCLUDE_DIRS = ${CANN_INCLUDE_DIRS}")
4357
message(STATUS "CANN: CANN_LIBRARIES = ${CANN_LIBRARIES}")
4458
else()

ggml/src/ggml-cann/kernels/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(SOC_VERSION "")
33
function(detect_ascend_soc_type SOC_VERSION)
44
execute_process(
5-
COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
5+
COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
66
OUTPUT_VARIABLE npu_info
77
RESULT_VARIABLE npu_result
88
OUTPUT_STRIP_TRAILING_WHITESPACE

0 commit comments

Comments
 (0)