27#include "timemory/backends/process.hpp"
28#include "timemory/backends/threading.hpp"
35#include "timemory/tpls/cereal/archives.hpp"
64template <
typename Tp,
typename StatT>
65struct entry : std::tuple<Tp, StatT>
70 TIMEMORY_DEFAULT_OBJECT(
entry)
72 template <
typename... Args>
80 :
base_type(std::forward<base_type>(_obj))
84 Tp&
data() {
return std::get<0>(*
this); }
87 StatT&
stats() {
return std::get<1>(*
this); }
90 const Tp&
data()
const {
return std::get<0>(*
this); }
93 const StatT&
stats()
const {
return std::get<1>(*
this); }
112template <
typename Tp>
123 std::tuple<bool, uint32_t, uint32_t, uint64_t, int64_t, Tp, stats_type>;
124 using result_type = std::tuple<uint32_t, uint32_t, int64_t, uint64_t, uint64_t,
137template <
typename Tp>
150 graph(uint64_t _id,
const Tp& _obj, int64_t _depth, uint32_t _tid,
151 uint32_t _pid = process::get_id(),
bool _is_dummy =
false);
162 bool operator==(const
graph& rhs) const;
163 bool operator!=(const
graph& rhs) const;
167 stats() += rhs.stats();
183 uint32_t&
tid() {
return std::get<1>(*
this); }
186 uint32_t&
pid() {
return std::get<2>(*
this); }
189 uint64_t&
id() {
return std::get<3>(*
this); }
192 int64_t&
depth() {
return std::get<4>(*
this); }
195 Tp&
obj() {
return std::get<5>(*
this); }
200 const bool&
is_dummy()
const {
return std::get<0>(*
this); }
201 const uint32_t&
tid()
const {
return std::get<1>(*
this); }
202 const uint32_t&
pid()
const {
return std::get<2>(*
this); }
203 const uint64_t&
id()
const {
return std::get<3>(*
this); }
204 const int64_t&
depth()
const {
return std::get<4>(*
this); }
205 const Tp&
obj()
const {
return std::get<5>(*
this); }
210 const auto&
data()
const {
return this->
obj(); }
211 const auto&
hash()
const {
return this->
id(); }
221template <
typename Tp>
242 uint32_t _tid, uint32_t _pid);
246 uint32_t&
tid() {
return std::get<0>(*
this); }
250 uint32_t&
pid() {
return std::get<1>(*
this); }
253 int64_t&
depth() {
return std::get<2>(*
this); }
256 uint64_t&
hash() {
return std::get<3>(*
this); }
268 Tp&
data() {
return std::get<7>(*
this); }
274 uint64_t&
id() {
return std::get<3>(*
this); }
277 Tp&
obj() {
return std::get<7>(*
this); }
279 const uint32_t&
tid()
const {
return std::get<0>(*
this); }
280 const uint32_t&
pid()
const {
return std::get<1>(*
this); }
281 const int64_t&
depth()
const {
return std::get<2>(*
this); }
282 const uint64_t&
hash()
const {
return std::get<3>(*
this); }
286 const Tp&
data()
const {
return std::get<7>(*
this); }
288 const uint64_t&
id()
const {
return std::get<3>(*
this); }
289 const Tp&
obj()
const {
return std::get<7>(*
this); }
321template <
typename Tp>
344 tree(
bool _is_dummy, uint32_t _tid, uint32_t _pid, uint64_t _hash, int64_t _depth,
349 bool operator==(const
tree& rhs) const;
350 bool operator!=(const
tree& rhs) const;
357 for(
const auto& itr : rhs.tid())
359 for(
const auto& itr : rhs.pid())
377 uint64_t&
hash() {
return std::get<1>(*
this); }
381 int64_t&
depth() {
return std::get<2>(*
this); }
395 const bool&
is_dummy()
const {
return std::get<0>(*
this); }
396 const uint64_t&
hash()
const {
return std::get<1>(*
this); }
397 const int64_t&
depth()
const {
return std::get<2>(*
this); }
410template <
typename Tp>
417template <
typename Tp>
419 uint32_t _pid,
bool _is_dummy)
425template <
typename Tp>
429 return (
id() == rhs.
id() && depth() == rhs.
depth());
434template <
typename Tp>
438 return !(*
this == rhs);
443template <
typename Tp>
452template <
typename Tp>
455 const stats_type& _stats, uint32_t _tid, uint32_t _pid)
456:
base_type(_tid, _pid, _depth, _id, _rolling,
_prefix, _hierarchy, _data, _stats)
460template <
typename Tp>
468template <
typename Tp>
477template <
typename Tp>
483 depth() = rhs.
depth();
484 tid() = { rhs.
tid() };
485 pid() = { rhs.
pid() };
505template <
typename Archive,
typename Tp>
510 ar(cereal::make_nvp(
"hash", d.
id()), cereal::make_nvp(
"prefix",
_prefix),
511 cereal::make_nvp(
"entry", d.
obj()), cereal::make_nvp(
"depth", d.
depth()),
512 cereal::make_nvp(
"stats", d.
stats()), cereal::make_nvp(
"tid", d.
tid()),
513 cereal::make_nvp(
"pid", d.
pid()), cereal::make_nvp(
"dummy", d.
is_dummy()));
518template <
typename Archive,
typename Tp>
523 ar(cereal::make_nvp(
"hash", d.
id()), cereal::make_nvp(
"prefix",
_prefix),
524 cereal::make_nvp(
"entry", d.
obj()), cereal::make_nvp(
"depth", d.
depth()),
525 cereal::make_nvp(
"stats", d.
stats()), cereal::make_nvp(
"tid", d.
tid()),
526 cereal::make_nvp(
"pid", d.
pid()), cereal::make_nvp(
"dummy", d.
is_dummy()));
534template <
typename Archive,
typename Tp>
536 cereal::specialization::non_member_load_save>
541template <
typename Archive,
typename Tp,
typename StatT>
545 ar(cereal::make_nvp(
"entry", e.
data()));
546 ar(cereal::make_nvp(
"stats", e.
stats()));
551template <
typename Archive,
typename Tp,
typename StatT>
555 ar(cereal::make_nvp(
"entry", e.
data()));
556 ar(cereal::make_nvp(
"stats", e.
stats()));
561template <
typename Archive,
typename Tp,
typename StatT>
563 cereal::specialization::non_member_load_save>
568template <
typename Archive,
typename Tp>
574 ar(cereal::make_nvp(
"hash", t.
hash()), cereal::make_nvp(
"prefix",
_prefix),
575 cereal::make_nvp(
"tid", t.
tid()), cereal::make_nvp(
"pid", t.
pid()),
576 cereal::make_nvp(
"depth", t.
depth()), cereal::make_nvp(
"is_dummy", t.
is_dummy()));
577 ar(cereal::make_nvp(
"inclusive", t.
inclusive()));
578 ar(cereal::make_nvp(
"exclusive", t.
exclusive()));
583template <
typename Archive,
typename Tp>
588 ar(cereal::make_nvp(
"hash", t.
hash()), cereal::make_nvp(
"prefix",
_prefix),
589 cereal::make_nvp(
"tid", t.
tid()), cereal::make_nvp(
"pid", t.
pid()),
590 cereal::make_nvp(
"depth", t.
depth()), cereal::make_nvp(
"is_dummy", t.
is_dummy()));
591 ar(cereal::make_nvp(
"inclusive", t.
inclusive()));
592 ar(cereal::make_nvp(
"exclusive", t.
exclusive()));
600template <
typename Archive,
typename Tp>
602 cereal::specialization::non_member_load_save>
607template <
typename Archive,
typename Tp>
611 ar(cereal::make_nvp(
"hash", r.
hash()), cereal::make_nvp(
"prefix", r.
prefix()),
612 cereal::make_nvp(
"depth", r.
depth()), cereal::make_nvp(
"entry", r.
data()),
613 cereal::make_nvp(
"stats", r.
stats()),
620template <
typename Archive,
typename Tp>
624 ar(cereal::make_nvp(
"hash", r.
hash()), cereal::make_nvp(
"prefix", r.
prefix()),
625 cereal::make_nvp(
"depth", r.
depth()), cereal::make_nvp(
"entry", r.
data()),
626 cereal::make_nvp(
"stats", r.
stats()),
633template <
typename Archive,
typename Tp>
637 ar(cereal::make_nvp(
"graph_size", result_nodes.size()));
638 ar.setNextName(
"graph");
641 for(
const auto& itr : result_nodes)
652template <
typename Archive,
typename Tp>
657 ar(cereal::make_nvp(
"graph_size", nnodes));
658 result_nodes.resize(nnodes);
660 ar.setNextName(
"graph");
662 for(
auto& itr : result_nodes)
673template <
typename Archive,
typename Tp>
675 cereal::specialization::non_member_load_save>
void load(Archive &ar, tim::node::graph< Tp > &d)
void save(Archive &ar, std::shared_ptr< tim::tsettings< Tp, Tp & > > obj)
hash_value_t add_hash_id(hash_map_ptr_t &_hash_map, string_view_cref_t _prefix)
add an string to the given hash-map (if it doesn't already exist) and return the hash
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::tuple< bool, uint64_t, int64_t, idset_type, idset_type, entry_type, entry_type > tree_type
typename trait::statistics< Tp >::type type
std::tuple< bool, uint32_t, uint32_t, uint64_t, int64_t, Tp, stats_type > node_type
std::set< int64_t > idset_type
typename stats_policy::statistics_type stats_type
std::tuple< uint32_t, uint32_t, int64_t, uint64_t, uint64_t, string_t, uintvector_t, Tp, stats_type > result_type
std::vector< uint64_t > uintvector_t
entry< Tp, stats_type > entry_type
std::vector< string_t > strvector_t
char const std::string & _prefix
tim::mpl::apply< std::string > string
Declare the storage types.
This data type is used in tim::node::tree for inclusive and exclusive values.
entry(const base_type &_obj)
std::tuple< Tp, StatT > base_type
const Tp & data() const
component object with either inclusive or exclusive values
this_type & operator-=(const this_type &rhs)
Tp & data()
component object with either inclusive or exclusive values
this_type & operator+=(const this_type &rhs)
entry(base_type &&_obj) noexcept
StatT & stats()
statistics data with either inclusive or exclusive values
const StatT & stats() const
statistics data with either inclusive or exclusive values
This is the compact representation of a measurement in the call-graph.
const auto & hash() const
const int64_t & depth() const
bool operator!=(const graph &rhs) const
int64_t & depth()
depth in call-graph
typename Tp::base_type data_base_type
stats_type & stats()
statistics data for entry in call-graph
bool & is_dummy()
denotes this is a placeholder for synchronization
const uint32_t & pid() const
typename Tp::value_type data_value_type
this_type & operator-=(const this_type &rhs)
bool operator==(const graph &rhs) const
const bool & is_dummy() const
uint64_t & id()
hash identifer
graph(graph &&) noexcept=default
uint32_t & pid()
process identifier
typename data< Tp >::stats_type stats_type
typename data< Tp >::node_type base_type
const stats_type & stats() const
const uint32_t & tid() const
Tp & obj()
this is the instance that gets updated in call-graph
const uint64_t & id() const
graph(const graph &)=default
uint32_t & tid()
thread identifier
const auto & data() const
This data type is used when rendering the flat representation (i.e. loop-iterable) representation of ...
const uint64_t & id() const
this_type & operator-=(const this_type &rhs)
int64_t & depth()
depth of the node in the calling-context
uint32_t & pid()
the process identifier of the reporting process, if multiple process data is combined,...
const uint32_t & pid() const
result(const result &)=default
uint64_t & id()
alias for hash()
string_t & prefix()
the associated string with the hash + indentation and other decoration
typename data< Tp >::stats_type stats_type
const int64_t & depth() const
Tp & obj()
alias for data()
uint64_t & hash()
hash identifer of the node
bool operator==(const this_type &rhs) const
const string_t & prefix() const
this_type & operator+=(const this_type &rhs)
const uint64_t & rolling_hash() const
uintvector_t & hierarchy()
an array of the hash value + each parent hash (not serialized)
const stats_type & stats() const
const uintvector_t & hierarchy() const
bool operator!=(const this_type &rhs) const
std::vector< uint64_t > uintvector_t
uint64_t & rolling_hash()
the summation of this hash and it's parent hashes
const uint64_t & hash() const
Tp & data()
reference to the component
uint32_t & tid()
measurement thread. May be std::numeric_limits<uint16_t>max() (i.e. 65536) if this entry is a combina...
typename data< Tp >::result_type base_type
result(result &&) noexcept=default
stats_type & stats()
reference to the associate statistical accumulation of the data (if any)
const uint32_t & tid() const
This data type is used when rendering the hierarchical representation (i.e. requires recursion) repre...
const entry_type & exclusive() const
tree & operator=(const graph< Tp > &)
tree(tree &&) noexcept=default
int64_t & depth()
returns the depth of the node in the tree. NOTE: this value may be relative to dummy nodes
entry_type & inclusive()
the inclusive data + statistics
typename Tp::base_type data_base_type
typename data< Tp >::stats_type stats_type
idset_type & pid()
the set of process ids this data was collected from
const uint64_t & hash() const
tree(const tree &)=default
typename Tp::value_type data_value_type
const idset_type & pid() const
const entry_type & inclusive() const
uint64_t & hash()
returns the hash identifier for the associated string identifier
const bool & is_dummy() const
idset_type & tid()
the set of thread ids this data was collected from
tree(base_type &&_base) noexcept
this_type & operator-=(const this_type &rhs)
typename data< Tp >::entry_type entry_type
typename data< Tp >::idset_type idset_type
bool & is_dummy()
returns whether or not this node is a synchronization point and, if so, should be ignored
typename data< Tp >::tree_type base_type
entry_type & exclusive()
the exclusive data + statistics
const idset_type & tid() const
const int64_t & depth() const
This class post-processes strings for a given API.
Specification of how to accumulate statistics. This will not be used unless tim::trait::statistics ha...
statistics< type > statistics_type