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::component::memory_allocations Struct Reference

This component wraps malloc, calloc, free, CUDA/HIP malloc/free via GOTCHA and tracks the number of bytes requested/freed in each call. This component is useful for detecting the locations where memory re-use would provide a performance benefit. More...

#include "timemory/components/gotcha/memory_allocations.hpp"

+ Collaboration diagram for tim::component::memory_allocations:

Public Types

using value_type = void
 
using this_type = memory_allocations
 
using base_type = base< this_type, value_type >
 
using tracker_type = policy::instance_tracker< memory_allocations, true >
 
using malloc_gotcha_t = typename malloc_gotcha::gotcha_type< component_tuple_t<> >
 
using malloc_bundle_t = component_tuple_t< malloc_gotcha_t >
 
using data_pointer_t = std::unique_ptr< malloc_bundle_t >
 
using storage_type = empty_storage
 

Public Member Functions

void start ()
 
void stop ()
 
void get () const
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static void global_init ()
 
static void global_finalize ()
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

This component wraps malloc, calloc, free, CUDA/HIP malloc/free via GOTCHA and tracks the number of bytes requested/freed in each call. This component is useful for detecting the locations where memory re-use would provide a performance benefit.

Definition at line 347 of file memory_allocations.hpp.

Member Typedef Documentation

◆ base_type

◆ data_pointer_t

◆ malloc_bundle_t

◆ malloc_gotcha_t

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ tracker_type

◆ value_type

Member Function Documentation

◆ description()

static std::string tim::component::memory_allocations::description ( )
inlinestatic

Definition at line 362 of file memory_allocations.hpp.

363 {
364 return "Number of bytes allocated/freed instead of peak/current memory usage: "
365 "free(malloc(10)) + free(malloc(10)) would use 10 bytes but this would "
366 "report 20 bytes";
367 }

◆ get()

void tim::component::empty_base::get ( ) const
inlineinherited

Definition at line 69 of file declaration.hpp.

69{}

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ global_finalize()

static void tim::component::memory_allocations::global_finalize ( )
inlinestatic

Definition at line 370 of file memory_allocations.hpp.

370{ malloc_gotcha::tear_down<component_tuple_t<>>(); }

◆ global_init()

static void tim::component::memory_allocations::global_init ( )
inlinestatic

Definition at line 369 of file memory_allocations.hpp.

369{ malloc_gotcha::configure<component_tuple_t<>>(); }

◆ label()

static std::string tim::component::memory_allocations::label ( )
inlinestatic

Definition at line 361 of file memory_allocations.hpp.

361{ return "memory_allocations"; }

◆ start()

void tim::component::memory_allocations::start ( )
inline

Definition at line 372 of file memory_allocations.hpp.

373 {
374 auto _cnt = tracker_type::start();
375 if(_cnt.first == 0 && _cnt.second == 0 && !get_data())
376 {
377 get_data() = std::make_unique<malloc_bundle_t>();
378 get_data()->start();
379 }
380 }
void start(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:316

References tim::invoke::start().

◆ stop()

void tim::component::memory_allocations::stop ( )
inline

Definition at line 382 of file memory_allocations.hpp.

383 {
384 auto _cnt = tracker_type::stop();
385 if(_cnt.first == 0 && _cnt.second == 0 && get_data())
386 {
387 get_data()->stop();
388 get_data().reset(nullptr);
389 }
390 }
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:386

References tim::invoke::stop().


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