diff options
author | Kawrakow <iwankawrakow@gmail.com> | 2025-03-01 17:12:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-01 17:12:58 +0200 |
commit | ef9a3d17b52bb5f6d55f7ef7e05e41e22f2ad81d (patch) | |
tree | 71f9641da80b64a24c5db2fe5624b9942bb9a06c | |
parent | a79ab8f34222e1e0142a30eaa97e78ad077abca9 (diff) |
A better way to measure the cost of ggml_barrier (#238)
Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
-rw-r--r-- | ggml/src/ggml.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 91c0c5db..7ba5e1ad 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -21459,14 +21459,26 @@ static thread_ret_t ggml_graph_compute_thread(void * data) { /*.shared=*/ state->shared, }; +#if IK_PRINT_TIMING + int64_t t_start = ggml_time_us(); + int64_t t_eval = 0; +#endif + for (int node_n = 0; node_n < cgraph->n_nodes; node_n++) { struct ggml_tensor * node = cgraph->nodes[node_n]; if (ggml_is_noop(node)) continue; +#if IK_PRINT_TIMING + int64_t tim1 = ggml_time_us(); +#endif if (ggml_compute_forward(¶ms, node, node_n < cgraph->n_nodes-1 ? cgraph->nodes[node_n+1] : NULL)) { ++node_n; } +#if IK_PRINT_TIMING + int64_t tim2 = ggml_time_us(); + t_eval += tim2 - tim1; +#endif if (state->ith == 0 && cplan->abort_callback && cplan->abort_callback(cplan->abort_callback_data)) { state->shared->ec = GGML_STATUS_ABORTED; @@ -21478,6 +21490,10 @@ static thread_ret_t ggml_graph_compute_thread(void * data) { break; } } +#if IK_PRINT_TIMING + int64_t t_end = ggml_time_us(); + if (state->ith == 0) printf("ggml_barrier(...): %d us\n", (int)(t_end - t_start - t_eval)); +#endif return 0; } |