|
| #define | CS_MALLOC(_ptr, _ni, _type) |
| | Allocate memory for _ni elements of type _type. More...
|
| |
| #define | CS_MALLOC_HD(_ptr, _ni, _type, _mode) |
| |
| #define | CS_REALLOC(_ptr, _ni, _type) |
| | Reallocate memory for _ni elements of type _type. More...
|
| |
| #define | CS_REALLOC_HD(_ptr, _ni, _type, _mode) |
| |
| #define | CS_FREE(_ptr) cs_mem_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL |
| |
| #define | CS_MEMALIGN(_ptr, _align, _ni, _type) |
| | Allocate aligned memory for _ni elements of type _type. More...
|
| |
| #define | cs_alloc_mode CS_ALLOC_HOST |
| |
| #define | cs_alloc_mode_read_mostly CS_ALLOC_HOST |
| |
| #define | cs_alloc_mode_device CS_ALLOC_HOST |
| |
| #define | cs_associate_device_ptr(_host_ptr, _ni, _size) ; |
| | Associate device memory with a given host memory pointer. More...
|
| |
| #define | cs_disassociate_device_ptr(_host_ptr) ; |
| | Detach device memory from a given host memory pointer. More...
|
| |
| #define | cs_set_alloc_mode(_host_ptr, mode) ; |
| | Set allocation mode for an already allocated pointer. More...
|
| |
| #define | cs_set_alloc_mode_r(_host_ptr, mode) ; |
| | Set allocation mode for an already allocated pointer using pass by reference semantics for the pointer (C++ only). More...
|
| |
| #define | cs_mem_advise_set_read_mostly(ptr) ; |
| | Advise memory system that a given allocation will be mostly read. More...
|
| |
|
| int | cs_mem_stats (uint64_t *alloc_cur, uint64_t *alloc_max, uint64_t *n_allocs, uint64_t *n_reallocs, uint64_t *n_frees, uint64_t *n_current) |
| | Return memory allocation stats, if available. More...
|
| |
| static void * | cs_get_device_ptr (void *ptr) |
| | Return matching device pointer for a given pointer. More...
|
| |
| static const void * | cs_get_device_ptr_const (const void *ptr) |
| | Return matching device pointer for a given constant pointer. More...
|
| |
| static cs_alloc_mode_t | cs_check_device_ptr (const void *ptr) |
| | Check if a pointer is associated with a device. More...
|
| |
| static bool | cs_mem_is_device_ptr (const void *ptr) |
| | Check if a pointer is a device (or shared) pointer. More...
|
| |
| static void | cs_mem_advise_unset_read_mostly (void *ptr) |
| | Advise memory system that a given allocation will be mostly read. More...
|
| |
| static void | cs_sync_h2d (const void *ptr) |
| | Synchronize data from host to device. More...
|
| |
| static void | cs_sync_h2d_start (const void *ptr) |
| | Start synchronization of data from host to device. More...
|
| |
| static void | cs_sync_d2h (void *ptr) |
| | Synchronize data from device to host. More...
|
| |
| static void | cs_sync_d2h_start (void *ptr) |
| | Start synchronization of data from device to host. More...
|
| |
| static void | cs_sync_d2h_if_needed (void *ptr) |
| | Synchronize data from device to host, only if needed. More...
|
| |
| static void | cs_sync_d2h_if_needed_start (void *ptr) |
| | Start synchronization of data from device to host, only if needed. More...
|
| |
| static void | cs_prefetch_h2d (const void *ptr, size_t size) |
| | Prefetch data from host to device. More...
|
| |
| static void | cs_prefetch_d2h (void *ptr, size_t size) |
| | Prefetch data from device to host. More...
|
| |
| static void | cs_mem_hd_async_wait (void) |
| | Wait for asynchronous memory operations between device and pinned host memory to finish. More...
|
| |
| static void * cs_get_device_ptr |
( |
void * |
ptr | ) |
|
|
inlinestatic |
Return matching device pointer for a given pointer.
If separate pointers are used on the host and device, the host pointer should be used with this function.
If memory is not allocated on device yet at the call site, it will be allocated automatically by this function.
- Parameters
-
- Returns
- pointer to device memory.
| static const void * cs_get_device_ptr_const |
( |
const void * |
ptr | ) |
|
|
inlinestatic |
Return matching device pointer for a given constant pointer.
If separate pointers are used on the host and device, the host pointer should be used with this function.
If memory is not allocated on device yet at the call site, it will be allocated automatically by this function.
- Parameters
-
- Returns
- pointer to device memory.
| int cs_mem_stats |
( |
uint64_t * |
alloc_cur, |
|
|
uint64_t * |
alloc_max, |
|
|
uint64_t * |
n_allocs, |
|
|
uint64_t * |
n_reallocs, |
|
|
uint64_t * |
n_frees, |
|
|
uint64_t * |
n_current |
|
) |
| |
Return memory allocation stats, if available.
Availability of statistics depends on the cs_mem_init options.
- Parameters
-
| [out] | alloc_cur | current allocation size, or nullptr |
| [out] | alloc_max | max allocation size, or nullptr |
| [out] | n_allocs | total number of allocations, or nullptr |
| [out] | n_reallocs | total number of reallocations, or nullptr |
| [out] | n_frees | total number of frees, or nullptr |
| [out] | n_current | total number of current allocations, or nullptr |
\return 1 if stats are available, O otherwise.
Return memory allocation stats, if available.
Availability of statistics depends on the cs_mem_init options.
With acceleration, alloc_cur and alloc_max should have 4 entries each 0: host 1: pinned (included in host) 2: unified (included in host and device) 3: device
- Parameters
-
| [out] | alloc_cur | current allocation sizes, or nullptr |
| [out] | alloc_max | max allocation sizes, or nullptr |
| [out] | n_allocs | total number of allocations, or nullptr |
| [out] | n_reallocs | total number of reallocations, or nullptr |
| [out] | n_frees | total number of frees, or nullptr |
| [out] | n_current | total number of current allocations, or nullptr |
- Returns
- 1 if stats are available, O otherwise.
| static void cs_sync_d2h |
( |
void * |
ptr | ) |
|
|
inlinestatic |
Synchronize data from device to host.
If separate allocations are used on the host and device (mode == CS_ALLOC_HOST_DEVICE), the host pointer should be passed to this function.
Depending on the allocaton type, this can imply a copy, data prefetch, or a no-op.
This function assumes the provided pointer was allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | pointer to values to copy or prefetch |
| static void cs_sync_d2h_if_needed |
( |
void * |
ptr | ) |
|
|
inlinestatic |
Synchronize data from device to host, only if needed.
If separate allocations are used on the host and device (mode == CS_ALLOC_HOST_DEVICE), the host pointer should be passed to this function.
Depending on the allocation type, this can imply a copy, data prefetch, or a no-op.
No operation occurs if the provided pointer was not allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | pointer to values to copy or prefetch |
| static void cs_sync_d2h_if_needed_start |
( |
void * |
ptr | ) |
|
|
inlinestatic |
Start synchronization of data from device to host, only if needed.
If separate allocations are used on the host and device (mode == CS_ALLOC_HOST_DEVICE), the host pointer should be passed to this function.
Depending on the allocation type, this can imply a copy, data prefetch, or a no-op.
No operation occurs if the provided pointer was not allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | pointer to values to copy or prefetch |
| static void cs_sync_d2h_start |
( |
void * |
ptr | ) |
|
|
inlinestatic |
Start synchronization of data from device to host.
If separate allocations are used on the host and device (mode == CS_ALLOC_HOST_DEVICE), the host pointer should be passed to this function.
Depending on the allocaton type, this can imply a copy, data prefetch, or a no-op.
This function assumes the provided pointer was allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | pointer to values to copy or prefetch |
| static void cs_sync_h2d |
( |
const void * |
ptr | ) |
|
|
inlinestatic |
Synchronize data from host to device.
If separate pointers are used on the host and device, the host pointer should be used with this function.
Depending on the allocation type, this can imply a copy, data prefetch, or a no-op.
This function assumes the provided pointer was allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | host pointer to values to copy or prefetch |
| static void cs_sync_h2d_start |
( |
const void * |
ptr | ) |
|
|
inlinestatic |
Start synchronization of data from host to device.
If separate pointers are used on the host and device, the host pointer should be used with this function.
Depending on the allocation type, this can imply a copy, data prefetch, or a no-op.
This function assumes the provided pointer was allocated using CS_MALLOC_HD or CS_REALLOC_HD, as it uses the associated mapping to determine associated metadata.
- Parameters
-
| [in,out] | ptr | host pointer to values to copy or prefetch |