develop/projects/rocprofiler-systems/source/lib/rocprof-sys-causal-api/rocprofiler-systems/causal_api.h Source File

develop/projects/rocprofiler-systems/source/lib/rocprof-sys-causal-api/rocprofiler-systems/causal_api.h Source File#

rocprofiler-systems: develop/projects/rocprofiler-systems/source/lib/rocprof-sys-causal-api/rocprofiler-systems/causal_api.h Source File
causal_api.h
Go to the documentation of this file.
1 // Copyright (c) Advanced Micro Devices, Inc.
2 // SPDX-License-Identifier: MIT
3 
4 /** @file causal_api.h
5  *
6  * Minimal, near-zero-overhead library backing the ROCPROFSYS_CAUSAL_* macros
7  * (see causal.h). An application links this tiny library directly; every
8  * function is a no-op until librocprof-sys-dl.so is separately preloaded and
9  * registers the real callbacks via rocprofsys_causal_register_callbacks().
10  * This lets causal progress points ship in production code without pulling in
11  * the full profiler backend.
12  *
13  * There is no general-purpose instrumentation API here (that role is now
14  * served by rocprofiler-sdk-roctx) -- only what causal profiling needs.
15  */
16 
17 #ifndef ROCPROFSYS_CAUSAL_API_H_
18 #define ROCPROFSYS_CAUSAL_API_H_
19 
20 #if defined(ROCPROFSYS_CAUSAL_API_SOURCE) && (ROCPROFSYS_CAUSAL_API_SOURCE > 0)
21 # if !defined(ROCPROFSYS_CAUSAL_PUBLIC_API)
22 # define ROCPROFSYS_CAUSAL_PUBLIC_API __attribute__((visibility("default")))
23 # endif
24 #else
25 # if !defined(ROCPROFSYS_CAUSAL_PUBLIC_API)
26 # define ROCPROFSYS_CAUSAL_PUBLIC_API
27 # endif
28 #endif
29 
31 
32 #include <stddef.h>
33 
34 #if defined(__cplusplus)
35 extern "C"
36 {
37 #endif
38 
39  // NOLINTNEXTLINE(modernize-use-using) -- C-style typedef for C ABI compatibility
40  typedef int (*rocprofsys_causal_region_func_t)(const char*);
41  // NOLINTNEXTLINE(modernize-use-using) -- C-style typedef for C ABI compatibility
42  typedef int (*rocprofsys_causal_annotated_func_t)(const char*,
43  rocprofsys_annotation_t*, size_t);
44 
45  /// @struct rocprofsys_causal_callbacks
46  /// @brief Callbacks invoked by the causal API functions below. Registered by
47  /// librocprof-sys-dl when it is preloaded; left null (no-op) otherwise.
48  ///
49  /// @typedef rocprofsys_causal_callbacks rocprofsys_causal_callbacks_t
50  // NOLINTNEXTLINE(modernize-use-using) -- C-style typedef for C ABI compatibility
52  {
58 
59  /// @brief Starts a latency progress point (region of interest) with the given label.
61 
62  /// @brief Ends the latency progress point for the matching label.
64 
65  /// @brief Adds a throughput progress point with the given label.
67 
68  /// @brief Adds a throughput progress point with the given label and annotations.
71 
72  /// @brief Registers the callbacks invoked by the functions above. Called by
73  /// librocprof-sys-dl once it dlopen's this library; not intended for direct use.
76 
77 #if defined(__cplusplus)
78 }
79 #endif
80 
81 #endif // ROCPROFSYS_CAUSAL_API_H_
A struct containing annotation data to be included in the perfetto trace.
Definition: annotation.h:101
struct rocprofsys_causal_callbacks rocprofsys_causal_callbacks_t
#define ROCPROFSYS_CAUSAL_PUBLIC_API
Definition: causal_api.h:26
rocprofsys_causal_annotated_func_t annotated_progress
Definition: causal_api.h:56
int rocprofsys_causal_end(const char *)
Ends the latency progress point for the matching label.
int rocprofsys_causal_progress(const char *)
Adds a throughput progress point with the given label.
void rocprofsys_causal_register_callbacks(rocprofsys_causal_callbacks_t)
Registers the callbacks invoked by the functions above. Called by librocprof-sys-dl once it dlopen's ...
int rocprofsys_causal_begin(const char *)
Starts a latency progress point (region of interest) with the given label.
rocprofsys_causal_region_func_t progress
Definition: causal_api.h:55
int rocprofsys_causal_annotated_progress(const char *, rocprofsys_annotation_t *, unsigned long)
Adds a throughput progress point with the given label and annotations.
int(* rocprofsys_causal_region_func_t)(const char *)
Definition: causal_api.h:40
rocprofsys_causal_region_func_t end
Definition: causal_api.h:54
rocprofsys_causal_region_func_t begin
Definition: causal_api.h:53
int(* rocprofsys_causal_annotated_func_t)(const char *, rocprofsys_annotation_t *, unsigned long)
Definition: causal_api.h:42
Callbacks invoked by the causal API functions below. Registered by librocprof-sys-dl when it is prelo...
Definition: causal_api.h:52