|
IPPL (Independent Parallel Particle Layer)
IPPL
|
Decorator class for buffer management that adds logging capabilities to buffer operations. More...
#include <LoggingBufferHandler.h>
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 > ¶meters) |
| 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< LogEntry > | logEntries_m |
| Log entries for buffer operations. | |
| int | rank_m |
| MPI rank for identifying log sources. | |
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.
| MemorySpace | The 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.
|
inherited |
Definition at line 23 of file BufferHandler.h.
| using ippl::LoggingBufferHandler< MemorySpace >::buffer_type = typename BufferHandler<MemorySpace>::buffer_type |
Definition at line 33 of file LoggingBufferHandler.h.
| using ippl::LoggingBufferHandler< MemorySpace >::size_type = typename BufferHandler<MemorySpace>::size_type |
Definition at line 34 of file LoggingBufferHandler.h.
| ippl::LoggingBufferHandler< MemorySpace >::LoggingBufferHandler | ( | std::shared_ptr< BufferHandler< MemorySpace > > | handler, |
| int | rank ) |
Constructs a LoggingBufferHandler with an existing buffer handler.
| handler | A shared pointer to an BufferHandler instance used for buffer operations. |
| rank | The MPI rank for logging purposes, used to identify the source of logs. |
Definition at line 10 of file LoggingBufferHandler.hpp.
| 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.
|
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().
|
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().
|
overridevirtual |
Frees a buffer and logs the action.
Overrides BufferHandler::freeBuffer. Calls BufferHandler::freeBuffer and records the operation in the log.
| buffer | The buffer to be freed. |
Implements ippl::BufferHandler< MemorySpace >.
Definition at line 31 of file LoggingBufferHandler.hpp.
References handler_m, and logMethod().
|
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.
| size | Requested size of the buffer. |
| overallocation | Optional multiplier to allocate extra buffer space. |
Implements ippl::BufferHandler< MemorySpace >.
Definition at line 23 of file LoggingBufferHandler.hpp.
References handler_m, and logMethod().
|
overridevirtual |
Retrieves the total size of free buffers.
Implements ippl::BufferHandler< MemorySpace >.
Definition at line 56 of file LoggingBufferHandler.hpp.
References handler_m.
| const std::vector< LogEntry > & ippl::LoggingBufferHandler< MemorySpace >::getLogs | ( | ) | const |
Retrieves the list of log entries.
Definition at line 61 of file LoggingBufferHandler.hpp.
References logEntries_m.
|
overridevirtual |
Retrieves the total size of allocated buffers.
Implements ippl::BufferHandler< MemorySpace >.
Definition at line 50 of file LoggingBufferHandler.hpp.
References handler_m.
|
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.
| methodName | Name of the method being logged (e.g., "getBuffer"). |
| parameters | A 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().
|
private |
Internal handler for buffer management.
Definition at line 108 of file LoggingBufferHandler.h.
Referenced by deleteAllBuffers(), freeAllBuffers(), freeBuffer(), getBuffer(), getFreeSize(), getUsedSize(), LoggingBufferHandler(), LoggingBufferHandler(), and logMethod().
|
private |
Log entries for buffer operations.
Definition at line 109 of file LoggingBufferHandler.h.
Referenced by getLogs(), and logMethod().
|
private |
MPI rank for identifying log sources.
Definition at line 110 of file LoggingBufferHandler.h.
Referenced by LoggingBufferHandler(), LoggingBufferHandler(), and logMethod().