7#ifndef EXTPREALLOC_HPP_ 
    8#define EXTPREALLOC_HPP_ 
   46            std::cerr << 
"Error: " << __FILE__ << 
" " << __LINE__ << 
" destroying a live object" << 
"\n";
 
   97        return mem->copyDeviceToDevice(*m.
mem);
 
  110        mem->deviceToDevice(ptr,start,stop,offset);
 
  113    constexpr static bool isDeviceHostSame()
 
  115        return Mem::isDeviceHostSame();
 
  139    virtual void fill(
unsigned char c)
 
  164            std::cerr << __FILE__ << 
":" << __LINE__ << 
" Error requesting more memory than the allocated one" << std::endl;
 
  197        return (
char *)
mem->getPointer() + 
l_size;
 
  207        return (
char *)
mem->getDevicePointer() + 
l_size;
 
  217        return mem->getPointer();
 
  230        {
return (((
unsigned char *)
mem->getDevicePointer()) + 
a_seq );}
 
  251        mem->hostToDevice(start,stop);
 
  263        mem->deviceToHost(start,stop);
 
  273        return (((
unsigned char *)
mem->getPointer()) + 
a_seq );
 
  283        return (((
unsigned char *)
mem->getPointer()) + 
a_seq);
 
  293        return (((
unsigned char *)
mem->getPointer()) + offset);
 
  361        for (
size_t i = 0 ; i < mm.size() ; i++)
 
virtual void decRef()
Decrement the reference counter.
void destroy()
Destroy memory.
size_t getOffsetEnd()
Get offset.
ExtPreAlloc(size_t size, Mem &mem)
Preallocated memory sequence.
void shift_backward(size_t sz)
shift the pointer backward
size_t a_seq
Actual allocation pointer.
Mem * getMemory()
Get the internal memory if you did not do it in the constructor.
virtual void fill(unsigned char c)
fill host and device memory with the selected byte
virtual bool resize(size_t sz)
Allocate or resize the allocated memory.
size_t getOffset()
Get offset.
void * getPointerOffset(size_t offset)
Get the base memory pointer increased with an offset.
void * getPointerEnd()
Return the end pointer of the previous allocated memory.
long int ref_cnt
Reference counter.
virtual void * getDevicePointer()
Return the pointer of the last allocation.
Mem * mem
Main class for memory allocation.
virtual void deviceToHost(size_t start, size_t stop)
Do nothing.
void shift_forward(size_t sz)
shift the pointer forward
virtual void incRef()
Increment the reference counter.
virtual void * getPointer()
Return the pointer of the last allocation.
virtual void deviceToHost()
Do nothing.
void * getDevicePointerEnd()
Return the device end pointer of the previous allocated memory.
static size_t calculateMem(std::vector< size_t > &mm)
Calculate the total memory required to pack the message.
ExtPreAlloc()
Default constructor.
bool isInitialized()
Allocated Memory is never initialized.
size_t l_size
Last allocation size.
void reset()
Reset the internal counters.
virtual long int ref()
Return the reference counter.
virtual void hostToDevice()
Return the pointer of the last allocation.
void deviceToDevice(void *ptr, size_t start, size_t stop, size_t offset)
special function to move memory from a raw device pointer
virtual bool flush()
flush the memory
void setMemory(size_t size, Mem &mem)
Set the internal memory if you did not do it in the constructor.
void * getPointerBase()
The the base pointer of the preallocate memory.
virtual bool allocate(size_t sz)
Allocate a chunk of memory.
bool allocate_nocheck(size_t sz)
Allocate a chunk of memory.
virtual void hostToDevice(size_t start, size_t stop)
Return the pointer of the last allocation.
virtual const void * getPointer() const
Return the pointer of the last allocation.
virtual size_t size() const
Get the size of the LAST allocated memory.
virtual bool copy(const memory &m)
Copy memory.
bool copyDeviceToDevice(const ExtPreAlloc< Mem > &m)
Copy the memory from device to device.
this class is a functor for "for_each" algorithm