latest/source/lib/rocprof-sys-user/rocprofiler-systems/user.h Source File

latest/source/lib/rocprof-sys-user/rocprofiler-systems/user.h Source File#

rocprofiler-systems: latest/source/lib/rocprof-sys-user/rocprofiler-systems/user.h Source File
user.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2022-2024 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 ROCPROFSYS_USER_H_
24 #define ROCPROFSYS_USER_H_
25 
26 #if defined(ROCPROFSYS_USER_SOURCE) && (ROCPROFSYS_USER_SOURCE > 0)
27 # if !defined(ROCPROFSYS_PUBLIC_API)
28 # define ROCPROFSYS_PUBLIC_API __attribute__((visibility("default")))
29 # endif
30 #else
31 # if !defined(ROCPROFSYS_PUBLIC_API)
32 # define ROCPROFSYS_PUBLIC_API
33 # endif
34 #endif
35 
38 
39 #if defined(__cplusplus)
40 extern "C"
41 {
42 #endif
43 
44  /// @fn int rocprofsys_user_start_trace(void)
45  /// @return rocprofsys_user_error_t value
46  /// @brief Enable tracing on this thread and all subsequently created threads
47  extern int rocprofsys_user_start_trace(void) ROCPROFSYS_PUBLIC_API;
48 
49  /// @fn int rocprofsys_user_stop_trace(void)
50  /// @return rocprofsys_user_error_t value
51  /// @brief Disable tracing on this thread and all subsequently created threads
52  extern int rocprofsys_user_stop_trace(void) ROCPROFSYS_PUBLIC_API;
53 
54  /// @fn int rocprofsys_user_start_thread_trace(void)
55  /// @return rocprofsys_user_error_t value
56  /// @brief Enable tracing on this specific thread. Does not apply to subsequently
57  /// created threads
58  extern int rocprofsys_user_start_thread_trace(void) ROCPROFSYS_PUBLIC_API;
59 
60  /// @fn int rocprofsys_user_stop_thread_trace(void)
61  /// @return rocprofsys_user_error_t value
62  /// @brief Disable tracing on this specific thread. Does not apply to subsequently
63  /// created threads
64  extern int rocprofsys_user_stop_thread_trace(void) ROCPROFSYS_PUBLIC_API;
65 
66  /// @fn int rocprofsys_user_push_region(const char* id)
67  /// @param id The string identifier for the region
68  /// @return rocprofsys_user_error_t value
69  /// @brief Start a user defined region.
70  extern int rocprofsys_user_push_region(const char*) ROCPROFSYS_PUBLIC_API;
71 
72  /// @fn int rocprofsys_user_pop_region(const char* id)
73  /// @param id The string identifier for the region
74  /// @return rocprofsys_user_error_t value
75  /// @brief End a user defined region. In general, user regions should be popped in
76  /// the inverse order that they were pushed, i.e. first-in, last-out (FILO). The
77  /// timemory backend was designed to accommodate asynchronous tasking, where FILO may
78  /// be violated, and will thus compenstate for out-of-order popping, however, the
79  /// perfetto backend will not; thus, out-of-order popping will result in different
80  /// results in timemory vs. perfetto.
81  extern int rocprofsys_user_pop_region(const char*) ROCPROFSYS_PUBLIC_API;
82 
83  /// @typedef rocprofsys_annotation rocprofsys_annotation_t
84  ///
85  /// @fn int rocprofsys_user_push_annotated_region(const char* id,
86  /// rocprofsys_annotation_t* annotations,
87  /// size_t num_annotations)
88  /// @param id The string identifier for the region
89  /// @param annotations Array of @ref rocprofsys_annotation instances
90  /// @param num_annotations Number of annotations
91  /// @return rocprofsys_user_error_t value
92  /// @brief Start a user defined region and adds the annotations to the perfetto trace.
93  extern int rocprofsys_user_push_annotated_region(const char*,
95  size_t) ROCPROFSYS_PUBLIC_API;
96 
97  /// @fn int rocprofsys_user_pop_annotated_region(const char* id,
98  /// rocprofsys_annotation_t* annotations,
99  /// size_t num_annotations)
100  /// @param id The string identifier for the region
101  /// @param annotations Array of @ref rocprofsys_annotation instances
102  /// @param num_annotations Number of annotations
103  /// @return rocprofsys_user_error_t value
104  /// @brief Stop a user defined region and adds the annotations to the perfetto trace.
106  size_t) ROCPROFSYS_PUBLIC_API;
107 
108  /// mark causal progress
109  extern int rocprofsys_user_progress(const char*) ROCPROFSYS_PUBLIC_API;
110 
111  /// mark causal progress with annotations
113  size_t) ROCPROFSYS_PUBLIC_API;
114 
115  /// @fn int rocprofsys_user_configure(rocprofsys_user_configure_mode_t mode,
116  /// rocprofsys_user_callbacks_t inp,
117  /// rocprofsys_user_callbacks_t* out)
118  /// @param[in] mode Specifies how the new callbacks are merged with the old
119  /// callbacks
120  /// @param[in] inp An @ref rocprofsys_user_callbacks instance specifying
121  /// the callbacks which should be invoked by the user API.
122  /// @param[out] out Pointer to @ref rocprofsys_user_callbacks which,
123  /// when non-NULL, will be assigned the former callbacks.
124  /// @return rocprofsys_user_error_t value
125  /// @brief Configure the function pointers invoked by the rocprof-sys user API.
126  /// The initial callbacks are set via the rocprof-sys-dl library when it is loaded but
127  /// the user can user this feature to turn on/off the user API or customize how the
128  /// the user callbacks occur. For example, the user could maintain one set of
129  /// callbacks which discard any annotation data or redirect all unannotated user
130  /// regions to the annotated user regions with annotations about some global state.
131  /// Changing the callbacks is thread-safe but not thread-local.
134  rocprofsys_user_callbacks_t* out) ROCPROFSYS_PUBLIC_API;
135 
136  /// @fn int rocprofsys_user_get_callbacks(int category, void** begin_func, void**
137  /// end_func)
138  /// @param[in] category An @ref ROCPROFSYS_USER_BINDINGS value
139  /// @param[out] begin_func The pointer to the function which corresponds to "starting"
140  /// the category, e.g. rocprofsys_user_start_trace or rocprofsys_user_push_region
141  /// @param[out] end_func The pointer to the function which corresponds to "ending" the
142  /// category, e.g. rocprofsys_user_stop_trace or rocprofsys_user_pop_region
143  /// @return rocprofsys_user_error_t value
144  /// @brief Get the current function pointers for a given category. The initial values
145  /// are assigned by rocprof-sys-dl at start up.
147  ROCPROFSYS_PUBLIC_API;
148 
149  /// @fn const char* rocprofsys_user_error_string(int error_category)
150  /// @param error_category ROCPROFSYS_USER_ERROR value
151  /// @return String descripting the error code
152  /// @brief Return a descriptor for the provided error code
153  extern const char* rocprofsys_user_error_string(int) ROCPROFSYS_PUBLIC_API;
154 
155 #if defined(__cplusplus)
156 }
157 #endif
158 
159 #endif // ROCPROFSYS_USER_H_
A struct containing annotation data to be included in the perfetto trace.
Definition: categories.h:178
enum ROCPROFSYS_USER_CONFIGURE_MODE rocprofsys_user_configure_mode_t
Struct containing the callbacks for the user API.
Definition: types.h:45
const char * rocprofsys_user_error_string(int)
Return a descriptor for the provided error code.
int rocprofsys_user_pop_annotated_region(const char *, rocprofsys_annotation_t *, unsigned long)
int rocprofsys_user_start_thread_trace(void)
Enable tracing on this specific thread. Does not apply to subsequently created threads.
int rocprofsys_user_stop_thread_trace(void)
Disable tracing on this specific thread. Does not apply to subsequently created threads.
int rocprofsys_user_get_callbacks(rocprofsys_user_callbacks_t *)
int rocprofsys_user_annotated_progress(const char *, rocprofsys_annotation_t *, unsigned long)
mark causal progress with annotations
int rocprofsys_user_push_region(const char *)
Start a user defined region.
int rocprofsys_user_configure(rocprofsys_user_configure_mode_t mode, rocprofsys_user_callbacks_t inp, rocprofsys_user_callbacks_t *out)
Configure the function pointers invoked by the rocprof-sys user API. The initial callbacks are set vi...
int rocprofsys_user_push_annotated_region(const char *, rocprofsys_annotation_t *, unsigned long)
int rocprofsys_user_progress(const char *)
mark causal progress
int rocprofsys_user_pop_region(const char *)
End a user defined region. In general, user regions should be popped in the inverse order that they w...
int rocprofsys_user_stop_trace(void)
Disable tracing on this thread and all subsequently created threads.
int rocprofsys_user_start_trace(void)
Enable tracing on this thread and all subsequently created threads.