ParGeMSLR
Macros | Enumerations | Functions
memory.hpp File Reference

Memory menagement functions for CPU and GPU. More...

#include <vector>
#include <unordered_map>

Go to the source code of this file.

Macros

#define PARGEMSLR_MALLOC_VOID(ptr, length, location)
 
#define PARGEMSLR_MALLOC(ptr, length, location, ...)
 
#define PARGEMSLR_CALLOC_VOID(ptr, length, location)
 
#define PARGEMSLR_CALLOC(ptr, length, location, ...)
 
#define PARGEMSLR_REALLOC_VOID(ptr, current_length, new_length, location)
 
#define PARGEMSLR_REALLOC(ptr, current_length, new_length, location, ...)
 
#define PARGEMSLR_MEMCPY(ptr_to, ptr_from, length, loc_to, loc_from, ...)
 
#define PARGEMSLR_FREE(ptr, location)
 
#define PARGEMSLR_PLACEMENT_NEW(ptr, location, ...)
 

Enumerations

enum  pargemslr::MemoryLocationEnum { kMemoryHost, kMemoryDevice, kMemoryUnified, kMemoryPinned }
 The memory location. Host, device, shared, page-locked. More...
 

Functions

void * pargemslr::PargemslrMalloc (size_t length, int location)
 Malloc memory at given location. More...
 
void * pargemslr::PargemslrCalloc (size_t length, int location)
 Calloc memory at given location. More...
 
void * pargemslr::PargemslrRealloc (void *ptr, size_t current_length, size_t new_length, int location)
 Realloc memory at given location. More...
 
void pargemslr::PargemslrMemcpy (void *ptr_to, const void *ptr_from, size_t length, int loc_to, int loc_from)
 Memory copy function. More...
 
void pargemslr::PargemslrFree (void *ptr, int location)
 Free the memory. More...
 

Macro Definition Documentation

◆ PARGEMSLR_CALLOC

#define PARGEMSLR_CALLOC (   ptr,
  length,
  location,
  ... 
)
Value:
{\
(ptr) = (__VA_ARGS__*) pargemslr::PargemslrCalloc( (size_t)(length)*sizeof(__VA_ARGS__), location);\
}

◆ PARGEMSLR_CALLOC_VOID

#define PARGEMSLR_CALLOC_VOID (   ptr,
  length,
  location 
)
Value:
{\
(ptr) = pargemslr::PargemslrCalloc( (size_t)(length), location);\
}

◆ PARGEMSLR_FREE

#define PARGEMSLR_FREE (   ptr,
  location 
)
Value:
{\
pargemslr::PargemslrFree( (void*)(ptr), location);\
(ptr) = NULL;\
}

◆ PARGEMSLR_MALLOC

#define PARGEMSLR_MALLOC (   ptr,
  length,
  location,
  ... 
)
Value:
{\
(ptr) = (__VA_ARGS__*) pargemslr::PargemslrMalloc( (size_t)(length)*sizeof(__VA_ARGS__), location);\
}

◆ PARGEMSLR_MALLOC_VOID

#define PARGEMSLR_MALLOC_VOID (   ptr,
  length,
  location 
)
Value:
{\
(ptr) = pargemslr::PargemslrMalloc( (size_t)(length), location);\
}

◆ PARGEMSLR_MEMCPY

#define PARGEMSLR_MEMCPY (   ptr_to,
  ptr_from,
  length,
  loc_to,
  loc_from,
  ... 
)
Value:
{\
pargemslr::PargemslrMemcpy( (void*)(ptr_to), (void*)(ptr_from), (size_t)(length)*sizeof(__VA_ARGS__), loc_to, loc_from);\
}

◆ PARGEMSLR_PLACEMENT_NEW

#define PARGEMSLR_PLACEMENT_NEW (   ptr,
  location,
  ... 
)
Value:
{\
(ptr) = (__VA_ARGS__*) pargemslr::PargemslrMalloc( (size_t)sizeof(__VA_ARGS__), location);\
(ptr) = new (ptr) __VA_ARGS__();\
}

◆ PARGEMSLR_REALLOC

#define PARGEMSLR_REALLOC (   ptr,
  current_length,
  new_length,
  location,
  ... 
)
Value:
{\
(ptr) = (__VA_ARGS__*) pargemslr::PargemslrRealloc( (void*)(ptr), (size_t)(current_length)*sizeof(__VA_ARGS__), (size_t)(new_length)*sizeof(__VA_ARGS__), location);\
}

◆ PARGEMSLR_REALLOC_VOID

#define PARGEMSLR_REALLOC_VOID (   ptr,
  current_length,
  new_length,
  location 
)
Value:
{\
(ptr) = (void*) pargemslr::PargemslrRealloc( (void*)(ptr), (size_t)(current_length), (size_t)(new_length), location);\
}

Enumeration Type Documentation

◆ MemoryLocationEnum

The memory location. Host, device, shared, page-locked.

Function Documentation

◆ PargemslrCalloc()

void * pargemslr::PargemslrCalloc ( size_t  length,
int  location 
)

Calloc memory at given location.

Parameters
[in]lengthThe length of array.
[in]locationThe location of the array.
Returns
Return pointer to the memory location.

◆ PargemslrFree()

void pargemslr::PargemslrFree ( void *  ptr,
int  location 
)

Free the memory.

Parameters
[in,out]ptrPointer to the memory, set to NULL on return.
[in]locationLocation of the memory.

◆ PargemslrMalloc()

void * pargemslr::PargemslrMalloc ( size_t  length,
int  location 
)

Malloc memory at given location.

Parameters
[in]lengthThe length of the array.
[in]locationThe location of the array.
Returns
Return pointer to the memory location.

◆ PargemslrMemcpy()

void pargemslr::PargemslrMemcpy ( void *  ptr_to,
const void *  ptr_from,
size_t  length,
int  loc_to,
int  loc_from 
)

Memory copy function.

Parameters
[in]ptr_toCopy to this address.
[in]ptr_fromCopy from this address.
[in]lengthThe length of the array.
[in]loc_toLocation of ptr_to.
[in]loc_fromLocation of ptr_from.

◆ PargemslrRealloc()

void * pargemslr::PargemslrRealloc ( void *  ptr,
size_t  current_length,
size_t  new_length,
int  location 
)

Realloc memory at given location.

Parameters
[in]ptrThe pointer to the memory location.
[in]current_lengthCurrent length of the array.
[in]new_lengthWanted length of the array.
[in]locationThe location of the array.
Returns
Return pointer to the memory location.