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)
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 
265 int32_t appPerfStatsInit();
266 
274 
282 int32_t appPerfStatsCpuLoadReset(uint32_t app_cpu_id);
283 
292 int32_t appPerfStatsCpuLoadGet(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load);
293 
304 int32_t appPerfStatsCpuTaskStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
305 
316 int32_t appPerfStatsCpuTaskStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
317 
328 int32_t appPerfStatsCpuTaskStacksStatsGet(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
329 
340 int32_t appPerfStatsCpuTaskStacksStatsPrint(uint32_t app_cpu_id, app_perf_stats_task_stats_t *cpu_stats);
341 
352 int32_t appPerfStatsCpuMemStatsGet(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats);
353 
364 int32_t appPerfStatsCpuMemStatsPrint(uint32_t app_cpu_id, app_perf_stats_mem_stats_t *cpu_stats);
365 
376 int32_t appPerfStatsCpuLoadPrint(uint32_t app_cpu_id, app_perf_stats_cpu_load_t *cpu_load);
377 
386 
397 int32_t appPerfStatsCpuOsStatsGet(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats);
398 
410 int32_t appPerfStatsCpuOsStatsPrint(uint32_t app_cpu_id, app_perf_stats_os_stats_t *os_stats, uint32_t showPeak);
411 
420 
421 
430 
431 
439 int32_t appPerfStatsPrintAll();
440 
450 int32_t appPerfStatsRegisterTask(void *task_handle, const char *name);
451 
459 int32_t appPerfStatsDeInit();
460 
461 
470 void appPerfPointSetName(app_perf_point_t *prm, const char *name);
471 
478 
485 
486 
493 
494 
501 
502 
509 
516 FILE *appPerfStatsExportOpenFile(const char *output_file_path, const char *output_file_prefix);
517 
527 int32_t appPerfStatsExportAll(FILE *fp, app_perf_point_t *perf_points[], uint32_t num_points);
528 
536 int32_t appPerfStatsExportCloseFile(FILE *fp);
537 
545 void appPerfStatsHwaUpdateLoad(app_perf_hwa_id_t id, uint32_t active_time_in_usecs, uint32_t pixels_processed);
546 
557 int32_t appPerfStatsHwaStatsGet(uint32_t app_cpu_id, app_perf_stats_hwa_stats_t *hwa_stats);
558 
569 
578 
587 
588 
597 
598 
609 
620 
629 
638 
646 void appPerfStatsResetAll();
647 
648 /* @} */
649 
650 #ifdef __cplusplus
651 }
652 #endif
653 
654 #endif
#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
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 num_tasks
Definition: app_perf_stats.h:178
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
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:221
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
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 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
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:157
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.
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
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