Skip to content

hexagon: find software divide calls using binary inspection tool - #29449

Merged
max-krasnyansky merged 2 commits into
ggml-org:masterfrom
qualcomm:tr/hex-inspect-bin
Sep 26, 2026
Merged

max-krasnyansky merged 2 commits into
ggml-org:masterfrom
qualcomm:tr/hex-inspect-bin

Conversation

@trivikram-reddy1

Copy link
Copy Markdown
Contributor

Overview

Add --swdiv mode to ggml-hexagon-inspect.py that lists functions calling the Hexagon software divide/modulo helpers. Hexagon has no hardware unit for division, so these calls are expensive, and this mode helps find hot paths that use them.

This PR also adds presets to build HTP skel with DWARF sections needed for hexagon-addr2line to map address to line numbers in src code.

Additional information

Details
$ ./scripts/snapdragon/ggml-hexagon-inspect.py --swdiv --lib pkg-adb/master-dbginfo/lib/libggml-htp-v81.so

Address    | Function                                    | In-Loop | Total | Call Sites
-----------|---------------------------------------------|---------|-------|----------------------------------
0x00093180 | pad_job_per_thread_hvx_circular_dma         |       0 |    21 | +0x260, pad-ops.c:396, pad-ops.c:397, pad-ops.c:414, pad-ops.c:458, pad-ops.c:459
0x00008d20 | op_matmul                                   |       0 |    13 | matmul-ops.c:3777, matmul-ops.c:3780
0x00046fc0 | op_binary                                   |       0 |    11 | binary-ops.c:1181
0x00086d20 | op_cpy                                      |       0 |    11 | cpy-ops.c:511
...
Total functions analyzed: 533 | Reported: 70 | Functions with sw divides: 70 | Total sw divide calls: 258 | In-loop: 0
$ ./scripts/snapdragon/ggml-hexagon-inspect.py --swdiv --inline --func "op_cpy" --lib pkg-adb/master-dbginfo/lib/libggml-htp-v81.so
--------------------------------------------------------------------------------------------------------------
Address    | Function                                 | In-Loop | Total | Call Sites
-----------|------------------------------------------|---------|-------|-------------------------------------
0x00086d20 | op_cpy                                   |       0 |    11 | cpy-ops.c:511
    +0x294   udivdi3  hex-fastdiv.h:22 <- cpy-ops.c:412 <- cpy-ops.c:511
    +0x2c8   udivdi3  hex-fastdiv.h:22 <- cpy-ops.c:413 <- cpy-ops.c:511
    +0x328   umodsi3  hex-common.h:83 <- cpy-ops.c:419 <- cpy-ops.c:511
    +0x338   udivsi3  cpy-ops.c:419 <- cpy-ops.c:511
    +0x484   udivdi3  hex-fastdiv.h:22 <- cpy-ops.c:468 <- cpy-ops.c:511
    ...

Because of LTO and inlining, most divides sit inside helpers several levels below the reported function. In the table above, all 11 divides in op_cpy show up as one line (cpy-ops.c:511). --inline prints one line per call with its full inline chain, innermost frame first and the op code that led to it (whether it is a 32-bit or a much slower 64-bit (udivdi3) divide).

Requirements

@trivikram-reddy1
trivikram-reddy1 requested a review from a team as a code owner September 26, 2026 00:37
@github-actions github-actions Bot added documentation Improvements or additions to documentation ggml changes relating to the ggml tensor library for machine learning Hexagon labels Sep 26, 2026
@max-krasnyansky

Copy link
Copy Markdown
Member

@lhez for second ack

@max-krasnyansky
max-krasnyansky merged commit 4e74811 into ggml-org:master Sep 26, 2026
30 of 34 checks passed
sky-mighty pushed a commit to sky-mighty/llama.cpp that referenced this pull request Sep 26, 2026
…l-org#29449)

* hex-scripts: fix table alignment

* hex-scripts: find sw div calls using binary inspection tool
@trivikram-reddy1
trivikram-reddy1 deleted the tr/hex-inspect-bin branch September 28, 2026 21:00
pierreguillot pushed a commit to Ircam-Partiels/llama.cpp that referenced this pull request Oct 1, 2026
…l-org#29449)

* hex-scripts: fix table alignment

* hex-scripts: find sw div calls using binary inspection tool
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
…l-org#29449)

* hex-scripts: fix table alignment

* hex-scripts: find sw div calls using binary inspection tool
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 7, 2026
…l-org#29449)

* hex-scripts: fix table alignment

* hex-scripts: find sw div calls using binary inspection tool

(cherry picked from commit 4e74811)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation ggml changes relating to the ggml tensor library for machine learning Hexagon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants