IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
ippl::LoggingBufferHandler< MemorySpace > Class Template Reference

Decorator class for buffer management that adds logging capabilities to buffer operations. More...

#include <LoggingBufferHandler.h>

Inheritance diagram for ippl::LoggingBufferHandler< MemorySpace >:
Collaboration diagram for ippl::LoggingBufferHandler< MemorySpace >:

Public Types

using buffer_type = typename BufferHandler<MemorySpace>::buffer_type
using size_type = typename BufferHandler<MemorySpace>::size_type
using archive_type = ippl::detail::Archive<MemorySpace>

Public Member Functions

 LoggingBufferHandler (std::shared_ptr< BufferHandler< MemorySpace > > handler, int rank)
 Constructs a LoggingBufferHandler with an existing buffer handler.
 LoggingBufferHandler ()
 Default constructor, creates an internal BufferHandler for managing buffers. This constructor also initializes the rank by calling MPI_Comm_rank.
buffer_type getBuffer (size_type size, double overallocation) override
 Allocates or retrieves a buffer and logs the action.
void freeBuffer (buffer_type buffer) override
 Frees a buffer and logs the action.
void freeAllBuffers () override
 Frees all buffers and logs the action.
void deleteAllBuffers () override
 Deletes all buffers and logs the action.
size_type getUsedSize () const override
 Retrieves the total size of allocated buffers.
size_type getFreeSize () const override
 Retrieves the total size of free buffers.
const std::vector< LogEntry > & getLogs () const
 Retrieves the list of log entries.

Private Member Functions

void logMethod (const std::string &methodName, const std::map< std::string, std::string > &parameters)
 Records a method call in the log with its parameters.

Private Attributes

std::shared_ptr< BufferHandler< MemorySpace > > handler_m
 Internal handler for buffer management.
std::vector< LogEntrylogEntries_m
 Log entries for buffer operations.
int rank_m
 MPI rank for identifying log sources.

Detailed Description

template<typename MemorySpace>
class ippl::LoggingBufferHandler< MemorySpace >

Decorator class for buffer management that adds logging capabilities to buffer operations.

LoggingBufferHandler extends the basic functionality of BufferHandler by recording detailed logs of buffer operations, such as allocation, deallocation, and resizing. This allows tracking of memory usage patterns and provides a record of buffer activity.

Template Parameters
MemorySpaceThe memory space in which buffers are managed (e.g., HostSpace, CudaSpace).

This class is a decorator for BufferHandler and does not modify buffer management logic. Instead, it adds logging for monitoring purposes.

Definition at line 31 of file LoggingBufferHandler.h.

Member Typedef Documentation

◆ archive_type

template<typename MemorySpace>
using ippl::BufferHandler< MemorySpace >::archive_type = ippl::detail::Archive<MemorySpace>
inherited

Definition at line 23 of file BufferHandler.h.

◆ buffer_type

template<typename MemorySpace>
using ippl::LoggingBufferHandler< MemorySpace >::buffer_type = typename BufferHandler<MemorySpace>::buffer_type

Definition at line 33 of file LoggingBufferHandler.h.

◆ size_type

template<typename MemorySpace>
using ippl::LoggingBufferHandler< MemorySpace >::size_type = typename BufferHandler<MemorySpace>::size_type

Definition at line 34 of file LoggingBufferHandler.h.

Constructor & Destructor Documentation

◆ LoggingBufferHandler() [1/2]

template<typename MemorySpace>
ippl::LoggingBufferHandler< MemorySpace >::LoggingBufferHandler ( std::shared_ptr< BufferHandler< MemorySpace > > handler,
int rank )

Constructs a LoggingBufferHandler with an existing buffer handler.

Parameters
handlerA shared pointer to an BufferHandler instance used for buffer operations.
rankThe MPI rank for logging purposes, used to identify the source of logs.

Definition at line 10 of file LoggingBufferHandler.hpp.

References handler_m, and rank_m.

◆ LoggingBufferHandler() [2/2]

template<typename MemorySpace>
ippl::LoggingBufferHandler< MemorySpace >::LoggingBufferHandler ( )

Default constructor, creates an internal BufferHandler for managing buffers. This constructor also initializes the rank by calling MPI_Comm_rank.

Definition at line 16 of file LoggingBufferHandler.hpp.

References handler_m, and rank_m.

Member Function Documentation

◆ deleteAllBuffers()

template<typename MemorySpace>
void ippl::LoggingBufferHandler< MemorySpace >::deleteAllBuffers ( )
overridevirtual

Deletes all buffers and logs the action.

Overrides BufferHandler::deleteAllBuffers. Calls BufferHandler::deleteAllBuffers and logs the operation.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 43 of file LoggingBufferHandler.hpp.

References handler_m, and logMethod().

Here is the call graph for this function:

◆ freeAllBuffers()

template<typename MemorySpace>
void ippl::LoggingBufferHandler< MemorySpace >::freeAllBuffers ( )
overridevirtual

Frees all buffers and logs the action.

Overrides BufferHandler::freeAllBuffers. Calls BufferHandler::freeAllBuffers and logs the operation.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 37 of file LoggingBufferHandler.hpp.

References handler_m, and logMethod().

Here is the call graph for this function:

◆ freeBuffer()

template<typename MemorySpace>
void ippl::LoggingBufferHandler< MemorySpace >::freeBuffer ( buffer_type buffer)
overridevirtual

Frees a buffer and logs the action.

Overrides BufferHandler::freeBuffer. Calls BufferHandler::freeBuffer and records the operation in the log.

Parameters
bufferThe buffer to be freed.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 31 of file LoggingBufferHandler.hpp.

References handler_m, and logMethod().

Here is the call graph for this function:

◆ getBuffer()

template<typename MemorySpace>
LoggingBufferHandler< MemorySpace >::buffer_type ippl::LoggingBufferHandler< MemorySpace >::getBuffer ( size_type size,
double overallocation )
overridevirtual

Allocates or retrieves a buffer and logs the action.

Overrides BufferHandler::getBuffer, providing the same buffer allocation behavior while recording an entry in the log with the operation details.

Parameters
sizeRequested size of the buffer.
overallocationOptional multiplier to allocate extra buffer space.
Returns
A buffer object.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 23 of file LoggingBufferHandler.hpp.

References handler_m, and logMethod().

Here is the call graph for this function:

◆ getFreeSize()

template<typename MemorySpace>
LoggingBufferHandler< MemorySpace >::size_type ippl::LoggingBufferHandler< MemorySpace >::getFreeSize ( ) const
overridevirtual

Retrieves the total size of free buffers.

Returns
The size of free buffers.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 56 of file LoggingBufferHandler.hpp.

References handler_m.

◆ getLogs()

template<typename MemorySpace>
const std::vector< LogEntry > & ippl::LoggingBufferHandler< MemorySpace >::getLogs ( ) const

Retrieves the list of log entries.

Returns
A constant reference to a vector containing log entries.

Definition at line 61 of file LoggingBufferHandler.hpp.

References logEntries_m.

◆ getUsedSize()

template<typename MemorySpace>
LoggingBufferHandler< MemorySpace >::size_type ippl::LoggingBufferHandler< MemorySpace >::getUsedSize ( ) const
overridevirtual

Retrieves the total size of allocated buffers.

Returns
The size of allocated buffers.

Implements ippl::BufferHandler< MemorySpace >.

Definition at line 50 of file LoggingBufferHandler.hpp.

References handler_m.

◆ logMethod()

template<typename MemorySpace>
void ippl::LoggingBufferHandler< MemorySpace >::logMethod ( const std::string & methodName,
const std::map< std::string, std::string > & parameters )
private

Records a method call in the log with its parameters.

This method creates a log entry with details of the buffer operation, including the method name, parameters, allocated size, free size, memory space, rank, and timestamp.

Parameters
methodNameName of the method being logged (e.g., "getBuffer").
parametersA map of parameter names and values for the operation.

Definition at line 66 of file LoggingBufferHandler.hpp.

References handler_m, logEntries_m, and rank_m.

Referenced by deleteAllBuffers(), freeAllBuffers(), freeBuffer(), and getBuffer().

Here is the caller graph for this function:

Member Data Documentation

◆ handler_m

template<typename MemorySpace>
std::shared_ptr<BufferHandler<MemorySpace> > ippl::LoggingBufferHandler< MemorySpace >::handler_m
private

◆ logEntries_m

template<typename MemorySpace>
std::vector<LogEntry> ippl::LoggingBufferHandler< MemorySpace >::logEntries_m
private

Log entries for buffer operations.

Definition at line 109 of file LoggingBufferHandler.h.

Referenced by getLogs(), and logMethod().

◆ rank_m

template<typename MemorySpace>
int ippl::LoggingBufferHandler< MemorySpace >::rank_m
private

MPI rank for identifying log sources.

Definition at line 110 of file LoggingBufferHandler.h.

Referenced by LoggingBufferHandler(), LoggingBufferHandler(), and logMethod().


The documentation for this class was generated from the following files: