rocprofiler-sdk/cxx/name_info.hpp Source File

rocprofiler-sdk/cxx/name_info.hpp Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/cxx/name_info.hpp Source File
Rocprofiler SDK Developer API 0.5.0
ROCm Profiling API and tools
name_info.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023 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
24#pragma once
25
26#include <rocprofiler-sdk/fwd.h>
28
29#include <string>
30#include <string_view>
31#include <type_traits>
32#include <vector>
33
34namespace rocprofiler
35{
36namespace sdk
37{
38namespace utility
39{
40template <typename EnumT, typename ValueT = std::string_view>
42{
44 using enum_type = EnumT;
45 using value_type = ValueT;
47 using item_type = std::pair<rocprofiler_tracing_operation_t, const value_type*>;
48 using item_array_t = std::vector<item_type>;
49
50 static_assert(support_type::value,
51 "value_type must be supported by rocprofiler::sdk::mpl::string_support");
52
53 return_type operator()() const { return name; }
54 return_type operator()(size_t idx) const { return operations.at(idx); }
55 return_type operator[](size_t idx) const { return operations.at(idx); }
56
57 item_array_t items() const;
58
59 EnumT value = static_cast<EnumT>(0);
61 std::vector<value_type> operations = {};
62};
63
64template <typename EnumT, typename ValueT = std::string_view>
66{
68 using enum_type = EnumT;
71 using item_type = const value_type*;
72 using item_array_t = std::vector<item_type>;
73
74 void emplace(EnumT idx, const char* name);
75 void emplace(EnumT idx, rocprofiler_tracing_operation_t opidx, const char* name);
76
77 return_type at(EnumT idx) const;
78 return_type at(EnumT idx, rocprofiler_tracing_operation_t opidx) const;
79
80 item_array_t items() const;
81
82 decltype(auto) size() const { return impl.size(); }
83 decltype(auto) begin() { return impl.begin(); }
84 decltype(auto) begin() const { return impl.begin(); }
85 decltype(auto) end() { return impl.end(); }
86 decltype(auto) end() const { return impl.end(); }
87
88 value_type& operator[](size_t idx) { return impl.at(idx); }
89 const value_type& operator[](size_t idx) const { return impl.at(idx); }
90
91private:
92 std::vector<value_type> impl = {};
93};
94} // namespace utility
95
96template <typename Tp = std::string_view>
98
99template <typename Tp = std::string_view>
101
104
105template <typename Tp = std::string_view>
108
109template <typename Tp = std::string_view>
112} // namespace sdk
113} // namespace rocprofiler
114
115#define ROCPROFILER_SDK_CXX_NAME_INFO_HPP_ 1
int32_t rocprofiler_tracing_operation_t
Tracing Operation ID. Depending on the kind, operations can be determined. If the value is equal to z...
Definition fwd.h:448
callback_name_info_t< Tp > get_callback_tracing_names()
buffer_name_info_t< Tp > get_buffer_tracing_names()
static constexpr auto value
Definition mpl.hpp:87
return_type operator[](unsigned long idx) const
Definition name_info.hpp:55
typename support_type::return_type return_type
Definition name_info.hpp:46
std::pair< rocprofiler_tracing_operation_t, const value_type * > item_type
Definition name_info.hpp:47
return_type operator()(unsigned long idx) const
Definition name_info.hpp:54
mpl::string_support< ValueT > support_type
Definition name_info.hpp:43
std::vector< value_type > operations
Definition name_info.hpp:61
std::vector< item_type > item_array_t
Definition name_info.hpp:48
std::vector< item_type > item_array_t
Definition name_info.hpp:72
typename value_type::support_type support_type
Definition name_info.hpp:69
value_type & operator[](unsigned long idx)
Definition name_info.hpp:88
typename value_type::return_type return_type
Definition name_info.hpp:70
void emplace(EnumT idx, const char *name)
Definition name_info.hpp:58
const value_type & operator[](unsigned long idx) const
Definition name_info.hpp:89
return_type at(EnumT idx) const
Definition name_info.hpp:78