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.
|
Ring buffer wrapper around tim::base::ring_buffer for data of type Tp. If the data object size is larger than the page size (typically 4KB), behavior is undefined. During initialization, one requests a minimum number of objects and the buffer will support that number of object + the remainder of the page, e.g. if a page is 1000 bytes, the object is 1 byte, and the buffer is requested to support 1500 objects, then an allocation supporting 2000 objects (i.e. 2 pages) will be created. More...
#include "timemory/storage/ring_buffer.hpp"
Public Types | |
using | base_type = base::ring_buffer |
Public Member Functions | |
ring_buffer ()=default | |
~ring_buffer ()=default | |
ring_buffer (bool _use_mmap) | |
ring_buffer (size_t _size) | |
ring_buffer (size_t _size, bool _use_mmap) | |
ring_buffer (const ring_buffer &) | |
ring_buffer (ring_buffer &&) noexcept=default | |
ring_buffer & | operator= (const ring_buffer &) |
ring_buffer & | operator= (ring_buffer &&) noexcept=default |
bool | is_initialized () const |
Returns whether the buffer has been allocated. More... | |
size_t | capacity () const |
Get the total number of Tp instances supported. More... | |
void | init (size_t _size) |
Creates new ring buffer. More... | |
void | destroy () |
Destroy ring buffer. More... | |
size_t | data_size () const |
Write data to buffer. More... | |
Tp * | write (Tp *in) |
Write data to buffer. Return pointer to location of write. More... | |
Tp * | read (Tp *out) const |
Read data from buffer. Return pointer to location of read. More... | |
Tp * | request () |
Get an uninitialized address at tail of buffer. More... | |
Tp * | retrieve () |
Read data from head of buffer. More... | |
size_t | count () const |
Returns number of Tp instances currently held by the buffer. More... | |
size_t | free () const |
Returns how many Tp instances are availiable in the buffer. More... | |
bool | is_empty () const |
Returns if the buffer is empty. More... | |
bool | is_full () const |
Returns if the buffer is full. More... | |
size_t | rewind (size_t n) const |
Rewinds the read pointer. More... | |
template<typename... Args> | |
auto | emplace (Args &&... args) |
std::string | as_string () const |
bool | get_use_mmap () const |
query whether using mmap More... | |
void | set_use_mmap (bool) |
explicitly configure to use mmap if avail More... | |
Private Member Functions | |
template<typename Tp > | |
std::pair< size_t, Tp * > | write (Tp *in, std::enable_if_t< std::is_class< Tp >::value, int >=0) |
Write class-type data to buffer (uses placement new). More... | |
template<typename Tp > | |
std::pair< size_t, Tp * > | write (Tp *in, std::enable_if_t<!std::is_class< Tp >::value, int >=0) |
Write non-class-type data to buffer (uses memcpy). More... | |
void * | request (size_t n) |
Request a pointer to an allocation for at least. More... | |
template<typename Tp > | |
std::pair< size_t, Tp * > | read (Tp *out, std::enable_if_t< std::is_class< Tp >::value, int >=0) const |
Read class-type data from buffer (uses placement new). More... | |
template<typename Tp > | |
std::pair< size_t, Tp * > | read (Tp *out, std::enable_if_t<!std::is_class< Tp >::value, int >=0) const |
Read non-class-type data from buffer (uses memcpy). More... | |
void * | retrieve (size_t n) |
Retrieve a pointer to the head allocation of at least. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ring_buffer &obj) |
Ring buffer wrapper around tim::base::ring_buffer for data of type Tp. If the data object size is larger than the page size (typically 4KB), behavior is undefined. During initialization, one requests a minimum number of objects and the buffer will support that number of object + the remainder of the page, e.g. if a page is 1000 bytes, the object is 1 byte, and the buffer is requested to support 1500 objects, then an allocation supporting 2000 objects (i.e. 2 pages) will be created.
Definition at line 360 of file ring_buffer.hpp.
using tim::data_storage::ring_buffer< Tp >::base_type = base::ring_buffer |
Definition at line 362 of file ring_buffer.hpp.
|
default |
|
default |
|
inlineexplicit |
Definition at line 367 of file ring_buffer.hpp.
|
inlineexplicit |
Definition at line 371 of file ring_buffer.hpp.
|
inline |
Definition at line 375 of file ring_buffer.hpp.
tim::data_storage::ring_buffer< Tp >::ring_buffer | ( | const ring_buffer< Tp > & | rhs | ) |
Definition at line 471 of file ring_buffer.hpp.
|
defaultnoexcept |
|
inline |
Definition at line 437 of file ring_buffer.hpp.
References tim::base::ring_buffer::capacity(), tim::data_storage::ring_buffer< Tp >::capacity(), tim::base::ring_buffer::count(), tim::data_storage::ring_buffer< Tp >::count(), tim::data_storage::ring_buffer< Tp >::data_size(), tim::base::ring_buffer::free(), tim::data_storage::ring_buffer< Tp >::free(), tim::data_storage::ring_buffer< Tp >::is_empty(), tim::data_storage::ring_buffer< Tp >::is_full(), and tim::data_storage::ring_buffer< Tp >::is_initialized().
|
inline |
Get the total number of Tp instances supported.
Definition at line 389 of file ring_buffer.hpp.
References tim::base::ring_buffer::capacity().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
Returns number of Tp instances currently held by the buffer.
Definition at line 413 of file ring_buffer.hpp.
References tim::base::ring_buffer::count().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
Write data to buffer.
Definition at line 398 of file ring_buffer.hpp.
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
Destroy ring buffer.
Definition at line 395 of file ring_buffer.hpp.
References tim::base::ring_buffer::destroy().
|
inline |
Definition at line 428 of file ring_buffer.hpp.
References tim::data_storage::ring_buffer< Tp >::write().
|
inline |
Returns how many Tp instances are availiable in the buffer.
Definition at line 416 of file ring_buffer.hpp.
References tim::base::ring_buffer::free().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
|
inline |
Creates new ring buffer.
Definition at line 392 of file ring_buffer.hpp.
References tim::base::ring_buffer::init().
|
inline |
Returns if the buffer is empty.
Definition at line 419 of file ring_buffer.hpp.
References tim::base::ring_buffer::is_empty().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
Returns if the buffer is full.
Definition at line 422 of file ring_buffer.hpp.
References tim::base::ring_buffer::free().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
|
inline |
Returns whether the buffer has been allocated.
Definition at line 386 of file ring_buffer.hpp.
References tim::base::ring_buffer::is_initialized().
Referenced by tim::data_storage::ring_buffer< Tp >::as_string().
ring_buffer< Tp > & tim::data_storage::ring_buffer< Tp >::operator= | ( | const ring_buffer< Tp > & | rhs | ) |
Definition at line 480 of file ring_buffer.hpp.
|
defaultnoexcept |
|
inline |
Read data from buffer. Return pointer to location of read.
Definition at line 404 of file ring_buffer.hpp.
|
inline |
Get an uninitialized address at tail of buffer.
Definition at line 407 of file ring_buffer.hpp.
|
inline |
Read data from head of buffer.
Definition at line 410 of file ring_buffer.hpp.
|
inline |
Rewinds the read pointer.
Definition at line 425 of file ring_buffer.hpp.
References tim::base::ring_buffer::rewind().
void tim::base::ring_buffer::set_use_mmap | ( | bool | _v | ) |
explicitly configure to use mmap if avail
Definition at line 131 of file ring_buffer.cpp.
|
inline |
Write data to buffer. Return pointer to location of write.
Definition at line 401 of file ring_buffer.hpp.
Referenced by tim::data_storage::ring_buffer< Tp >::emplace().
|
friend |
Definition at line 456 of file ring_buffer.hpp.