1#ifndef __CS_BASE_ACCEL_H__
2#define __CS_BASE_ACCEL_H__
64#define CS_MALLOC_HD(_ptr, _ni, _type, _mode) \
65_ptr = (_type *) cs_malloc_hd(_mode, _ni, sizeof(_type), \
66 #_ptr, __FILE__, __LINE__)
84#define CS_REALLOC_HD(_ptr, _ni, _type, _mode) \
85_ptr = (_type *) cs_realloc_hd(_ptr, _mode, _ni, sizeof(_type), \
86 #_ptr, __FILE__, __LINE__)
104#define CS_FREE_HD(_ptr) \
105cs_free_hd(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
123#define CS_FREE(_ptr) \
124cs_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
159#if defined(HAVE_ACCEL)
165#define cs_alloc_mode CS_ALLOC_HOST
181#if defined(HAVE_ACCEL)
217#if defined(HAVE_ACCEL)
223 const char *var_name,
224 const char *file_name,
233 const char *var_name,
234 const char *file_name,
273#if defined(HAVE_ACCEL)
280 const char *var_name,
281 const char *file_name,
291 const char *var_name,
292 const char *file_name,
315#if defined(HAVE_ACCEL)
319 const char *var_name,
320 const char *file_name,
327 const char *var_name,
328 const char *file_name,
350#if defined(HAVE_ACCEL)
354 const char *var_name,
355 const char *file_name,
362 const char *var_name,
363 const char *file_name,
387#if defined(HAVE_ACCEL)
418#if defined(HAVE_ACCEL)
425inline static const void *
450#if defined(HAVE_ACCEL)
457inline static const void *
476#if defined(HAVE_ACCEL)
508#if defined(HAVE_ACCEL)
517#define cs_associate_device_ptr(_host_ptr, _ni, _size);
532#if defined(HAVE_ACCEL)
539#define cs_disassociate_device_ptr(_host_ptr);
556#if defined(HAVE_ACCEL)
564#define cs_set_alloc_mode(_host_ptr, mode);
586#if defined(HAVE_ACCEL)
625#if defined(HAVE_ACCEL)
659#if defined(HAVE_ACCEL)
687#if defined(HAVE_ACCEL)
718#if defined(HAVE_ACCEL)
736#if defined(HAVE_ACCEL)
802#if defined(HAVE_ACCEL)
827#if defined(HAVE_ACCEL)
843#if defined(HAVE_OPENMP_TARGET)
857cs_omp_target_select_default_device(
void);
884#if defined(HAVE_ACCEL)
888cs_set_alloc_mode_r(T* &host_ptr,
898#define cs_set_alloc_mode_r(_host_ptr, mode);
void * bft_mem_malloc(size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Allocate memory for ni elements of size bytes.
Definition bft_mem.c:815
void * bft_mem_realloc(void *ptr, size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Reallocate memory for ni elements of size bytes.
Definition bft_mem.c:899
void * bft_mem_free(void *ptr, const char *var_name, const char *file_name, int line_num)
Free allocated memory.
Definition bft_mem.c:1056
void cs_copy_h2d(void *dest, const void *src, size_t size)
Copy data from host to device.
Definition cs_base_accel.cxx:1406
void cs_copy_d2h(void *dest, const void *src, size_t size)
Copy data from device to host.
Definition cs_base_accel.cxx:1436
void cs_copy_d2d(void *dest, const void *src, size_t size)
Copy data from device to device.
Definition cs_base_accel.cxx:1466
static const void * cs_get_device_ptr_const_pf(const void *ptr)
Return matching device pointer for a given constant pointer, prefetching if applicable.
Definition cs_base_accel.h:458
static 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.h:230
static void cs_prefetch_d2h(void *ptr, size_t size)
Prefetch data from device to host.
Definition cs_base_accel.h:727
static int cs_get_device_id(void)
Return currently associated device id.
Definition cs_base_accel.h:189
static const void * cs_get_device_ptr_const(const void *ptr)
Return matching device pointer for a given constant pointer.
Definition cs_base_accel.h:426
#define cs_associate_device_ptr(_host_ptr, _ni, _size)
Associate device memory with a given host memory pointer.
Definition cs_base_accel.h:517
#define cs_set_alloc_mode(_host_ptr, mode)
Set allocation mode for an already allocated pointer.
Definition cs_base_accel.h:564
static void cs_sync_d2h(void *ptr)
Synchronize data from device to host.
Definition cs_base_accel.h:667
#define cs_disassociate_device_ptr(_host_ptr)
Detach device memory from a given host memory pointer.
Definition cs_base_accel.h:539
#define cs_alloc_mode
Definition cs_base_accel.h:165
static size_t cs_get_allocation_hd_size(void *host_ptr)
Check if a given host pointer is allocated with associated with cs_alloc_hd or cs_realloc_hd.
Definition cs_base_accel.h:835
static void cs_sync_h2d_future(const void *ptr)
Initiate synchronization of data from host to device for future access.
Definition cs_base_accel.h:633
static void cs_prefetch_h2d(void *ptr, size_t size)
Prefetch data from host to device.
Definition cs_base_accel.h:696
static cs_alloc_mode_t cs_check_device_ptr(const void *ptr)
Check if a pointer is associated with a device.
Definition cs_base_accel.h:484
static int cs_get_n_allocations_hd(void)
Return number of host-device allocations.
Definition cs_base_accel.h:810
static 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.h:287
static void cs_free_hd(void *ptr, const char *var_name, const char *file_name, int line_num)
Free memory on host and device for a given host pointer.
Definition cs_base_accel.h:326
static void cs_sync_h2d(const void *ptr)
Synchronize data from host to device.
Definition cs_base_accel.h:594
static void * cs_get_device_ptr(void *ptr)
Return matching device pointer for a given pointer.
Definition cs_base_accel.h:395
static void cs_free(void *ptr, const char *var_name, const char *file_name, int line_num)
Free memory on host and device for a given pointer.
Definition cs_base_accel.h:361
cs_alloc_mode_t
Definition cs_base_accel.h:142
@ CS_ALLOC_HOST
Definition cs_base_accel.h:144
@ CS_ALLOC_HOST_DEVICE_PINNED
Definition cs_base_accel.h:146
@ CS_ALLOC_HOST_DEVICE_SHARED
Definition cs_base_accel.h:149
@ CS_ALLOC_HOST_DEVICE
Definition cs_base_accel.h:145
@ CS_ALLOC_DEVICE
Definition cs_base_accel.h:151
#define BEGIN_C_DECLS
Definition cs_defs.h:509
#define CS_UNUSED(x)
Definition cs_defs.h:495
#define END_C_DECLS
Definition cs_defs.h:510
@ p
Definition cs_field_pointer.h:67