Skip to content

Commit 415107b

Browse files
committed
support enabling trace from commmand line
1 parent 5e4d730 commit 415107b

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int opt_arch = 0; // autodetect
4848
static int opt_etm = 0;
4949
static int opt_verbose = 0;
5050
static int opt_profile = 0;
51-
static int opt_trace = 1;
51+
static int opt_trace = 0;
5252
static itrace_logger_handle_t g_itrace_logger_handle = NULL;
5353
static itrace_profiler_handle_t g_itrace_cpu_profiler_handle = NULL;
5454
static int opt_hostbuf = 1;
@@ -2901,6 +2901,13 @@ static const char * ggml_backend_hexagon_name(ggml_backend_t backend) {
29012901
}
29022902

29032903
static void ggml_backend_hexagon_free(ggml_backend_t backend) {
2904+
// Flush and close itrace logger if profiling was enabled
2905+
if (opt_trace) {
2906+
itrace_flush_logs(g_itrace_logger_handle);
2907+
itrace_close_logger(g_itrace_logger_handle);
2908+
HEX_VERBOSE("ggml-hex: close itrace\n");
2909+
}
2910+
29042911
// we just need to delete the backend here
29052912
// the sessions are allocated & freed as part of the registry
29062913
delete backend;
@@ -3448,12 +3455,6 @@ ggml_hexagon_registry::~ggml_hexagon_registry() {
34483455
auto sess = static_cast<ggml_hexagon_session *>(devices[i].context);
34493456
delete sess;
34503457
}
3451-
3452-
// Flush and close itrace logger if profiling was enabled
3453-
if (opt_trace) {
3454-
itrace_flush_logs(g_itrace_logger_handle);
3455-
itrace_close_logger(g_itrace_logger_handle);
3456-
}
34573458
}
34583459

34593460
static const char * ggml_backend_hexagon_reg_get_name(ggml_backend_reg_t reg) {
@@ -3501,11 +3502,16 @@ static void ggml_hexagon_init(ggml_backend_reg * reg) {
35013502
opt_profile = getenv("GGML_HEXAGON_PROFILE") != nullptr;
35023503
opt_etm = getenv("GGML_HEXAGON_ETM") != nullptr;
35033504
opt_experimental = getenv("GGML_HEXAGON_EXPERIMENTAL") != nullptr;
3505+
opt_trace = getenv("GGML_HEXAGON_TRACE") != nullptr;
35043506

35053507
// Initialize itrace if profiling is enabled
35063508
if (opt_trace) {
3509+
HEX_VERBOSE("ggml-hex: open itrace\n");
35073510
itrace_open_logger(CPU_DOMAIN_ID, &g_itrace_logger_handle);
35083511
itrace_open_profiler(g_itrace_logger_handle, CPU_DOMAIN_ID, 0, &g_itrace_cpu_profiler_handle);
3512+
3513+
itrace_start_section(g_itrace_cpu_profiler_handle, "open-itrace", NULL);
3514+
itrace_end_section(g_itrace_cpu_profiler_handle, NULL);
35093515
}
35103516

35113517
const char * str_opmask = getenv("GGML_HEXAGON_OPMASK");

scripts/snapdragon/adb/run-cli.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ sched=
3030
profile=
3131
[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1"
3232

33+
trace=
34+
[ "$TRACE" != "" ] && trace="GGML_HEXAGON_TRACE=$TRACE"
35+
3336
opmask=
3437
[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
3538

@@ -45,7 +48,7 @@ adb $adbserial shell " \
4548
cd $basedir; ulimit -c unlimited; \
4649
LD_LIBRARY_PATH=$basedir/$branch/lib \
4750
ADSP_LIBRARY_PATH=$basedir/$branch/lib \
48-
$verbose $experimental $sched $opmask $profile $nhvx $ndev \
51+
$verbose $experimental $sched $opmask $profile $trace $nhvx $ndev \
4952
./$branch/bin/llama-cli --no-mmap -m $basedir/../gguf/$model \
5053
--poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 \
5154
--ctx-size 8192 --batch-size 128 -ctk q8_0 -ctv q8_0 -fa on \

0 commit comments

Comments
 (0)