Preallocated memory sequence
External pre-allocated memory, is a class that preallocate memory and than it answer to a particular allocation pattern
Base | memory allocation class [Example] HeapMemory or CudaMemory |
Definition at line 27 of file ExtPreAlloc.hpp.
#include <ExtPreAlloc.hpp>
Public Member Functions | |
ExtPreAlloc () | |
Default constructor. | |
ExtPreAlloc (size_t size, Mem &mem) | |
Preallocated memory sequence. | |
void | setMemory (size_t size, Mem &mem) |
Set the internal memory if you did not do it in the constructor. | |
Mem * | getMemory () |
Get the internal memory if you did not do it in the constructor. | |
bool | copyDeviceToDevice (const ExtPreAlloc< Mem > &m) |
Copy the memory from device to device. | |
void | deviceToDevice (void *ptr, size_t start, size_t stop, size_t offset) |
special function to move memory from a raw device pointer | |
virtual void | incRef () |
Increment the reference counter. | |
virtual void | decRef () |
Decrement the reference counter. | |
virtual long int | ref () |
Return the reference counter. | |
virtual bool | flush () |
flush the memory | |
virtual void | fill (unsigned char c) |
fill host and device memory with the selected byte | |
virtual bool | allocate (size_t sz) |
Allocate a chunk of memory. | |
bool | allocate_nocheck (size_t sz) |
Allocate a chunk of memory. | |
void * | getPointerEnd () |
Return the end pointer of the previous allocated memory. | |
void * | getDevicePointerEnd () |
Return the device end pointer of the previous allocated memory. | |
void * | getPointerBase () |
The the base pointer of the preallocate memory. | |
virtual void * | getDevicePointer () |
Return the pointer of the last allocation. | |
virtual void | hostToDevice () |
Return the pointer of the last allocation. | |
virtual void | hostToDevice (size_t start, size_t stop) |
Return the pointer of the last allocation. | |
virtual void | deviceToHost () |
Do nothing. | |
virtual void | deviceToHost (size_t start, size_t stop) |
Do nothing. | |
virtual void * | getPointer () |
Return the pointer of the last allocation. | |
virtual const void * | getPointer () const |
Return the pointer of the last allocation. | |
void * | getPointerOffset (size_t offset) |
Get the base memory pointer increased with an offset. | |
virtual bool | resize (size_t sz) |
Allocate or resize the allocated memory. | |
virtual size_t | size () const |
Get the size of the LAST allocated memory. | |
void | destroy () |
Destroy memory. | |
virtual bool | copy (const memory &m) |
Copy memory. | |
bool | isInitialized () |
Allocated Memory is never initialized. | |
void | shift_backward (size_t sz) |
shift the pointer backward | |
void | shift_forward (size_t sz) |
shift the pointer forward | |
size_t | getOffset () |
Get offset. | |
size_t | getOffsetEnd () |
Get offset. | |
void | reset () |
Reset the internal counters. | |
Public Member Functions inherited from memory | |
virtual | ~memory () |
destructor | |
Static Public Member Functions | |
static constexpr bool | isDeviceHostSame () |
static size_t | calculateMem (std::vector< size_t > &mm) |
Calculate the total memory required to pack the message. | |
Private Attributes | |
size_t | a_seq |
Actual allocation pointer. | |
size_t | l_size |
Last allocation size. | |
Mem * | mem |
Main class for memory allocation. | |
long int | ref_cnt |
Reference counter. | |
|
inlinevirtual |
Definition at line 43 of file ExtPreAlloc.hpp.
|
inline |
Default constructor.
Definition at line 50 of file ExtPreAlloc.hpp.
|
inline |
Preallocated memory sequence.
size | number of bytes |
mem | external memory, used if you want to keep the memory |
Definition at line 61 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Allocate a chunk of memory.
Allocate a chunk of memory
sz | size of the chunk of memory to allocate in byte |
Implements memory.
Definition at line 151 of file ExtPreAlloc.hpp.
|
inline |
Allocate a chunk of memory.
Allocate a chunk of memory
sz | size of the chunk of memory to allocate in byte |
Definition at line 178 of file ExtPreAlloc.hpp.
|
inlinestatic |
Calculate the total memory required to pack the message.
Definition at line 357 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inline |
Copy the memory from device to device.
m | memory from where to copy |
Definition at line 95 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inlinevirtual |
|
inline |
special function to move memory from a raw device pointer
start | byte |
stop | byte |
offset | destination byte |
Definition at line 108 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
fill host and device memory with the selected byte
Implements memory.
Definition at line 139 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inlinevirtual |
Return the pointer of the last allocation.
NULL if memory has not been allocated
Implements memory.
Definition at line 227 of file ExtPreAlloc.hpp.
|
inline |
Return the device end pointer of the previous allocated memory.
Definition at line 205 of file ExtPreAlloc.hpp.
|
inline |
Get the internal memory if you did not do it in the constructor.
Definition at line 85 of file ExtPreAlloc.hpp.
|
inline |
|
inline |
|
inlinevirtual |
Return the pointer of the last allocation.
Implements memory.
Definition at line 271 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Return the pointer of the last allocation.
Implements memory.
Definition at line 281 of file ExtPreAlloc.hpp.
|
inline |
The the base pointer of the preallocate memory.
Definition at line 215 of file ExtPreAlloc.hpp.
|
inline |
Return the end pointer of the previous allocated memory.
Definition at line 195 of file ExtPreAlloc.hpp.
|
inline |
Get the base memory pointer increased with an offset.
offset | memory offset |
Definition at line 291 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Return the pointer of the last allocation.
Implements memory.
Definition at line 239 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Return the pointer of the last allocation.
Implements memory.
Definition at line 249 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inlinestaticconstexpr |
Definition at line 113 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Allocated Memory is never initialized.
Implements memory.
Definition at line 347 of file ExtPreAlloc.hpp.
|
inlinevirtual |
|
inline |
Reset the internal counters.
Definition at line 448 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Allocate or resize the allocated memory.
Resize the allocated memory, if request is smaller than the allocated, memory is not resized
sz | size |
Implements memory.
Definition at line 306 of file ExtPreAlloc.hpp.
|
inline |
Set the internal memory if you did not do it in the constructor.
size | number of bytes |
mem | external memory, used if you want to keep the memory |
Definition at line 74 of file ExtPreAlloc.hpp.
|
inline |
shift the pointer backward
This function is useful to go ahead in memory and fill the memory later on
how | many byte to shift |
Definition at line 401 of file ExtPreAlloc.hpp.
|
inline |
shift the pointer forward
The same as shift backward, but in this case it move the pointer forward
In general you use this function after the you went back with shift_backward and you have to move forward again
Definition at line 418 of file ExtPreAlloc.hpp.
|
inlinevirtual |
Get the size of the LAST allocated memory.
Get the size of the allocated memory
Implements memory.
Definition at line 319 of file ExtPreAlloc.hpp.
|
private |
Actual allocation pointer.
Definition at line 30 of file ExtPreAlloc.hpp.
|
private |
Last allocation size.
Definition at line 33 of file ExtPreAlloc.hpp.
|
private |
Main class for memory allocation.
Definition at line 36 of file ExtPreAlloc.hpp.
|
private |
Reference counter.
Definition at line 39 of file ExtPreAlloc.hpp.