-
Notifications
You must be signed in to change notification settings - Fork 350
Tools: Testbench: Track and print heap usage for modules #10593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -148,6 +148,11 @@ struct testbench_prm { | |||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| struct tb_heap_usage_record { | ||||||||||||||||||||||||||||||||||||||||||||||||
| char *module_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| size_t heap_max; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| extern int debug; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| int tb_decode_enum(struct snd_soc_tplg_enum_control *enum_ctl, char *token); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -169,6 +174,7 @@ int tb_set_up_all_pipelines(struct testbench_prm *tp); | |||||||||||||||||||||||||||||||||||||||||||||||
| int tb_setup(struct sof *sof, struct testbench_prm *tp); | ||||||||||||||||||||||||||||||||||||||||||||||||
| bool tb_is_pipeline_enabled(struct testbench_prm *tp, int pipeline_id); | ||||||||||||||||||||||||||||||||||||||||||||||||
| bool tb_schedule_pipeline_check_state(struct testbench_prm *tp); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| bool tb_schedule_pipeline_check_state(struct testbench_prm *tp); | |
| bool tb_schedule_pipeline_check_state(struct testbench_prm *tp); | |
| /** | |
| * tb_collect_heap_usage - Collect per-module heap usage statistics. | |
| * @tp: Testbench context; must remain valid for the duration of the call. | |
| * @rec: Caller-allocated array of tb_heap_usage_record entries to fill. | |
| * The function writes at most *@count records and does not retain | |
| * a pointer to this array after returning. | |
| * @count: In/out parameter. On entry, *@count specifies the maximum | |
| * number of records that can be written to @rec. On return, | |
| * *@count is set to the number of valid records populated. | |
| * | |
| * Each tb_heap_usage_record describes the heap usage of a single module | |
| * (or module instance). The tb_heap_usage_record::module_name field, if | |
| * non-NULL, points to a NUL-terminated string whose storage is owned by | |
| * the caller or a longer-lived topology object; tb_collect_heap_usage | |
| * does not take ownership, free, or duplicate this string, and it is only | |
| * required to remain valid for the duration of this call. | |
| * | |
| * The tb_heap_usage_record::heap_max field is expressed in bytes and | |
| * represents the maximum (peak/high-water mark) heap usage observed for | |
| * the corresponding module since it was created. | |
| */ |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -240,7 +240,9 @@ static int parse_input_args(int argc, char **argv, struct testbench_prm *tp) | |||||||||
| return ret; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static void test_pipeline_stats(struct testbench_prm *tp, long long delta_t) | ||||||||||
| static void test_pipeline_stats(struct testbench_prm *tp, long long delta_t, | ||||||||||
| struct tb_heap_usage_record *heap_records, | ||||||||||
| int heap_records_count) | ||||||||||
| { | ||||||||||
| long long file_cycles, pipeline_cycles; | ||||||||||
| float pipeline_mcps; | ||||||||||
|
|
@@ -284,22 +286,28 @@ static void test_pipeline_stats(struct testbench_prm *tp, long long delta_t) | |||||||||
| frames_out = n_out / tp->channels_out; | ||||||||||
| printf("Input sample (frame) count: %d (%d)\n", n_in, n_in / tp->channels_in); | ||||||||||
| printf("Output sample (frame) count: %d (%d)\n", n_out, frames_out); | ||||||||||
| if (heap_records_count > 0) { | ||||||||||
| for (i = 0; i < heap_records_count; i++) | ||||||||||
| printf("Heap usage for module %s: %u bytes\n", | ||||||||||
| heap_records[i].module_name, (uint32_t)heap_records[i].heap_max); | ||||||||||
|
Comment on lines
+291
to
+292
|
||||||||||
| printf("Heap usage for module %s: %u bytes\n", | |
| heap_records[i].module_name, (uint32_t)heap_records[i].heap_max); | |
| printf("Heap usage for module %s: %zu bytes\n", | |
| heap_records[i].module_name, heap_records[i].heap_max); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use "%zu" with xt-clang for xtensa. It just prints as zu when run.
singalsu marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -441,4 +441,8 @@ int tb_set_bytes_control(struct testbench_prm *tp, struct tb_ctl *ctl, uint32_t | |||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| void tb_collect_heap_usage(struct testbench_prm *tp, struct tb_heap_usage_record *rec, int *count) | ||||||||||||||
| { | ||||||||||||||
|
||||||||||||||
| { | |
| { | |
| (void)tp; | |
| (void)rec; | |
| *count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a new cross-file API (
tb_collect_heap_usage) and data contract (tb_heap_usage_record) but doesn’t document key expectations (e.g.,module_nameownership/lifetime, whetherheap_maxis bytes, and whether it is “peak”/HWM). Adding a short comment block near the struct/function would make the usage clearer and reduce coupling to implementation details.