latest/source/lib/omnitrace-user/omnitrace/types.h Source File

latest/source/lib/omnitrace-user/omnitrace/types.h Source File#

omnitrace: latest/source/lib/omnitrace-user/omnitrace/types.h Source File
types.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef OMNITRACE_TYPES_H_
24 #define OMNITRACE_TYPES_H_
25 
26 #include <stddef.h>
27 #include <stdint.h>
28 
29 #if defined(__cplusplus)
30 extern "C"
31 {
32 #endif
33 
34  struct omnitrace_annotation;
35  typedef int (*omnitrace_trace_func_t)(void);
36  typedef int (*omnitrace_region_func_t)(const char*);
38  size_t);
39 
40  /// @struct omnitrace_user_callbacks
41  /// @brief Struct containing the callbacks for the user API
42  ///
43  /// @typedef omnitrace_user_callbacks omnitrace_user_callbacks_t
44  typedef struct omnitrace_user_callbacks
45  {
56 
57  /// @var start_trace
58  /// @brief callback for enabling tracing globally
59  /// @var stop_trace
60  /// @brief callback for disabling tracing globally
61  /// @var start_thread_trace
62  /// @brief callback for enabling tracing on current thread
63  /// @var stop_thread_trace
64  /// @brief callback for disabling tracing on current thread
65  /// @var push_region
66  /// @brief callback for starting a trace region
67  /// @var pop_region
68  /// @brief callback for ending a trace region
69  /// @var progress
70  /// @brief callback for marking an causal profiling event
71  /// @var push_annotated_region
72  /// @brief callback for starting a trace region + annotations
73  /// @var pop_annotated_region
74  /// @brief callback for ending a trace region + annotations
75  /// @var annotated_progress
76  /// @brief callback for marking an causal profiling event + annotations
78 
79  /// @enum OMNITRACE_USER_CONFIGURE_MODE
80  /// @brief Identifier for errors
81  /// @typedef OMNITRACE_USER_CONFIGURE_MODE omnitrace_user_configure_mode_t
83  {
84  // clang-format off
85  OMNITRACE_USER_UNION_CONFIG = 0, ///< Replace the callbacks in the current config with the non-null callbacks in the provided config
86  OMNITRACE_USER_REPLACE_CONFIG, ///< Replace the entire config even if the provided config has null callbacks
87  OMNITRACE_USER_INTERSECT_CONFIG, ///< Produce a config which is the intersection of the current config and the provided config
89  // clang-format on
91 
92  /// @enum OMNITRACE_USER_ERROR
93  /// @brief Identifier for errors
94  /// @typedef OMNITRACE_USER_ERROR omnitrace_user_error_t
95  ///
96  typedef enum OMNITRACE_USER_ERROR
97  {
98  OMNITRACE_USER_SUCCESS = 0, ///< No error
99  OMNITRACE_USER_ERROR_NO_BINDING, ///< Function pointer was not assigned
100  OMNITRACE_USER_ERROR_BAD_VALUE, ///< Provided value was invalid
101  OMNITRACE_USER_ERROR_INVALID_CATEGORY, ///< Invalid user binding category
102  OMNITRACE_USER_ERROR_INTERNAL, ///< Internal error occurred within libomnitrace
105 
106 #if defined(__cplusplus)
107 }
108 #endif
109 
110 #ifndef OMNITRACE_USER_CALLBACKS_INIT
111 # define OMNITRACE_USER_CALLBACKS_INIT \
112  { \
113  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \
114  }
115 #endif
116 
117 #endif // OMNITRACE_TYPES_H_
A struct containing annotation data to be included in the perfetto trace.
Definition: categories.h:178
enum OMNITRACE_USER_ERROR omnitrace_user_error_t
OMNITRACE_USER_CONFIGURE_MODE
Identifier for errors.
Definition: types.h:83
@ OMNITRACE_USER_CONFIGURE_MODE_LAST
Definition: types.h:88
@ OMNITRACE_USER_REPLACE_CONFIG
Replace the entire config even if the provided config has null callbacks.
Definition: types.h:86
@ OMNITRACE_USER_UNION_CONFIG
Replace the callbacks in the current config with the non-null callbacks in the provided config.
Definition: types.h:85
@ OMNITRACE_USER_INTERSECT_CONFIG
Produce a config which is the intersection of the current config and the provided config.
Definition: types.h:87
struct omnitrace_user_callbacks omnitrace_user_callbacks_t
OMNITRACE_USER_ERROR
Identifier for errors.
Definition: types.h:97
@ OMNITRACE_USER_ERROR_LAST
Definition: types.h:103
@ OMNITRACE_USER_SUCCESS
No error.
Definition: types.h:98
@ OMNITRACE_USER_ERROR_INTERNAL
Internal error occurred within libomnitrace.
Definition: types.h:102
@ OMNITRACE_USER_ERROR_INVALID_CATEGORY
Invalid user binding category.
Definition: types.h:101
@ OMNITRACE_USER_ERROR_NO_BINDING
Function pointer was not assigned.
Definition: types.h:99
@ OMNITRACE_USER_ERROR_BAD_VALUE
Provided value was invalid.
Definition: types.h:100
omnitrace_annotated_region_func_t pop_annotated_region
callback for ending a trace region + annotations
Definition: types.h:54
omnitrace_trace_func_t start_thread_trace
callback for enabling tracing on current thread
Definition: types.h:48
omnitrace_trace_func_t stop_thread_trace
callback for disabling tracing on current thread
Definition: types.h:49
omnitrace_annotated_region_func_t annotated_progress
callback for marking an causal profiling event + annotations
Definition: types.h:55
enum OMNITRACE_USER_CONFIGURE_MODE omnitrace_user_configure_mode_t
int(* omnitrace_annotated_region_func_t)(const char *, omnitrace_annotation *, unsigned long)
Definition: types.h:37
omnitrace_trace_func_t stop_trace
callback for disabling tracing globally
Definition: types.h:47
omnitrace_region_func_t push_region
callback for starting a trace region
Definition: types.h:50
omnitrace_trace_func_t start_trace
callback for enabling tracing globally
Definition: types.h:46
int(* omnitrace_region_func_t)(const char *)
Definition: types.h:36
omnitrace_region_func_t pop_region
callback for ending a trace region
Definition: types.h:51
omnitrace_region_func_t progress
callback for marking an causal profiling event
Definition: types.h:52
int(* omnitrace_trace_func_t)(void)
Definition: types.h:35
omnitrace_annotated_region_func_t push_annotated_region
callback for starting a trace region + annotations
Definition: types.h:53
Struct containing the callbacks for the user API.
Definition: types.h:45