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

This component wraps malloc, calloc, free, cudaMalloc, cudaFree 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 >
 

Public Member Functions

void start ()
 
void stop ()
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static void global_init ()
 
static void global_finalize ()
 

Detailed Description

This component wraps malloc, calloc, free, cudaMalloc, cudaFree 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 329 of file memory_allocations.hpp.

Member Typedef Documentation

◆ base_type

◆ data_pointer_t

◆ malloc_bundle_t

◆ malloc_gotcha_t

◆ this_type

◆ tracker_type

◆ value_type

Member Function Documentation

◆ description()

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

Definition at line 344 of file memory_allocations.hpp.

345  {
346  return "Number of bytes allocated/freed instead of peak/current memory usage: "
347  "free(malloc(10)) + free(malloc(10)) would use 10 bytes but this would "
348  "report 20 bytes";
349  }

◆ global_finalize()

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

Definition at line 352 of file memory_allocations.hpp.

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

◆ global_init()

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

Definition at line 351 of file memory_allocations.hpp.

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

◆ label()

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

Definition at line 343 of file memory_allocations.hpp.

343 { return "memory_allocations"; }

◆ start()

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

Definition at line 354 of file memory_allocations.hpp.

355  {
356  auto _cnt = tracker_type::start();
357  if(_cnt.first == 0 && _cnt.second == 0 && !get_data())
358  {
359  get_data() = std::make_unique<malloc_bundle_t>();
360  get_data()->start();
361  }
362  }
void start(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:298

References tim::invoke::start().

◆ stop()

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

Definition at line 364 of file memory_allocations.hpp.

365  {
366  auto _cnt = tracker_type::stop();
367  if(_cnt.first == 0 && _cnt.second == 0 && get_data())
368  {
369  get_data()->stop();
370  get_data().reset(nullptr);
371  }
372  }
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:368

References tim::invoke::stop().


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