Skip to content

Commit 1c66c4d

Browse files
committed
fixed bugs in ggml-hexagon
1 parent c25a377 commit 1c66c4d

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

CMakeLists.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ set(CMAKE_WARN_UNUSED_CLI YES)
77

88
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
99

10-
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
11-
if(DEFINED HTP_ARCH_VERSION AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
12-
if (${HTP_ARCH_VERSION} STREQUAL "v75" OR ${HTP_ARCH_VERSION} STREQUAL "v79")
13-
#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 -ffp-model=fast -fno-finite-math-only")
15-
16-
# this set of flag is more general (without the cortex cpu optimisation, which is only available on very very modern archs)
17-
set(OPT_FLAG " -O3 -flto -D_GNU_SOURCE -fvectorize -ffp-model=fast -fno-finite-math-only")
18-
19-
message("OPT_FLAG:${OPT_FLAG}")
20-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBUG_FLAG} ${OPT_FLAG}")
21-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAG} ${OPT_FLAG}")
22-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${DEBUG_FLAG} ${OPT_FLAG}")
23-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DEBUG_FLAG} ${OPT_FLAG}")
24-
endif()
25-
endif()
26-
endif()
27-
2810
if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
2911
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
3012
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static inline void hex_format_op_names(char * str, const struct ggml_tensor * t)
211211
// ** backend sessions
212212

213213
struct ggml_hexagon_session {
214-
ggml_hexagon_session(int dev_id) noexcept(false);
214+
ggml_hexagon_session(int dev_id, ggml_backend_dev_t dev) noexcept(false);
215215
~ggml_hexagon_session() noexcept(true);
216216

217217
void allocate(int dev_id) noexcept(false);
@@ -1631,10 +1631,13 @@ void ggml_hexagon_session::release() noexcept(true) {
16311631
}
16321632
}
16331633

1634-
ggml_hexagon_session::ggml_hexagon_session(int dev_id) noexcept(false) {
1634+
ggml_hexagon_session::ggml_hexagon_session(int dev_id, ggml_backend_dev_t dev) noexcept(false) {
16351635
buffer_type.context = nullptr;
16361636
repack_buffer_type.context = nullptr;
16371637

1638+
buffer_type.device = dev;
1639+
repack_buffer_type.device = dev;
1640+
16381641
try {
16391642
allocate(dev_id);
16401643

@@ -3628,7 +3631,7 @@ ggml_hexagon_registry::ggml_hexagon_registry(ggml_backend_reg_t reg) {
36283631
devices[i].iface = ggml_backend_hexagon_device_i;
36293632
devices[i].reg = reg;
36303633
try {
3631-
devices[i].context = new ggml_hexagon_session(i);
3634+
devices[i].context = new ggml_hexagon_session(i, &devices[i]);
36323635
} catch (std::exception const &exc) {
36333636
GGML_LOG_ERROR("ggml-hex: failed to create device/session %zu\n", i);
36343637
devices[i].context = nullptr;

0 commit comments

Comments
 (0)