7.1
general documentation
cs_base_accel.h File Reference
#include "cs_defs.h"
#include <stdio.h>
#include "bft_mem.h"
+ Include dependency graph for cs_base_accel.h:

Go to the source code of this file.

Macros

#define CS_MALLOC_HD(_ptr, _ni, _type, _mode)
 
#define CS_REALLOC_HD(_ptr, _ni, _type, _mode)
 
#define CS_FREE_HD(_ptr)   cs_free_hd(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
 
#define CS_FREE(_ptr)   cs_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
 
#define cs_alloc_mode   CS_ALLOC_HOST
 
#define cs_associate_device_ptr(_host_ptr, _ni, _size)   ;
 Associate device memory with a given host memory pointer. More...
 
#define cs_dissassociate_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...
 

Enumerations

enum  cs_alloc_mode_t {
  CS_ALLOC_HOST, CS_ALLOC_HOST_DEVICE, CS_ALLOC_HOST_DEVICE_PINNED, CS_ALLOC_HOST_DEVICE_SHARED,
  CS_ALLOC_DEVICE
}
 

Macro Definition Documentation

◆ cs_alloc_mode

#define cs_alloc_mode   CS_ALLOC_HOST

◆ cs_associate_device_ptr

#define cs_associate_device_ptr (   _host_ptr,
  _ni,
  _size 
)    ;

Associate device memory with a given host memory pointer.

If the host memory is already associated with the device, the existing device pointer is returned. Otherwise, a new device allocation is called and returned.

Parameters
[in]host_ptrhost pointer
[in]ninumber of elements
[in]sizeelement size
Returns
pointer to allocated memory.

◆ cs_dissassociate_device_ptr

#define cs_dissassociate_device_ptr (   _host_ptr)    ;

Detach device memory from a given host memory pointer.

If the host memory is shared with the device (i.e. using CS_ALLOC_SHARED), device memory stays shared.

Parameters
[in]host_ptrhost pointer

◆ CS_FREE

#define CS_FREE (   _ptr)    cs_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL

◆ CS_FREE_HD

#define CS_FREE_HD (   _ptr)    cs_free_hd(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL

◆ CS_MALLOC_HD

#define CS_MALLOC_HD (   _ptr,
  _ni,
  _type,
  _mode 
)
Value:
_ptr = (_type *) cs_malloc_hd(_mode, _ni, sizeof(_type), \
#_ptr, __FILE__, __LINE__)
void * cs_malloc_hd(cs_alloc_mode_t mode, size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Allocate memory on host and device for ni elements of size bytes.
Definition: cs_base_accel.cxx:336

◆ CS_REALLOC_HD

#define CS_REALLOC_HD (   _ptr,
  _ni,
  _type,
  _mode 
)
Value:
_ptr = (_type *) cs_realloc_hd(_ptr, _mode, _ni, sizeof(_type), \
#_ptr, __FILE__, __LINE__)
void * cs_realloc_hd(void *ptr, cs_alloc_mode_t mode, size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Reallocate memory on host and device for ni elements of size bytes.
Definition: cs_base_accel.cxx:449

◆ cs_set_alloc_mode

#define cs_set_alloc_mode (   _host_ptr,
  mode 
)    ;

Set allocation mode for an already allocated pointer.

If the allocation mode is different from the previous one, the associated memory will be reallocated with the desired mode, and the previous allocation freed.

Parameters
[in,out]host_ptrpointer to host pointer to modify
[in]modedesired allocation mode

Enumeration Type Documentation

◆ cs_alloc_mode_t

Enumerator
CS_ALLOC_HOST 

allocation on host only

CS_ALLOC_HOST_DEVICE 

allocation on host and device

CS_ALLOC_HOST_DEVICE_PINNED 

allocation on host and device, using page-locked memory on host if possible

CS_ALLOC_HOST_DEVICE_SHARED 

allocation on host and device, using mapped/shared memory

CS_ALLOC_DEVICE 

allocation on device only