Add compile option soc type macro ASCEND_310P to ggml-cann lib
This commit is contained in:
parent
63273690b5
commit
1ee8d721bd
2 changed files with 15 additions and 1 deletions
|
@ -39,6 +39,20 @@ if (CANN_INSTALL_DIR)
|
||||||
target_include_directories(ggml-cann PRIVATE . .. ${CANN_INCLUDE_DIRS})
|
target_include_directories(ggml-cann PRIVATE . .. ${CANN_INCLUDE_DIRS})
|
||||||
target_link_directories(ggml-cann PRIVATE ${CANN_INSTALL_DIR}/lib64)
|
target_link_directories(ggml-cann PRIVATE ${CANN_INSTALL_DIR}/lib64)
|
||||||
|
|
||||||
|
# set define macro for the special soc type, as function of some ascend kernel is different for different soc type.
|
||||||
|
set(SOC_VERSION "")
|
||||||
|
if(NOT SOC_TYPE)
|
||||||
|
detect_ascend_soc_type(SOC_VERSION)
|
||||||
|
set(SOC_TYPE "${SOC_VERSION}")
|
||||||
|
endif()
|
||||||
|
string(TOLOWER ${SOC_TYPE} SOC_VERSION)
|
||||||
|
string(FIND "${SOC_VERSION}" "ascend310p" FIRST_310P_INDEX)
|
||||||
|
if(FIRST_310P_INDEX GREATER -1)
|
||||||
|
#add_compile_definitions(ASCEND_310P)
|
||||||
|
target_compile_definitions(ggml-cann PRIVATE ASCEND_310P)
|
||||||
|
endif()
|
||||||
|
message(STATUS "CANN: Compile llama.cpp with ${SOC_TYPE}.")
|
||||||
|
|
||||||
message(STATUS "CANN: CANN_INCLUDE_DIRS = ${CANN_INCLUDE_DIRS}")
|
message(STATUS "CANN: CANN_INCLUDE_DIRS = ${CANN_INCLUDE_DIRS}")
|
||||||
message(STATUS "CANN: CANN_LIBRARIES = ${CANN_LIBRARIES}")
|
message(STATUS "CANN: CANN_LIBRARIES = ${CANN_LIBRARIES}")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set(SOC_VERSION "")
|
set(SOC_VERSION "")
|
||||||
function(detect_ascend_soc_type SOC_VERSION)
|
function(detect_ascend_soc_type SOC_VERSION)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
|
COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
|
||||||
OUTPUT_VARIABLE npu_info
|
OUTPUT_VARIABLE npu_info
|
||||||
RESULT_VARIABLE npu_result
|
RESULT_VARIABLE npu_result
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue