timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
decode.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25#pragma once
26
30
31namespace tim
32{
33namespace operation
34{
35//
36//--------------------------------------------------------------------------------------//
37//
38///
39/// \struct tim::operation::decode
40/// \tparam ApiT Timemory project API, e.g. \ref tim::project::timemory
41///
42/// \brief This class post-processes strings for a given API
43///
44//
45//--------------------------------------------------------------------------------------//
46//
47template <typename ApiT>
48struct decode
49{
50 TIMEMORY_DEFAULT_OBJECT(decode)
51
52 static auto tokenized_demangle(std::string inp)
53 {
54 using pair_t = std::pair<std::string, std::string>;
55 for(auto&& itr : { pair_t{ "_Z", " " }, pair_t{ "_Z", "]" }, pair_t{ " ", " " } })
56 {
57 inp = str_transform(inp, itr.first, itr.second,
58 [](const std::string& _s) { return demangle(_s); });
59 }
60 return inp;
61 }
62
63 auto operator()(const char* inp)
64 {
65 return tokenized_demangle(demangle_backtrace(demangle_hash_identifier(inp)));
66 }
67
68 auto operator()(const std::string& inp)
69 {
70 return tokenized_demangle(demangle_backtrace(demangle_hash_identifier(inp)));
71 }
72
75 {
76 auto _resolvers = *get_hash_resolvers();
77 std::string _resolved{};
78 for(auto& itr : _resolvers)
79 {
80 if(itr(_hash_id, _resolved))
82 return _resolved;
83 }
84
87 }
88
90 {
91 auto _resolvers = *get_hash_resolvers();
92 std::string _resolved{};
93 for(auto& itr : _resolvers)
94 {
95 if(itr(_hash_id, _resolved))
97 return _resolved;
98 }
99
100 return tokenized_demangle(
102 }
103};
104//
105//--------------------------------------------------------------------------------------//
106//
107} // namespace operation
108} // namespace tim
STL namespace.
hash_value_t _hash_id
Definition: definition.hpp:114
std::shared_ptr< hash_resolver_vec_t > & get_hash_resolvers()
std::shared_ptr< hash_alias_map_t > hash_alias_ptr_t
Definition: types.hpp:89
bool get_hash_identifier(const hash_map_ptr_t &_hash_map, const hash_alias_ptr_t &_hash_alias, hash_value_t _hash_id, std::string *&_ret)
std::shared_ptr< hash_map_t > hash_map_ptr_t
Definition: types.hpp:87
const hash_alias_ptr_t & _hash_alias
Definition: definition.hpp:124
std::string demangle_hash_identifier(std::string, char bdelim='[', char edelim=']')
size_t hash_value_t
Definition: types.hpp:84
Definition: kokkosp.cpp:39
std::string str_transform(const std::string &input, const std::string &_begin, const std::string &_end, PredicateT &&predicate)
apply a string transformation to substring inbetween a common delimiter. e.g.
Definition: delimit.hpp:111
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
Declare the operations types.
This class post-processes strings for a given API.
Definition: decode.hpp:49
auto operator()(const hash_map_ptr_t &_hash_map, const hash_alias_ptr_t &_hash_alias, hash_value_t _hash_id)
Definition: decode.hpp:73
auto operator()(const char *inp)
Definition: decode.hpp:63
auto operator()(const std::string &inp)
Definition: decode.hpp:68
auto operator()(hash_value_t _hash_id)
Definition: decode.hpp:89
static auto tokenized_demangle(std::string inp)
Definition: decode.hpp:52