Skip to content

Commit 91720fa

Browse files
author
zhouwg
committed
ggml-hexagon: sync from project kantv(fix a long-term issue which introduced in kantv-ai/kantv#281)
1 parent b172f4a commit 91720fa

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
1111
if(DEFINED HTP_ARCH_VERSION)
1212
if (${HTP_ARCH_VERSION} STREQUAL "v75" OR ${HTP_ARCH_VERSION} STREQUAL "v79")
1313
#works fine on Snapdragon 8Gen3&8Elite with 1.5x - 3x performance gains with the default ggml backend
14-
#set(OPT_FLAG " -O3 -march=armv8.7-a -mcpu=cortex-x1 -mtune=cortex-x1 -flto -D_GNU_SOURCE -fvectorize -ffp-model=fast -fno-finite-math-only")
15-
set(OPT_FLAG " -O3 -march=armv8.7-a -flto -D_GNU_SOURCE -fvectorize -ffp-model=fast -fno-finite-math-only")
14+
set(OPT_FLAG " -O3 -march=armv8.7-a -mcpu=cortex-x1 -mtune=cortex-x1 -ffp-model=fast -fno-finite-math-only")
1615
message("OPT_FLAG:${OPT_FLAG}")
1716
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGGML_USE_HEXAGON ${DEBUG_FLAG} ${OPT_FLAG}")
1817
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGGML_USE_HEXAGON ${DEBUG_FLAG} ${OPT_FLAG}")

ggml/src/ggml-hexagon/ggml-hexagon.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6134,13 +6134,18 @@ static void ggml_backend_hexagon_device_get_memory(ggml_backend_dev_t dev, size_
61346134
} else if (HEXAGON_BACKEND_QNNNPU == ctx->device) {
61356135
size_t rpc_ion_memsize = 0;
61366136
size_t rpc_ion_usage = 0;
6137-
if (HWACCEL_CDSP != g_hexagon_appcfg.hwaccel_approach) {
6138-
rpc_ion_memsize = ctx->instance->get_rpcmem_capacity();
6139-
rpc_ion_usage = ctx->instance->get_rpcmem_usage();
6140-
} else {
6141-
rpc_ion_memsize = ctx->rpc_mempool_capacity;
6142-
rpc_ion_usage = ctx->rpc_mempool_usage;
6143-
}
6137+
GGML_ASSERT(nullptr != ctx->instance);
6138+
rpc_ion_memsize = ctx->instance->get_rpcmem_capacity();
6139+
rpc_ion_usage = ctx->instance->get_rpcmem_usage();
6140+
*total = rpc_ion_memsize;
6141+
*free = (rpc_ion_memsize - rpc_ion_usage);
6142+
GGMLHEXAGON_LOG_DEBUG("rpc memsize %d MiB", rpc_ion_memsize / SIZE_IN_MB);
6143+
GGMLHEXAGON_LOG_DEBUG("rpc usage %d MiB\n\n", rpc_ion_usage / SIZE_IN_MB);
6144+
} else if (HEXAGON_BACKEND_CDSP == ctx->device) {
6145+
size_t rpc_ion_memsize = 0;
6146+
size_t rpc_ion_usage = 0;
6147+
rpc_ion_memsize = ctx->rpc_mempool_capacity;
6148+
rpc_ion_usage = ctx->rpc_mempool_usage;
61446149
*total = rpc_ion_memsize;
61456150
*free = (rpc_ion_memsize - rpc_ion_usage);
61466151
GGMLHEXAGON_LOG_DEBUG("rpc memsize %d MiB", rpc_ion_memsize / SIZE_IN_MB);

0 commit comments

Comments
 (0)