PEARL
Parallel Event Access and Replay Library
List of all members
pearl::SmallObject Class Reference

Provides a base class for small objects using a custom memory management. More...

#include <pearl/SmallObject.h>

Inheritance diagram for pearl::SmallObject:
pearl::Event_rep pearl::Enter_rep pearl::Leave_rep pearl::MpiCancelled_rep pearl::MpiCollBegin_rep pearl::MpiCollEnd_rep pearl::MpiReceive_rep pearl::MpiReceiveRequest_rep pearl::MpiRequestTested_rep pearl::MpiRmaCollBegin_rep pearl::MpiRmaCollEnd_rep pearl::MpiRmaGats_rep pearl::MpiRmaLock_rep pearl::MpiRmaUnlock_rep pearl::MpiSend_rep pearl::MpiSendComplete_rep pearl::RmaGetEnd_rep pearl::RmaGetStart_rep pearl::RmaPutEnd_rep pearl::RmaPutStart_rep pearl::ThreadAcquireLock_rep pearl::ThreadBegin_rep pearl::ThreadCreate_rep pearl::ThreadEnd_rep pearl::ThreadFork_rep pearl::ThreadJoin_rep pearl::ThreadReleaseLock_rep pearl::ThreadTaskComplete_rep pearl::ThreadTaskCreate_rep pearl::ThreadTaskSwitch_rep pearl::ThreadTeamBegin_rep pearl::ThreadTeamEnd_rep pearl::ThreadWait_rep

Static Public Member Functions

Memory allocation operators
static void * operator new (std::size_t objectSize)
 Allocate storage space. More...
 
static void operator delete (void *deadObject, std::size_t objectSize)
 Deallocate storage space. More...
 

Protected Member Functions

Constructors & destructor
 ~SmallObject ()
 Destructor. More...
 

Detailed Description

Each dynamically allocated memory block usually requires some extra memory for bookkeeping purposes. However, this can be quite space inefficient if a large number of small objects is allocated, as the per-object overhead is significant.

The SmallObject class serves as a base class that can be used for such kinds of small objects, providing a customized memory management that allocates memory in larger chunks rather than individually for each object. This specialized memory management is restricted to objects of not more than 64 bytes, however, if objects grow larger (e.g., objects of a derived class), the default memory allocation routines are used transparently.

Note
Array allocations of small objects are always handled by the default allocator operator new.
Attention
Small objects derived from this class have to be deleted on the same thread they were allocated on. Otherwise the behavior is undefined.

Constructor & Destructor Documentation

◆ ~SmallObject()

pearl::SmallObject::~SmallObject ( )
protected

Protected destructor destroying the instance.

            \n@par Exception safety\n        <b class="paramname">No-throw guarantee:</b>         never throws exceptions.        <br>\n

Member Function Documentation

◆ operator delete()

static void pearl::SmallObject::operator delete ( void *  deadObject,
std::size_t  objectSize 
)
static

Deallocates the memory block of size objectSize pointed to by deadObject if it is not nullptr, otherwise this operator is a no-op. The memory block pointed to by deadObject must have been returned by a previous call to SmallObject::operator new on the same thread, otherwise the behavior is undefined.

Parameters
deadObjectPointer to the allocated memory
objectSizeSize of the memory block (in bytes)
        \n@par Exception safety\n        <b class="paramname">No-throw guarantee:</b>         never throws exceptions.        <br>\n

◆ operator new()

static void* pearl::SmallObject::operator new ( std::size_t  objectSize)
static

Allocates objectSize bytes of storage space and returns a non-null pointer to the first byte of the block. An optimized allocator is used for small objects less than 64 bytes, the default operator new otherwise.

Parameters
objectSizeSize of the requested memory block (in bytes)
\n@par Exception safety\n
If no (re-)allocations happen, the global state remains unchanged in case of exceptions (strong guarantee). Otherwise the global state is guaranteed to end in a valid state (basic guarantee).
Exceptions
bad_allocon failure to allocate the object memory or any of the required internal data structures

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

Scalasca    Copyright © 1998–2019 Forschungszentrum Jülich GmbH, Jülich Supercomputing Centre
Copyright © 2009–2015 German Research School for Simulation Sciences GmbH, Laboratory for Parallel Programming