From 4cc80354ee5ce708f65f0a0b5279e4754f7a6398 Mon Sep 17 00:00:00 2001 From: co-seven Date: Fri, 27 Nov 2026 03:23:30 +0000 Subject: [PATCH] ggml-spacemit : flush worker profiling buffers on graph completion Assisted-by: Codex --- ggml/include/ggml-profile.h | 2 +- ggml/src/ggml-spacemit/ggml-spacemit.cpp | 2 ++ ggml/src/ggml-spacemit/ime.cpp | 4 ---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ggml/include/ggml-profile.h b/ggml/include/ggml-profile.h index 20aa5e16239a..da033393fcf9 100644 --- a/ggml/include/ggml-profile.h +++ b/ggml/include/ggml-profile.h @@ -18,7 +18,7 @@ GGML_API void ggml_profile_log_op_begin(struct ggml_tensor * tensor, int ith, in GGML_API void ggml_profile_log_op_end(struct ggml_tensor * tensor, int ith, int nth); GGML_API void ggml_profile_log_spacemit_op_begin(struct ggml_tensor * tensor, int ith, int nth); GGML_API void ggml_profile_log_spacemit_op_end(struct ggml_tensor * tensor, int ith, int nth); -void ggml_profile_flush_tls(void); +GGML_API void ggml_profile_flush_tls(void); #else #define g_current_token_idx 0 #define ggml_profile_init_trace_file() ((void) 0) diff --git a/ggml/src/ggml-spacemit/ggml-spacemit.cpp b/ggml/src/ggml-spacemit/ggml-spacemit.cpp index a1c253350d32..5ec33f44b2ea 100644 --- a/ggml/src/ggml-spacemit/ggml-spacemit.cpp +++ b/ggml/src/ggml-spacemit/ggml-spacemit.cpp @@ -671,6 +671,8 @@ static ggml_status ggml_backend_spacemit_graph_compute(ggml_backend_t backend, g ctx.sync(); } + // Flush each worker before returning to the runtime pool. + ggml_profile_flush_tls(); ctx.clear(); } ); diff --git a/ggml/src/ggml-spacemit/ime.cpp b/ggml/src/ggml-spacemit/ime.cpp index 493c989d4ccf..a1f95206e45a 100644 --- a/ggml/src/ggml-spacemit/ime.cpp +++ b/ggml/src/ggml-spacemit/ime.cpp @@ -1860,10 +1860,6 @@ class tensor_traits_f16 : public ggml::spacemit::tensor_traits_base { const int ith = ctx.ith; const int nth = ctx.nth; - if (ith == 0 && getenv("GGML_SPACEMIT_Q41_TRACE") != nullptr) { - fprintf(stderr, "q41_mul_mat: N=%zu M=%zu K=%zu (%s)\n", N, M, K, M == 1 ? "decode" : "prefill"); - } - const size_t out_row_stride = dst->nb[1]; // bytes constexpr size_t m_tile = F16_M_TILE;