timemory  3.2.1
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 445 of file types.hpp.

Constructor & Destructor Documentation

◆ config() [1/12]

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

Definition at line 447 of file types.hpp.

448  : data_type(get_default_bitset())
449  {}
std::bitset< scope_count > data_type
Definition: types.hpp:395

◆ config() [2/12]

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

Definition at line 451 of file types.hpp.

452  : data_type(obj)
453  {}

◆ config() [3/12]

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

Definition at line 455 of file types.hpp.

456  : data_type(std::forward<data_type>(obj))
457  {}

◆ config() [4/12]

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

Definition at line 459 of file types.hpp.

460  : data_type(generate(input_type{ { _flat, false, false } },
461  make_index_sequence<scope_count>{}))
462  {}
std::array< bool, scope_count > input_type
Definition: types.hpp:396

◆ config() [5/12]

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

Definition at line 464 of file types.hpp.

465  : data_type(generate(input_type{ { _flat, _timeline, false } },
466  make_index_sequence<scope_count>{}))
467  {}

◆ config() [6/12]

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

Definition at line 469 of file types.hpp.

470  : data_type(generate(input_type{ { _flat, _timeline, _tree } },
471  make_index_sequence<scope_count>{}))
472  {}

◆ config() [7/12]

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

Definition at line 474 of file types.hpp.

475  : config(false, false, false)
476  {}

◆ config() [8/12]

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

Definition at line 478 of file types.hpp.

479  : config(true, false, false)
480  {}

◆ config() [9/12]

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

Definition at line 482 of file types.hpp.

483  : config(false, true, false)
484  {}

◆ 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 491 of file types.hpp.

492  {
493  *this += std::forward<Arg>(arg);
494  TIMEMORY_FOLD_EXPRESSION(*this += std::forward<Args>(args));
495  }
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:55

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 586 of file types.hpp.

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

◆ 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 609 of file types.hpp.

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

References tim::get_combined_hash_id().

◆ is_flat() [1/2]

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

Definition at line 539 of file types.hpp.

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

◆ is_flat() [2/2]

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

Definition at line 557 of file types.hpp.

558  {
559  return (ForceFlatT) ? true : this->test(flat::value);
560  }

◆ is_flat_timeline()

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

Definition at line 547 of file types.hpp.

548  {
549  return (is_flat() && is_timeline());
550  }

◆ is_timeline()

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

Definition at line 540 of file types.hpp.

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

◆ is_tree() [1/2]

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

Definition at line 543 of file types.hpp.

544  {
545  return this->none() || (this->test(tree::value) && !this->test(flat::value));
546  }

◆ is_tree() [2/2]

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

Definition at line 563 of file types.hpp.

564  {
565  return (ForceTreeT)
566  ? true
567  : ((ForceTimeT) ? false
568  : (this->none() || (this->test(tree::value) &&
569  !this->test(flat::value))));
570  }

◆ is_tree_timeline()

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

Definition at line 551 of file types.hpp.

552  {
553  return (is_tree() && is_timeline());
554  }
bool is_tree() const
Definition: types.hpp:543

◆ 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 521 of file types.hpp.

522  {
523  this->data_type::set(T::value, true);
524  return *this;
525  }

◆ 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 503 of file types.hpp.

504  {
505  if(this != &rhs)
506  data_type::operator=(rhs);
507  return *this;
508  }

◆ operator=() [4/4]

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

Definition at line 510 of file types.hpp.

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

◆ 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 533 of file types.hpp.

534  {
535  this->data_type::set(T::value, val);
536  return *this;
537  }

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

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 572 of file types.hpp.

573  {
574  std::stringstream ss;
575  ss << std::boolalpha << "tree: " << obj.is_tree() << ", flat: " << obj.is_flat()
576  << ", timeline: " << obj.is_timeline()
577  << ". Values: flat::value = " << obj.test(flat::value)
578  << ", timeline::value = " << obj.test(timeline::value)
579  << ", tree::value = " << obj.test(tree::value);
580  os << ss.str();
581  return os;
582  }

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