TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
jtag_profile_functions.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tenstorrent AI ULC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BH_DMFW_APP_JTAG_UGLY_SRC_JTAG_PROFILE_FUNCTIONS_H_
8#define BH_DMFW_APP_JTAG_UGLY_SRC_JTAG_PROFILE_FUNCTIONS_H_
9
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#ifdef CONFIG_JTAG_PROFILE_FUNCTIONS
17
18#define CYCLES_ENTRY() \
19 static struct cycle_cnt __cnt; \
20 uint32_t __cyc = 0; \
21 uint32_t __ops = 0; \
22 \
23 if (!__cnt.func) { \
24 __cyc = k_cycle_get_32(); \
25 __ops = io_ops; \
26 }
27
28#define CYCLES_EXIT() \
29 do { \
30 if (!__cnt.func) { \
31 __cnt.func = __func__; \
32 __cnt.cycles = k_cycle_get_32() - __cyc; \
33 __cnt.io_ops = io_ops - __ops; \
34 printk("%s(): %d: finished in %u ms (%u cycles), %u " \
35 "io_ops\n", \
36 __func__, __LINE__, \
37 __cnt.cycles / (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000), \
38 __cnt.cycles, __cnt.io_ops); \
39 } \
40 } while (0)
41
42/*
43 * In files where I/O ops are counted add the line below.
44 * The reason for that is that I/O ops are counted globally.
45 *
46 * static uint32_t io_ops;
47 */
48#define IO_OPS_INC() io_ops++
49
50#else /* CONFIG_JTAG_PROFILE_FUNCTIONS */
51
52#define CYCLES_ENTRY()
53#define CYCLES_EXIT()
54#define IO_OPS_INC()
55
56#endif /* CONFIG_JTAG_PROFILE_FUNCTIONS */
57
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* BH_DMFW_APP_JTAG_UGLY_SRC_JTAG_PROFILE_FUNCTIONS_H_ */
__UINT32_TYPE__ uint32_t
Definition jtag_profile_functions.h:58
uint32_t io_ops
Definition jtag_profile_functions.h:61
const char * func
Definition jtag_profile_functions.h:59
uint32_t cycles
Definition jtag_profile_functions.h:60