KaMPIng 0.1.0
(Near) zero-overhead C++ MPI bindings.
Loading...
Searching...
No Matches
kamping::MPIAllocator< T > Class Template Reference

STL-compatible allocator for requesting memory using the builtin MPI allocator. More...

#include <allocator.hpp>

Public Types

using value_type = T
 The value type.
 
using propagate_on_container_move_assignment = std::true_type
 the memory "ownership" can be moved when the container is move-assigned. If this would not be the case, container would need to free memory using the old allocator and reallocated it using the copied allocator.
 
using is_always_equal = std::true_type
 memory allocated by one allocator instance can always be dellocated by another and vice-versa
 

Public Member Functions

template<typename U >
 MPIAllocator (MPIAllocator< U > const &) noexcept
 Copy constructor for allocators with different value type.
 
T * allocate (size_t n)
 Allocates n * sizeof(T) bytes using MPI allocation functions.
 
void deallocate (T *p, size_t)
 Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier call to allocate().
 

Detailed Description

template<typename T>
class kamping::MPIAllocator< T >

STL-compatible allocator for requesting memory using the builtin MPI allocator.

Note that this allocator may only be used after initializing MPI.

Template Parameters
TThe type to allocate.

Constructor & Destructor Documentation

◆ MPIAllocator()

template<typename T >
template<typename U >
kamping::MPIAllocator< T >::MPIAllocator ( MPIAllocator< U > const & )
inlinenoexcept

Copy constructor for allocators with different value type.

Since the allocator is stateless, we can also copy-assign allocators for other types (because this is a noop).

Member Function Documentation

◆ allocate()

template<typename T >
T * kamping::MPIAllocator< T >::allocate ( size_t n)
inline

Allocates n * sizeof(T) bytes using MPI allocation functions.

Parameters
nThe number of objects to allocate storage for.
Returns
Pointer to the allocated memory segment.

◆ deallocate()

template<typename T >
void kamping::MPIAllocator< T >::deallocate ( T * p,
size_t  )
inline

Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier call to allocate().

Parameters
pPointer obtained from allocate().

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