Skip to content

Commit c97d7a0

Browse files
author
zhouwg
committed
ggml-hexagon: merge build logic in kernels/Makefile to ggml-hexagon/CMakeLists.txt and remove Makefile
1 parent 7fde87c commit c97d7a0

File tree

5 files changed

+23
-32
lines changed

5 files changed

+23
-32
lines changed

ggml/src/ggml-hexagon/CMakeLists.txt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ message("QNN_SDK_PATH : ${QNN_SDK_PATH}")
1717
message("HEXAGON_SDK_PATH: ${HEXAGON_SDK_PATH}")
1818
message("HTP_ARCH_VERSION: ${HTP_ARCH_VERSION}")
1919

20+
#v68 --- Snapdragon 888
21+
#v69 --- Snapdragon 8 Gen1
22+
#v73 --- Snapdragon 8 Gen2
23+
#v75 --- Snapdragon 8 Gen3
24+
#v79 --- Snapdragon 8 Elite(aka Gen4)
25+
if(NOT DEFINED HTP_ARCH_VERSION)
26+
#set default HTP_ARCH_VERSION to v75
27+
set(HTP_ARCH_VERSION v75)
28+
endif()
29+
30+
#cross compiling for hexagon kernels on cDSP side
31+
set(HEXAGON_CC "${HEXAGON_SDK_PATH}/tools/HEXAGON_Tools/8.8.06/Tools/bin/hexagon-clang")
32+
set(HEXAGON_CXX "${HEXAGON_SDK_PATH}/tools/HEXAGON_Tools/8.8.06/Tools/bin/hexagon-clang")
33+
set(HEXAGON_TARGET libggmlop_skel${HTP_ARCH_VERSION}.so)
34+
set(HEXAGON_KERNELS_PATH "${CMAKE_CURRENT_LIST_DIR}/kernels")
35+
2036
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
2137
find_library(LOG_LIB log)
2238

@@ -67,10 +83,10 @@ function(ggml_hexagon_build_kernel KNAME)
6783
TARGET ${PROJECT_NAME}
6884
POST_BUILD
6985
COMMAND echo "current working path:`pwd`\n"
70-
COMMAND echo "${CMAKE_CURRENT_LIST_DIR}/kernels"
71-
COMMAND make -C ${CMAKE_CURRENT_LIST_DIR}/kernels/ clean
72-
COMMAND make -C ${CMAKE_CURRENT_LIST_DIR}/kernels/ HEXAGON_SDK_PATH=${HEXAGON_SDK_PATH} HTP_ARCH_VERSION=${HTP_ARCH_VERSION}
73-
COMMAND echo "`pwd`"
86+
COMMAND ${HEXAGON_CC} -o ${HEXAGON_KERNELS_PATH}/ggml-dsp.o -c ${HEXAGON_KERNELS_PATH}/ggml-dsp.c -m${HTP_ARCH_VERSION} -c -Ofast -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fdata-sections -fpic -D__V_DYNAMIC__ -mhvx -mhvx-length=128B -I${HEXAGON_SDK_PATH}/incs -I${HEXAGON_SDK_PATH}/libs/qprintf/inc -I${HEXAGON_SDK_PATH}/incs/stddef -I${HEXAGON_SDK_PATH}/ipc/fastrpc/incs -I${HEXAGON_SDK_PATH}/ipc/fastrpc/rpcmem/inc -I${HEXAGON_SDK_PATH}/utils/examples -I${HEXAGON_SDK_PATH}/ipc/fastrpc/rtld/ship/inc -I${HEXAGON_SDK_PATH}/libs/atomic/inc -I${HEXAGON_SDK_PATH}/utils/sim_utils/inc
87+
COMMAND ${HEXAGON_CC} -o ${HEXAGON_KERNELS_PATH}/ggmlop_cdsp_skel.o -c ${HEXAGON_KERNELS_PATH}/ggmlop_cdsp_skel.c -m${HTP_ARCH_VERSION} -c -Ofast -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fdata-sections -fpic -D__V_DYNAMIC__ -mhvx -mhvx-length=128B -I${HEXAGON_SDK_PATH}/incs -I${HEXAGON_SDK_PATH}/libs/qprintf/inc -I${HEXAGON_SDK_PATH}/incs/stddef -I${HEXAGON_SDK_PATH}/ipc/fastrpc/incs -I${HEXAGON_SDK_PATH}/ipc/fastrpc/rpcmem/inc -I${HEXAGON_SDK_PATH}/utils/examples -I${HEXAGON_SDK_PATH}/ipc/fastrpc/rtld/ship/inc -I${HEXAGON_SDK_PATH}/libs/atomic/inc -I${HEXAGON_SDK_PATH}/utils/sim_utils/inc
88+
COMMAND ${HEXAGON_CC} -m${HTP_ARCH_VERSION} -Wl,--defsym=ISDB_TRUSTED_FLAG=2 -Wl,--defsym=ISDB_SECURE_FLAG=2 -Wl,--no-threads -fpic -shared -Wl,-Bsymbolic -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=memalign -lc -Wl,-soname=${HEXAGON_TARGET} -o ${HEXAGON_KERNELS_PATH}/${HEXAGON_TARGET} -Wl,--start-group ${HEXAGON_KERNELS_PATH}/ggmlop_cdsp_skel.o ${HEXAGON_KERNELS_PATH}/ggml-dsp.o -Wl,--end-group
89+
COMMAND ls -l ${HEXAGON_KERNELS_PATH}/${HEXAGON_TARGET}
7490
COMMENT "build hexagon-kernel"
7591
)
7692
endfunction()

ggml/src/ggml-hexagon/kernels/Makefile

Lines changed: 0 additions & 25 deletions
This file was deleted.

ggml/src/ggml-hexagon/kernels/ggml-dsp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ static const struct ggml_type_traits type_traits[GGML_TYPE_COUNT] = {
299299
// section-2: ggml-hexagon kernel's internal troubleshooting function
300300
// =================================================================================================
301301
static void ggmlhexagon_log_internal(int level, const char *file, const char *func, int line, const char *format, ...) {
302+
#if !GGMLHEXAGON_DEBUG
302303
return;
304+
#endif
303305
static char s_ggmlhexagon_log_internal_buf[GGMLHEXAGON_LOGBUF_LEN];
304306
va_list args;
305307
va_start(args, format);

ggml/src/ggml-hexagon/kernels/ggml-dsp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern "C" {
5050
#define GGML_FP32_TO_FP16(x) GGML_COMPUTE_FP32_TO_FP16(x)
5151
#define GGML_FP16_TO_FP32(x) ggml_lookup_fp16_to_fp32(x)
5252

53-
#if 0//def NDEBUG
53+
#ifdef NDEBUG
5454
#define GGMLHEXAGON_DEBUG 0
5555
#else
5656
#define GGMLHEXAGON_DEBUG 1

ggml/src/ggml-hexagon/kernels/ggmlop_ap_skel.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,9 @@ static __inline int _stub_method_1(remote_handle64 _handle, uint32_t _mid, uintp
405405
_count_1(_numIn, _numROut, _numInH, _numROutH, (uint32_t*)&(((uint32_t*)_in1)[0]), (uint32_t*)&(((uint32_t*)_in1)[1]), (uint32_t*)&(((uint32_t*)_in1)[5]), (uint32_t*)&(((uint32_t*)_in1)[9]), (uint32_t*)&(((uint32_t*)_in1)[10]), (uint32_t*)&(((uint32_t*)_in1)[26]), SLIM_IFPTR32((char**)&(((uint32_t*)_in1)[27]), (char**)&(((uint64_t*)_in1)[14])), SLIM_IFPTR32((uint32_t*)&(((uint32_t*)_in1)[28]), (uint32_t*)&(((uint32_t*)_in1)[30])));
406406
_count(_numIn, _numROut, _numInH, _numROutH, (uint32_t*)&(((uint32_t*)_rout2)[0]), (uint32_t*)&(((uint32_t*)_rout2)[1]), (uint32_t*)&(((uint32_t*)_rout2)[5]), (uint32_t*)&(((uint32_t*)_rout2)[9]), (uint32_t*)&(((uint32_t*)_rout2)[10]), (uint32_t*)&(((uint32_t*)_rout2)[26]), SLIM_IFPTR32((char**)&(((uint32_t*)_rout2)[27]), (char**)&(((uint64_t*)_rout2)[14])), SLIM_IFPTR32((uint32_t*)&(((uint32_t*)_rout2)[28]), (uint32_t*)&(((uint32_t*)_rout2)[30])));
407407
if(_numIn[0]>=255){
408-
_QAIC_FARF(RUNTIME_ERROR, "ERROR: Unsupported number of input buffers\n");
409408
return AEE_EUNSUPPORTED;
410409
}
411410
if(_numROut[0]>=255){
412-
_QAIC_FARF(RUNTIME_ERROR, "ERROR: Unsupported number of output buffers\n");
413411
return AEE_EUNSUPPORTED;
414412
}
415413
_allocator_init(_al, 0, 0);

0 commit comments

Comments
 (0)