Vision Apps User Guide
app_perf_stats.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2019 Texas Instruments Incorporated
4  *
5  * All rights reserved not granted herein.
6  *
7  * Limited License.
8  *
9  * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10  * license under copyrights and patents it now or hereafter owns or controls to make,
11  * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12  * terms herein. With respect to the foregoing patent license, such license is granted
13  * solely to the extent that any such patent is necessary to Utilize the software alone.
14  * The patent license shall not apply to any combinations which include this software,
15  * other than combinations with devices manufactured by or for TI ("TI Devices").
16  * No hardware patent is licensed hereunder.
17  *
18  * Redistributions must preserve existing copyright notices and reproduce this license
19  * (including the above copyright notice and the disclaimer and (if applicable) source
20  * code license limitations below) in the documentation and/or other materials provided
21  * with the distribution
22  *
23  * Redistribution and use in binary form, without modification, are permitted provided
24  * that the following conditions are met:
25  *
26  * * No reverse engineering, decompilation, or disassembly of this software is
27  * permitted with respect to any software provided in binary form.
28  *
29  * * any redistribution and use are licensed by TI for use only with TI Devices.
30  *
31  * * Nothing shall obligate TI to provide you with source code for the software
32  * licensed and provided to you in object code.
33  *
34  * If software source code is provided to you, modification and redistribution of the
35  * source code are permitted provided that the following conditions are met:
36  *
37  * * any redistribution and use of the source code, including any resulting derivative
38  * works, are licensed by TI for use only with TI Devices.
39  *
40  * * any redistribution and use of any object code compiled from the source code
41  * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42  *
43  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44  *
45  * may be used to endorse or promote products derived from this software without
46  * specific prior written permission.
47  *
48  * DISCLAIMER.
49  *
50  * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59  * OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  */
62 
63 #ifndef __APP_PERF_STATS_H__
64 #define __APP_PERF_STATS_H__
65 
66 #include <stdint.h>
67 #include <stdio.h>
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
74 
86 typedef enum {
87 
96  #if defined(SOC_J784S4) || defined(SOC_J742S2)
97  APP_PERF_HWA_VPAC2_VISS,
98  APP_PERF_HWA_VPAC2_LDC,
99  APP_PERF_HWA_VPAC2_NF,
100  APP_PERF_HWA_VPAC2_MSC0,
101  APP_PERF_HWA_VPAC2_MSC1,
102  #endif
104 
106 
107 
109 #define APP_PERF_STATS_TASK_NAME_MAX (12u)
110 
112 #define APP_PERF_STATS_TASK_MAX (24u)
113 
115 #define APP_PERF_POINT_NAME_MAX (16u)
116 
118 #define APP_PERF_POINT_MAX_FILENAME (256u)
119 
121 #define APP_PERF_MAX_LINE_SIZE (1024u)
122 
126 typedef struct {
127 
128  uint32_t cpu_load;
129  uint32_t hwi_load;
130  uint32_t swi_load;
133 
134 
138 typedef struct {
139 
141  uint64_t tmp;
142  uint64_t sum;
143  uint64_t avg;
144  uint64_t min;
145  uint64_t max;
146  uint64_t num;
147 
149 
153 typedef struct {
154 
156  uint32_t task_load;
159 
163 typedef struct {
164 
165  uint32_t num_tasks;
166  uint32_t starting_task;
172 
176 typedef struct {
177 
178  uint32_t num_tasks;
183 
187 typedef struct {
188 
189  uint64_t total_time;
190  uint64_t active_time;
191  uint64_t pixels_processed;
192  uint64_t last_timestamp;
195 
202 typedef struct {
203 
207 
208 
215 typedef struct {
216 
217  uint32_t read_bw_avg;
218  uint32_t write_bw_avg;
219  uint32_t read_bw_peak;
220  uint32_t write_bw_peak;
223  uint32_t counter0_total;
224  uint32_t counter1_total;
225  uint32_t counter2_total;
226  uint32_t counter3_total;
229 
233 typedef struct {
234 
235  uint32_t semaphore_count;
236  uint32_t mutex_count;
237  uint32_t queue_count;
238  uint32_t event_count;
239  uint32_t heap_count;
240  uint32_t mailbox_count;
241  uint32_t task_count;
242  uint32_t clock_count;
243  uint32_t hwi_count;
244  uint32_t timer_count;
246  uint32_t semaphore_peak;
247  uint32_t mutex_peak;
248  uint32_t queue_peak;
249  uint32_t event_peak;
250  uint32_t heap_peak;
251  uint32_t mailbox_peak;
252  uint32_t task_peak;
253  uint32_t clock_peak;
254  uint32_t hwi_peak;
255  uint32_t timer_peak;
258 
262 typedef struct {
263 
264  uint32_t targets_in_cpu;
268 
270 
274 typedef void (*tiovxStats_Fxn) (app_perf_stats_tiovx_stats_t* tiovx_stats);
275 
279 typedef struct {
282 
289 int32_t appPerfStatsInit();
290 
298 
306 
314 int32_t appPerfStatsCpuLoadReset(uint32_t app_cpu_id);
315 
324 int32_t appPerfStatsCpuLoadGet(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load);
325 
336 int32_t appPerfStatsCpuTaskStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
337 
348 int32_t appPerfStatsCpuTaskStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
349 
360 int32_t appPerfStatsCpuTaskStacksStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
361 
372 int32_t appPerfStatsCpuTaskStacksStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
373 
384 int32_t appPerfStatsCpuMemStatsGet(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats);
385 
396 int32_t appPerfStatsCpuMemStatsPrint(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats);
397 
408 int32_t appPerfStatsCpuLoadPrint(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load);
409 
418 
429 int32_t appPerfStatsCpuOsStatsGet(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats);
430 
441 int32_t appPerfStatsCpuTiovxStatsGet(uint32_t app_cpu_id, app_perf_stats_tiovx_stats_t *tiovx_stats);
442 
454 int32_t appPerfStatsCpuOsStatsPrint(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats, uint32_t showPeak);
455 
466 int32_t appPerfStatsCpuTiovxStatsPrint(uint32_t app_cpu_id, app_perf_stats_tiovx_stats_t *tiovx_stats);
467 
476 
477 
486 
487 
495 int32_t appPerfStatsPrintAll();
496 
506 int32_t appPerfStatsRegisterTask(void *task_handle, const char *name);
507 
515 int32_t appPerfStatsDeInit();
516 
517 
526 void appPerfPointSetName(app_perf_point_t *prm, const char *name);
527 
534 
541 
542 
549 
550 
557 
558 
565 
572 FILE *appPerfStatsExportOpenFile(const char *output_file_path, const char *output_file_prefix);
573 
583 int32_t appPerfStatsExportAll(FILE *fp, app_perf_point_t *perf_points[], uint32_t num_points);
584 
592 int32_t appPerfStatsExportCloseFile(FILE *fp);
593 
601 void appPerfStatsHwaUpdateLoad(app_perf_hwa_id_t id, uint32_t active_time_in_usecs, uint32_t pixels_processed);
602 
613 int32_t appPerfStatsHwaStatsGet(uint32_t app_cpu_id, app_perf_stats_hwa_stats_t *hwa_stats);
614 
625 
634 
643 
644 
653 
654 
665 
676 
685 
694 
702 void appPerfStatsResetAll();
703 
704 /* @} */
705 
706 #ifdef __cplusplus
707 }
708 #endif
709 
710 #endif
int32_t appPerfStatsCpuTiovxStatsPrint(uint32_t app_cpu_id, app_perf_stats_tiovx_stats_t *tiovx_stats)
Print CPU TIOVX statistics.
#define APP_PERF_STATS_TASK_MAX
Max number of tasks whoose information can be retrived.
Definition: app_perf_stats.h:112
int32_t appPerfStatsRemoteServiceInit()
Initialize perf statistics collector module.
void appPerfPointSetName(app_perf_point_t *prm, const char *name)
Set name for a performance point.
uint32_t mutex_peak
Definition: app_perf_stats.h:247
int32_t appPerfStatsHwaLoadPrintAll()
Print HWA load statistics for all enabled CPUs.
OS Resource usage information.
Definition: app_perf_stats.h:233
Summary of CPU load.
Definition: app_perf_stats.h:126
uint64_t sum
Definition: app_perf_stats.h:142
Detailed CPU Mem Stats information.
Definition: app_perf_stats.h:176
uint32_t max_targets_per_kernel
Definition: app_perf_stats.h:265
int32_t appPerfStatsExportAll(FILE *fp, app_perf_point_t *perf_points[], uint32_t num_points)
Exports the performance to a .md file.
void appPerfPointPrint(app_perf_point_t *prm)
Print a performance point.
uint32_t target_kernel_max
Definition: app_perf_stats.h:267
uint32_t num_tasks
Definition: app_perf_stats.h:178
TIOVX registration functions.
Definition: app_perf_stats.h:279
int32_t appPerfStatsCpuMemStatsPrint(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats)
Print CPU peformance statistics.
int32_t appPerfStatsDdrStatsPrintAll()
Print DDR BW statistics.
uint32_t write_bw_avg
Definition: app_perf_stats.h:218
uint64_t total_time
Definition: app_perf_stats.h:189
TIOVX resource usage information.
Definition: app_perf_stats.h:262
Definition: app_perf_stats.h:95
Definition: app_perf_stats.h:94
void appPerfPointPrintFPS(app_perf_point_t *prm)
Print a performance point in units of FPS.
uint32_t read_bw_peak
Definition: app_perf_stats.h:219
int32_t appPerfStatsCpuOsStatsGet(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats)
Get CPU OS statistics.
int32_t appPerfStatsRegisterTask(void *task_handle, const char *name)
Register a task for task load calculation.
uint32_t task_peak
Definition: app_perf_stats.h:252
Heap statistics and information.
Definition: app_mem.h:227
uint32_t mailbox_count
Definition: app_perf_stats.h:240
int32_t appPerfStatsCpuLoadGet(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load)
Get CPU peformance statistics.
uint32_t hwi_load
Definition: app_perf_stats.h:129
int32_t appPerfStatsCpuTaskStacksStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats)
Get CPU task stack statistics.
uint32_t starting_task
Definition: app_perf_stats.h:166
#define APP_PERF_STATS_TASK_NAME_MAX
Max size of task name string.
Definition: app_perf_stats.h:109
#define APP_PERF_POINT_NAME_MAX
Max size of performance point name string.
Definition: app_perf_stats.h:115
uint32_t target_kernel_instance_max
Definition: app_perf_stats.h:266
int32_t appPerfStatsCpuTiovxStatsGet(uint32_t app_cpu_id, app_perf_stats_tiovx_stats_t *tiovx_stats)
Get CPU TIOVX target statistics.
CPU task statistics information.
Definition: app_perf_stats.h:153
uint32_t queue_peak
Definition: app_perf_stats.h:248
uint32_t write_bw_peak
Definition: app_perf_stats.h:220
int32_t appPerfStatsHwaLoadResetAll()
Reset HWA load calc for all HWAs.
void appPerfStatsResetAll()
Reset all perf stats.
uint64_t max
Definition: app_perf_stats.h:145
int32_t appPerfStatsInit()
Initialize perf statistics collector module.
void appPerfPointBegin(app_perf_point_t *prm)
Start a performance point.
DDR BW information.
Definition: app_perf_stats.h:215
uint32_t queue_count
Definition: app_perf_stats.h:237
int32_t appPerfStatsDdrStatsResetAll()
Reset DDR BW statistics.
uint32_t counter1_total
Definition: app_perf_stats.h:224
int32_t appPerfStatsExportCloseFile(FILE *fp)
Closes performance file opened by appPerfStatsExportOpenFile.
int32_t appPerfStatsInitRegister(app_perf_registration_t *reg_fxns)
Initialize perf statistics collector module with registration functions.
int32_t appPerfStatsCpuLoadResetAll()
Reset CPU load calc for all enabled CPUs.
uint32_t clock_peak
Definition: app_perf_stats.h:253
uint32_t mutex_count
Definition: app_perf_stats.h:236
int32_t appPerfStatsCpuLoadReset(uint32_t app_cpu_id)
Reset CPU load statistics.
int32_t appPerfStatsCpuStatsPrintAll()
Print CPU peformance statistics for all enabled CPUs.
uint32_t counter0_total
Definition: app_perf_stats.h:223
uint64_t avg
Definition: app_perf_stats.h:143
Definition: app_perf_stats.h:103
tiovxStats_Fxn get_tiovx_stats
Definition: app_perf_stats.h:280
int32_t appPerfStatsPrintAll()
Print all performance related information.
uint32_t event_count
Definition: app_perf_stats.h:238
uint64_t tmp
Definition: app_perf_stats.h:141
uint32_t semaphore_peak
Definition: app_perf_stats.h:246
uint32_t task_load
Definition: app_perf_stats.h:156
int32_t appPerfStatsCpuTaskStacksStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats)
Print CPU task stack statistics.
int32_t appPerfStatsCpuOsStatsPrint(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats, uint32_t showPeak)
Print CPU OS statistics.
uint32_t mailbox_peak
Definition: app_perf_stats.h:251
FILE * appPerfStatsExportOpenFile(const char *output_file_path, const char *output_file_prefix)
Opens a .md file and returns the pointer to application.
uint32_t semaphore_count
Definition: app_perf_stats.h:235
uint32_t task_count
Definition: app_perf_stats.h:241
char * appPerfStatsGetHwaName(app_perf_hwa_id_t hwa_id)
Get HWA name.
uint64_t min
Definition: app_perf_stats.h:144
void appPerfPointReset(app_perf_point_t *prm)
Reset a performance point, MUST be called once before begin/end.
void appPerfStatsHwaUpdateLoad(app_perf_hwa_id_t id, uint32_t active_time_in_usecs, uint32_t pixels_processed)
Update load numbers against a HWA.
Detailed CPU Task Stats information.
Definition: app_perf_stats.h:163
Definition: app_perf_stats.h:91
uint32_t heap_peak
Definition: app_perf_stats.h:250
uint32_t cpu_load
Definition: app_perf_stats.h:128
HWA load information for all HWAs.
Definition: app_perf_stats.h:202
#define APP_MEM_HEAP_MAX
Max heaps in system.
Definition: app_mem.h:159
uint32_t total_available_bw
Definition: app_perf_stats.h:221
uint32_t num_tasks
Definition: app_perf_stats.h:165
int32_t appPerfStatsCpuTaskStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats)
Get CPU peformance statistics.
int32_t appPerfStatsCpuMemStatsGet(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats)
Get Memory statistics.
int32_t appPerfStatsCpuLoadPrintAll()
Print CPU load statistics for all enabled CPUs.
void(* tiovxStats_Fxn)(app_perf_stats_tiovx_stats_t *tiovx_stats)
TIOVX registration function pointer.
Definition: app_perf_stats.h:274
uint32_t swi_load
Definition: app_perf_stats.h:130
Definition: app_perf_stats.h:93
uint32_t counter2_total
Definition: app_perf_stats.h:225
uint32_t targets_in_cpu
Definition: app_perf_stats.h:264
void appPerfPointEnd(app_perf_point_t *prm)
End a performance point.
Definition: app_perf_stats.h:92
uint32_t heap_count
Definition: app_perf_stats.h:239
uint64_t active_time
Definition: app_perf_stats.h:190
uint64_t pixels_processed
Definition: app_perf_stats.h:191
uint32_t read_bw_avg
Definition: app_perf_stats.h:217
Definition: app_perf_stats.h:89
Performance point, all time in units of usecs.
Definition: app_perf_stats.h:138
int32_t appPerfStatsDeInit()
De-Initialize perf statistics collector module.
uint32_t hwi_peak
Definition: app_perf_stats.h:254
int32_t appPerfStatsCpuTaskStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats)
Print CPU peformance statistics.
uint64_t last_timestamp
Definition: app_perf_stats.h:192
uint32_t hwi_count
Definition: app_perf_stats.h:243
int32_t appPerfStatsHwaStatsGet(uint32_t app_cpu_id, app_perf_stats_hwa_stats_t *hwa_stats)
Get HWA peformance statistics.
Definition: app_perf_stats.h:90
uint32_t timer_count
Definition: app_perf_stats.h:244
int32_t appPerfStatsDdrStatsGet(app_perf_stats_ddr_stats_t *ddr_stats)
Get DDR BW statistics.
uint32_t clock_count
Definition: app_perf_stats.h:242
int32_t appPerfStatsCpuLoadPrint(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load)
Print CPU load statistics.
uint32_t event_peak
Definition: app_perf_stats.h:249
Definition: app_perf_stats.h:88
HWA load information.
Definition: app_perf_stats.h:187
uint64_t num
Definition: app_perf_stats.h:146
int32_t appPerfStatsHwaLoadPrint(app_perf_stats_hwa_stats_t *hwa_load)
Print HWA load statistics.
app_perf_hwa_id_t
HWA ID.
Definition: app_perf_stats.h:86
int32_t appPerfStatsDdrStatsPrint(app_perf_stats_ddr_stats_t *ddr_load)
Print DDR BW statistics.
uint32_t counter3_total
Definition: app_perf_stats.h:226
uint32_t timer_peak
Definition: app_perf_stats.h:255