C++ Operations¶
Namespace:
tim::operation
These structs are invoked by the variadic template bundlers when performing operations on components. The constructor of the class is invoked with a reference to the component and any additional arguments either provided by the bundler or passed in by the user.
component_tuple<Foo, Bar> handle("example");
handle.start();
for(int i = 0; i < N; ++i)
{
handle.store(i);
// ...
}
handle.stop();
will roughly translate to:
component_tuple<Foo, Bar> handle("example");
Foo& f = std::get<0>(handle.m_data);
Bar& b = std::get<1>(handle.m_data);
// constructor
auto ... = operation::set_prefix<Foo>(f, "example");
auto ... = operation::set_prefix<Bar>(b, "example");
// handle.start()
auto ... = operation::start<Foo>(f);
auto ... = operation::start<Bar>(b);
for(int i = 0; i < N; ++i)
{
// handle.store(i)
auto ... = operation::store<Foo>(f, i);
auto ... = operation::store<Bar>(b, i);
// ...
}
// handle.stop()
auto ... = operation::stop<Foo>(f);
auto ... = operation::stop<Bar>(b);
and, after the optimization by the compiler, those temporary objects
will be eliminated and only the contents of happen inside the constructor (if any)
will remain. This can be verified by executing the nm
utility and searching for
any symbols in the binary with the name operation
:
nm --demangle <EXE or LIB> | grep operation
-
template<typename
Tp
>
structinit
¶ This operation class is used for invoking the static initializer and thread-local initializer of a component.
-
template<typename
Tp
>
structinit_storage
¶
-
template<typename
Tp
>
structfini_storage
¶
-
template<typename
Tp
>
structconstruct
¶ The purpose of this operation class is construct an object with specific args.
-
template<typename
Tp
>
structset_prefix
¶ Call the set_prefix member function. These instantiations are always inlined because of the use of string_view. Without inlining, you will get undefined symbols in C++14 code when timemory was compiled with C++17.
- tparam Tp
Component type
-
template<typename
Tp
>
structset_scope
¶
-
template<typename
Tp
>
structpush_node
¶
-
template<typename
Tp
>
structpop_node
¶
-
template<typename
Tp
>
structrecord
¶
-
template<typename
Tp
>
structreset
¶
-
template<typename
Tp
>
structmeasure
¶ This operation class is used for a single measurement for a component.
-
template<typename
Tp
>
structsample
¶ This operation class is used for sampling.
-
template<typename
RetType
, typenameLhsType
, typenameRhsType
>
structcompose
¶ The purpose of this operation class is operating on two components to compose a result, e.g. use system-clock and user-clock to get a cpu-clock.
-
template<typename
T
, boolDefaultValue
>
structis_running
¶ This operation attempts to call a member function which provides whether or not the component currently within a phase measurement.
- tparam T
Component type
- tparam DefaultValue
The value to return if the member function is not provided
-
template<typename
T
>
structset_started
¶ This operation attempts to call a member function which the component provides to internally store whether or not it is currently within a phase measurement (to prevent restarts)
- tparam T
Component type
-
template<typename
Tp
>
structstart
¶
-
template<typename
Tp
>
structpriority_start
¶
-
template<typename
Tp
>
structstandard_start
¶
-
template<typename
Tp
>
structdelayed_start
¶
-
template<typename
T
>
structset_stopped
¶ This operation attempts to call a member function which the component provides to internally store whether or not it is currently within a phase measurement (to prevent stopping when it hasn’t been started)
- tparam T
Component type
-
template<typename
Tp
>
structstop
¶
-
template<typename
Tp
>
structpriority_stop
¶
-
template<typename
Tp
>
structstandard_stop
¶
-
template<typename
Tp
>
structdelayed_stop
¶
-
template<typename
Tp
>
structmark
¶ This operation class is used for marking some event (usually in some external profiler)
-
template<typename
Tp
>
structmark_begin
¶ This operation class is used for asynchronous routines such as cuda_event and nvtx_marker which are passed cudaStream_t instances.
-
template<typename
Tp
>
structmark_end
¶ This operation class is used for asynchronous routines such as cuda_event and nvtx_marker which are passed cudaStream_t instances.
-
template<typename
Tp
>
structstore
¶
-
template<typename
Tp
>
structaudit
¶ The purpose of this operation class is for a component to provide some extra customization within a GOTCHA function. It allows a GOTCHA component to inspect the arguments and the return type of a wrapped function. To add support to a component, define
void audit(std::string, context, <Args...>)
. The first argument is the function name (possibly mangled), the second is either type tim::audit::incoming or tim::audit::outgoing, and the remaining arguments are the corresponding types.One such purpose may be to create a custom component that intercepts a malloc and uses the arguments to get the exact allocation size.
-
template<typename
Tp
>
structplus
¶ Define addition operations.
-
template<typename
Tp
>
structminus
¶ Define subtraction operations.
-
template<typename
Tp
>
structmultiply
¶ This operation class is used for multiplication of a component.
-
template<typename
Tp
>
structdivide
¶ This operation class is used for division of a component.
-
template<typename
Tp
>
structget
¶ The purpose of this operation class is to provide a non-template hook to get the object itself.
-
template<typename
Tp
>
structget_data
¶ The purpose of this operation class is to combine the output types from the “get()” member function for multiple components this is specifically used in the Python interface to provide direct access to the results.
-
template<typename
Tp
>
structget_labeled_data
¶
-
template<typename
Tp
>
structtim::operation
::
base_printer
: public tim::operation::common_utils¶ invoked from the base class to provide default printing behavior
Public Static Functions
-
static inline string_t
attribute_string
(const string_t &key, const string_t &item)¶ generate an attribute
-
static inline string_t
replace
(string_t &item, const string_t &str, const strset_t &values)¶ replace matching values in item with str
-
static inline string_t
lowercase
(string_t _str)¶ convert to lowercase
-
static inline string_t
uppercase
(string_t _str)¶ convert to uppercase
-
static inline bool
contains
(const string_t &str, const strset_t &items)¶ check if str contains any of the string items
-
static inline string_t
-
template<typename
Tp
>
structprint
¶ print routines for individual components
-
template<typename
Tp
>
structtim::operation
::
print_header
: public tim::operation::common_utils¶ Public Static Functions
-
static inline string_t
attribute_string
(const string_t &key, const string_t &item)¶ generate an attribute
-
static inline string_t
replace
(string_t &item, const string_t &str, const strset_t &values)¶ replace matching values in item with str
-
static inline string_t
lowercase
(string_t _str)¶ convert to lowercase
-
static inline string_t
uppercase
(string_t _str)¶ convert to uppercase
-
static inline bool
contains
(const string_t &str, const strset_t &items)¶ check if str contains any of the string items
-
static inline string_t
-
template<typename
Tp
>
structtim::operation
::
print_statistics
: public tim::operation::common_utils¶ prints the statistics for a type
Public Static Functions
-
static inline string_t
attribute_string
(const string_t &key, const string_t &item)¶ generate an attribute
-
static inline string_t
replace
(string_t &item, const string_t &str, const strset_t &values)¶ replace matching values in item with str
-
static inline string_t
lowercase
(string_t _str)¶ convert to lowercase
-
static inline string_t
uppercase
(string_t _str)¶ convert to uppercase
-
static inline bool
contains
(const string_t &str, const strset_t &items)¶ check if str contains any of the string items
-
static inline string_t
-
template<typename
Tp
>
structprint_storage
¶ Print the storage for a component.
Subclassed by tim::operation::print_storage< Tp * >
-
template<typename
Tp
>
structadd_secondary
: public tim::operation::internal::add_secondary<Tp, trait::secondary_data<Tp>::value>¶ component contains secondary data resembling the original data but should be another node entry in the graph. These types must provide a get_secondary() member function and that member function must return a pair-wise iterable container, e.g. std::map, of types:
std::string
value_type or Tp
- tparam Tp
Component type
-
template<typename
T
>
structadd_statistics
¶ Enabling statistics in timemory has two parts:
tim::trait::record_statistics must be set to true for component
tim::trait::statistics must set the data type of the statistics
this is usually set to the data type returned from get()
tuple<> is the default and will fully disable statistics unless changed
-
template<typename
Tp
>
structserialization
: public tim::operation::internal::serialization<Tp, is_enabled<Tp>::value>¶
-
template<typename
T
, boolEnabled
= trait::echo_enabled<T>::value>
structecho_measurement
¶ This operation class echoes DartMeasurements for a CDash dashboard.
-
template<typename
Tp
>
structcopy
¶ This operation class is used for copying the object generically.
-
template<typename
Tp
>
structassemble
¶
-
template<typename
Tp
>
structderive
¶
-
template<typename
Tp
>
structcache
¶
-
template<typename
Tp
>
structfini
¶ This operation class is used for invoking the static initializer and thread-local initializer of a component.
-
template<typename
Type
, boolhas_data
>
structget
¶
-
template<typename
Type
, boolhas_data
>
structmpi_get
¶
-
template<typename
Type
, boolhas_data
>
structupc_get
¶
-
template<typename
Type
, boolhas_data
>
structdmp_get
¶
-
template<typename
Type
, boolhas_data
>
structprint
¶
-
template<typename
Type
, boolhas_data
>
structmerge
¶
-
template<typename
Type
>
structflamegraph
¶
-
template<typename
Tp
>
structgeneric_deleter
¶
-
template<typename
Tp
>
structgeneric_counter
¶
-
template<typename
Tp
, typenameOp
, typenameTag
>
structgeneric_operator
¶ This operation class is similar to pointer_operator but can handle non-pointer types.