26#include <rocprofiler-sdk/agent.h>
27#include <rocprofiler-sdk/counters.h>
28#include <rocprofiler-sdk/defines.h>
29#include <rocprofiler-sdk/experimental/thread-trace/trace_decoder.h>
30#include <rocprofiler-sdk/fwd.h>
31#include <rocprofiler-sdk/hsa.h>
32#include <rocprofiler-sdk/internal_threading.h>
34#include "rocprofiler-sdk/cxx/details/mpl.hpp"
39#define ROCPROFILER_CXX_DECLARE_OPERATORS(TYPE) \
40 bool operator==(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
41 bool operator!=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
42 bool operator<(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
43 bool operator>(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
44 bool operator<=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure); \
45 bool operator>=(TYPE lhs, TYPE rhs) ROCPROFILER_ATTRIBUTE(pure);
47#define ROCPROFILER_CXX_DEFINE_NE_OPERATOR(TYPE) \
48 inline bool operator!=(TYPE lhs, TYPE rhs) { return !(lhs == rhs); }
50#define ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(TYPE) \
51 inline bool operator==(TYPE lhs, TYPE rhs) \
53 return ::rocprofiler::sdk::operators::equal(lhs, rhs); \
56#define ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(TYPE) \
57 inline bool operator<(TYPE lhs, TYPE rhs) \
59 return ::rocprofiler::sdk::operators::less(lhs, rhs); \
62#define ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(TYPE) \
63 inline bool operator>(TYPE lhs, TYPE rhs) { return !(lhs == rhs || lhs < rhs); } \
64 inline bool operator<=(TYPE lhs, TYPE rhs) { return (lhs == rhs || lhs < rhs); } \
65 inline bool operator>=(TYPE lhs, TYPE rhs) { return !(lhs < rhs); }
75equal(Tp lhs, Tp rhs) ROCPROFILER_ATTRIBUTE(pure);
79less(Tp lhs, Tp rhs) ROCPROFILER_ATTRIBUTE(pure);
85 static_assert(
sizeof(Tp) ==
sizeof(uint64_t),
"error! only for opaque handle types");
86 return lhs.handle == rhs.handle;
93 static_assert(
sizeof(Tp) ==
sizeof(uint64_t),
"error! only for opaque handle types");
94 return lhs.handle < rhs.handle;
102 static constexpr auto is_string_type() noexcept
104 return mpl::is_string_type<mpl::unqualified_identity_t<Tp>>::value;
107 using type = std::conditional_t<is_string_type(), std::string_view, Tp&>;
109 constexpr type operator()(Tp& v)
noexcept
111 if constexpr(is_string_type())
112 return std::string_view{v};
121template <
typename... Tp>
123tie_sv(Tp&... vs)
noexcept
125 return std::make_tuple(detail::sv_trait<Tp>{}(vs)...);
141ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_agent_t)
142ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_signal_t)
143ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_executable_t)
146ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_region_t)
147ROCPROFILER_CXX_DECLARE_OPERATORS(hsa_amd_memory_pool_t)
165ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_agent_t)
166ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_signal_t)
167ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_executable_t)
168ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_region_t)
169ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(hsa_amd_memory_pool_t)
175 return (lhs.
id == rhs.
id);
181 return std::tie(lhs.x, lhs.y, lhs.z) == std::tie(rhs.x, rhs.y, rhs.z);
188 namespace op = ::rocprofiler::sdk::operators;
189 return op::tie_sv(lhs.
id, lhs.instance_size, lhs.name) ==
190 op::tie_sv(rhs.
id, rhs.instance_size, rhs.name);
197 namespace op = ::rocprofiler::sdk::operators;
227 return std::tie(lhs.major, lhs.minor, lhs.patch) == std::tie(rhs.major, rhs.minor, rhs.patch);
246ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_agent_t)
247ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_signal_t)
248ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_executable_t)
251ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_region_t)
252ROCPROFILER_CXX_DEFINE_NE_OPERATOR(hsa_amd_memory_pool_t)
267ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_agent_t)
268ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_signal_t)
269ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_executable_t)
270ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_region_t)
271ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(hsa_amd_memory_pool_t)
278 namespace op = ::rocprofiler::sdk::operators;
279 return op::tie_sv(lhs.
id, lhs.instance_size, lhs.name) <
280 op::tie_sv(rhs.
id, rhs.instance_size, rhs.name);
287 namespace op = ::rocprofiler::sdk::operators;
312 return (lhs.
id < rhs.
id);
318 const auto magnitude = [](
rocprofiler_dim3_t dim_v) {
return dim_v.x * dim_v.y * dim_v.z; };
319 auto lhs_m = magnitude(lhs);
320 auto rhs_m = magnitude(rhs);
322 return (lhs_m == rhs_m) ? std::tie(lhs.x, lhs.y, lhs.z) < std::tie(rhs.x, rhs.y, rhs.z)
329 return std::tie(lhs.major, lhs.minor, lhs.patch) < std::tie(rhs.major, rhs.minor, rhs.patch);
348ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_agent_t)
349ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_signal_t)
350ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_executable_t)
353ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_region_t)
354ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(hsa_amd_memory_pool_t)
360#undef ROCPROFILER_CXX_DECLARE_OPERATORS
361#undef ROCPROFILER_CXX_DEFINE_NE_OPERATOR
362#undef ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR
363#undef ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR
364#undef ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS
rocprofiler_agent_id_t id
Internal opaque identifier.
Stores the properties of an agent (CPU, GPU, etc.)
rocprofiler_counter_dimension_id_t id
Id for this dimension used by rocprofiler_query_record_dimension_position.
(experimental) Details for the dimension, including its size, for a counter record.
Multi-dimensional struct of data used to describe GPU workgroup and grid sizes.
Stores memory address for profiling.
const rocprofiler_counter_dimension_info_t ** dimensions
Array of pointers to dimension info structures, each representing one dimension and the position of t...
const char * dimension_name
Name of the dimension this instance belongs to.
uint64_t size
Size of this structure. Used for versioning and validation.
uint64_t counter_id
Identifier of the counter associated with this instance.
uint64_t dimensions_count
Number of dimensions associated with this instance.
rocprofiler_counter_instance_id_t instance_id
Encoded identifier for the instance, which includes the counter ID and all dimension positions.
unsigned long index
Position (zero-based) of the instance within the specified dimension.
(experimental) Represents metadata about a single dimension of a counter instance.
(experimental) Describes a specific counter instance and its position across multiple dimensions.
(experimental) opaque handle to an internal thread identifier which delivers callbacks for buffers
uint64_t address
Address (code_object_id == 0), or ELF vaddr (code_object_id != 0)
uint64_t code_object_id
Zero if no code object was found.
Handle containing a loaded rocprof-trace-decoder and a decoder state.