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.
tim::scope::config Struct Reference

this data type encodes the options of storage scope. The default is hierarchical (tree) scope. Specification of flat scope overrides the hierarchy scope, e.g. you cannot have a hierarchical flat scope. The timeline scope is meaningless should a specification of tree or flat, thus the valid combinations are: tree, flat, tree + timeline, flat + timeline. More...

#include "timemory/utility/types.hpp"

+ Collaboration diagram for tim::scope::config:

Public Member Functions

 config ()
 
 config (const data_type &obj)
 
 config (data_type &&obj) noexcept
 
 config (bool _flat)
 
 config (bool _flat, bool _timeline)
 
 config (bool _flat, bool _timeline, bool _tree)
 
 config (tree)
 
 config (flat)
 
 config (timeline)
 
template<typename Arg , typename... Args, std::enable_if_t<(std::is_same< Arg, tree >::value||std::is_same< Arg, flat >::value||std::is_same< Arg, timeline >::value), int > = 0>
 config (Arg &&arg, Args &&... args)
 
 ~config ()=default
 
 config (const config &)=default
 
 config (config &&) noexcept=default
 
configoperator= (const config &)=default
 
configoperator= (config &&) noexcept=default
 
configoperator= (const data_type &rhs)
 
configoperator= (data_type &&rhs) noexcept
 
template<typename T , std::enable_if_t<(std::is_same< T, tree >::value||std::is_same< T, flat >::value||std::is_same< T, timeline >::value), int > = 0>
configoperator+= (T)
 
template<typename T , std::enable_if_t<(std::is_same< T, tree >::value||std::is_same< T, flat >::value||std::is_same< T, timeline >::value), int > = 0>
configset (bool val=true)
 
bool is_flat () const
 
bool is_timeline () const
 
bool is_tree () const
 
bool is_flat_timeline () const
 
bool is_tree_timeline () const
 
template<bool ForceFlatT>
bool is_flat () const
 
template<bool ForceTreeT, bool ForceTimeT>
bool is_tree () const
 
template<typename ForceTreeT = false_type, typename ForceFlatT = false_type, typename ForceTimeT = false_type>
uint64_t compute_depth (uint64_t _current)
 
template<typename ForceTreeT = false_type, typename ForceFlatT = false_type, typename ForceTimeT = false_type>
uint64_t compute_hash (uint64_t _id, uint64_t _depth, uint64_t &_counter)
 

Friends

std::ostream & operator<< (std::ostream &os, const config &obj)
 

Detailed Description

this data type encodes the options of storage scope. The default is hierarchical (tree) scope. Specification of flat scope overrides the hierarchy scope, e.g. you cannot have a hierarchical flat scope. The timeline scope is meaningless should a specification of tree or flat, thus the valid combinations are: tree, flat, tree + timeline, flat + timeline.

Definition at line 452 of file types.hpp.

Constructor & Destructor Documentation

◆ config() [1/12]

tim::scope::config::config ( )
inline

Definition at line 454 of file types.hpp.

455 : data_type(get_default_bitset())
456 {}
std::bitset< scope_count > data_type
Definition: types.hpp:399

◆ config() [2/12]

tim::scope::config::config ( const data_type obj)
inlineexplicit

Definition at line 458 of file types.hpp.

459 : data_type(obj)
460 {}

◆ config() [3/12]

tim::scope::config::config ( data_type &&  obj)
inlineexplicitnoexcept

Definition at line 462 of file types.hpp.

463 : data_type(std::forward<data_type>(obj))
464 {}

◆ config() [4/12]

tim::scope::config::config ( bool  _flat)
inlineexplicit

Definition at line 466 of file types.hpp.

467 : data_type(generate(input_type{ { _flat, false, false } },
468 make_index_sequence<scope_count>{}))
469 {}
std::array< bool, scope_count > input_type
Definition: types.hpp:400

◆ config() [5/12]

tim::scope::config::config ( bool  _flat,
bool  _timeline 
)
inlineexplicit

Definition at line 471 of file types.hpp.

472 : data_type(generate(input_type{ { _flat, _timeline, false } },
473 make_index_sequence<scope_count>{}))
474 {}

◆ config() [6/12]

tim::scope::config::config ( bool  _flat,
bool  _timeline,
bool  _tree 
)
inlineexplicit

Definition at line 476 of file types.hpp.

477 : data_type(generate(input_type{ { _flat, _timeline, _tree } },
478 make_index_sequence<scope_count>{}))
479 {}

◆ config() [7/12]

tim::scope::config::config ( tree  )
inline

Definition at line 481 of file types.hpp.

482 : config(false, false, false)
483 {}

◆ config() [8/12]

tim::scope::config::config ( flat  )
inline

Definition at line 485 of file types.hpp.

486 : config(true, false, false)
487 {}

◆ config() [9/12]

tim::scope::config::config ( timeline  )
inline

Definition at line 489 of file types.hpp.

490 : config(false, true, false)
491 {}

◆ config() [10/12]

template<typename Arg , typename... Args, std::enable_if_t<(std::is_same< Arg, tree >::value||std::is_same< Arg, flat >::value||std::is_same< Arg, timeline >::value), int > = 0>
tim::scope::config::config ( Arg &&  arg,
Args &&...  args 
)
inlineexplicit

Definition at line 498 of file types.hpp.

499 {
500 *this += std::forward<Arg>(arg);
501 TIMEMORY_FOLD_EXPRESSION(*this += std::forward<Args>(args));
502 }
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:56

References TIMEMORY_FOLD_EXPRESSION.

◆ ~config()

tim::scope::config::~config ( )
default

◆ config() [11/12]

tim::scope::config::config ( const config )
default

◆ config() [12/12]

tim::scope::config::config ( config &&  )
defaultnoexcept

Member Function Documentation

◆ compute_depth()

template<typename ForceTreeT = false_type, typename ForceFlatT = false_type, typename ForceTimeT = false_type>
uint64_t tim::scope::config::compute_depth ( uint64_t  _current)
inline

Definition at line 593 of file types.hpp.

594 {
595 static_assert(!(ForceTreeT::value && ForceFlatT::value),
596 "Error! Type cannot enforce tree-based call-stack depth storage "
597 "and flat call-stack depth storage simulatenously");
598 // flat: always at depth of 1
599 // tree: features nesting
600 // timeline: features nesting if not flat and depth of 1 if flat
601 if(ForceFlatT::value || is_flat())
602 {
603 // flat + timeline will be differentiated via compute_hash
604 // flat + tree is invalid and flat takes precedence
605 // printf("compute_depth is flat at %i\n", (int) _current);
606 return 1;
607 }
608 // if not flat, return the nested depth and compute_hash will account
609 // for whether the entry is a duplicate or not
610 // printf("compute_depth is tree or timeline at %i\n", (int) _current);
611 return _current + 1;
612 }
bool is_flat() const
Definition: types.hpp:546

◆ compute_hash()

template<typename ForceTreeT = false_type, typename ForceFlatT = false_type, typename ForceTimeT = false_type>
uint64_t tim::scope::config::compute_hash ( uint64_t  _id,
uint64_t  _depth,
uint64_t &  _counter 
)
inline

Definition at line 616 of file types.hpp.

617 {
618 // flat/tree: always compute the same hash for a given depth and key
619 // timeline: uses a counter to differentiate idential hashes occurring at diff
620 // time points.
621 // below is a fall-through (i.e. not an if-else) bc either tree or flat can be
622 // combined with timeline but in the case of tree + flat, flat will take
623 // precedence.
624 if(is_tree<ForceTreeT::value, ForceTimeT::value>() ||
625 is_flat<ForceFlatT::value>())
626 {
627 _id = get_combined_hash_id(_id, _depth);
628 }
629 if(ForceTimeT::value || is_timeline())
630 {
631 _id = get_combined_hash_id(_id, _counter++);
632 }
633 return _id;
634 }
hash_value_t get_combined_hash_id(hash_value_t _lhs, hash_value_t _rhs)
Definition: types.hpp:161
bool is_timeline() const
Definition: types.hpp:547

References tim::hash::get_combined_hash_id().

◆ is_flat() [1/2]

bool tim::scope::config::is_flat ( ) const
inline

Definition at line 546 of file types.hpp.

546{ return this->test(flat::value); }

◆ is_flat() [2/2]

template<bool ForceFlatT>
bool tim::scope::config::is_flat ( ) const
inline

Definition at line 564 of file types.hpp.

565 {
566 return (ForceFlatT) ? true : this->test(flat::value);
567 }

◆ is_flat_timeline()

bool tim::scope::config::is_flat_timeline ( ) const
inline

Definition at line 554 of file types.hpp.

555 {
556 return (is_flat() && is_timeline());
557 }

◆ is_timeline()

bool tim::scope::config::is_timeline ( ) const
inline

Definition at line 547 of file types.hpp.

547{ return this->test(timeline::value); }

◆ is_tree() [1/2]

bool tim::scope::config::is_tree ( ) const
inline

Definition at line 550 of file types.hpp.

551 {
552 return this->none() || (this->test(tree::value) && !this->test(flat::value));
553 }

◆ is_tree() [2/2]

template<bool ForceTreeT, bool ForceTimeT>
bool tim::scope::config::is_tree ( ) const
inline

Definition at line 570 of file types.hpp.

571 {
572 return (ForceTreeT)
573 ? true
574 : ((ForceTimeT) ? false
575 : (this->none() || (this->test(tree::value) &&
576 !this->test(flat::value))));
577 }

◆ is_tree_timeline()

bool tim::scope::config::is_tree_timeline ( ) const
inline

Definition at line 558 of file types.hpp.

559 {
560 return (is_tree() && is_timeline());
561 }
bool is_tree() const
Definition: types.hpp:550

◆ operator+=()

template<typename T , std::enable_if_t<(std::is_same< T, tree >::value||std::is_same< T, flat >::value||std::is_same< T, timeline >::value), int > = 0>
config & tim::scope::config::operator+= ( )
inline

Definition at line 528 of file types.hpp.

529 {
530 this->data_type::set(T::value, true);
531 return *this;
532 }

◆ operator=() [1/4]

config & tim::scope::config::operator= ( config &&  )
defaultnoexcept

◆ operator=() [2/4]

config & tim::scope::config::operator= ( const config )
default

◆ operator=() [3/4]

config & tim::scope::config::operator= ( const data_type rhs)
inline

Definition at line 510 of file types.hpp.

511 {
512 if(this != &rhs)
513 data_type::operator=(rhs);
514 return *this;
515 }

◆ operator=() [4/4]

config & tim::scope::config::operator= ( data_type &&  rhs)
inlinenoexcept

Definition at line 517 of file types.hpp.

518 {
519 if(this != &rhs)
520 data_type::operator=(std::forward<data_type>(rhs));
521 return *this;
522 }

◆ set()

template<typename T , std::enable_if_t<(std::is_same< T, tree >::value||std::is_same< T, flat >::value||std::is_same< T, timeline >::value), int > = 0>
config & tim::scope::config::set ( bool  val = true)
inline

Definition at line 540 of file types.hpp.

541 {
542 this->data_type::set(T::value, val);
543 return *this;
544 }

Referenced by tim::scope::operator+().

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const config obj 
)
friend

Definition at line 579 of file types.hpp.

580 {
581 std::stringstream ss;
582 ss << std::boolalpha << "tree: " << obj.is_tree() << ", flat: " << obj.is_flat()
583 << ", timeline: " << obj.is_timeline()
584 << ". Values: flat::value = " << obj.test(flat::value)
585 << ", timeline::value = " << obj.test(timeline::value)
586 << ", tree::value = " << obj.test(tree::value);
587 os << ss.str();
588 return os;
589 }
const std::string std::ostream * os

The documentation for this struct was generated from the following file: