1 #ifndef __CS_BASE_ACCEL_H__
2 #define __CS_BASE_ACCEL_H__
38 #if defined(SYCL_LANGUAGE_VERSION)
39 #include <sycl/sycl.hpp>
68 #define CS_MALLOC_HD(_ptr, _ni, _type, _mode) \
69 _ptr = (_type *) cs_malloc_hd(_mode, _ni, sizeof(_type), \
70 #_ptr, __FILE__, __LINE__)
88 #define CS_REALLOC_HD(_ptr, _ni, _type, _mode) \
89 _ptr = (_type *) cs_realloc_hd(_ptr, _mode, _ni, sizeof(_type), \
90 #_ptr, __FILE__, __LINE__)
108 #define CS_FREE_HD(_ptr) \
109 cs_free_hd(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
127 #define CS_FREE(_ptr) \
128 cs_free_hd(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
142 #if defined(HAVE_ACCEL)
151 #define cs_alloc_mode CS_ALLOC_HOST
152 #define cs_alloc_mode_read_mostly CS_ALLOC_HOST
154 #define cs_mpi_device_support 0;
160 #if defined(SYCL_LANGUAGE_VERSION)
161 extern sycl::queue cs_glob_sycl_queue;
176 #if defined(HAVE_ACCEL)
212 #if defined(HAVE_ACCEL)
218 const char *var_name,
219 const char *file_name,
228 const char *var_name,
229 const char *file_name,
268 #if defined(HAVE_ACCEL)
275 const char *var_name,
276 const char *file_name,
286 const char *var_name,
287 const char *file_name,
310 #if defined(HAVE_ACCEL)
314 const char *var_name,
315 const char *file_name,
322 const char *var_name,
323 const char *file_name,
347 #if defined(HAVE_ACCEL)
364 #if defined(__cplusplus) && defined(HAVE_ACCEL)
396 #if defined(HAVE_ACCEL)
403 inline static const void *
413 #if defined(__cplusplus) && defined(HAVE_ACCEL)
446 #if defined(HAVE_ACCEL)
453 inline static const void *
463 #if defined(__cplusplus) && defined(HAVE_ACCEL)
490 #if defined(HAVE_ACCEL)
522 #if defined(HAVE_ACCEL)
531 #define cs_associate_device_ptr(_host_ptr, _ni, _size);
546 #if defined(HAVE_ACCEL)
553 #define cs_disassociate_device_ptr(_host_ptr);
570 #if defined(HAVE_ACCEL)
578 #define cs_set_alloc_mode(_host_ptr, mode);
590 #if defined(HAVE_ACCEL)
597 #define cs_mem_advise_set_read_mostly(ptr);
609 #if defined(HAVE_ACCEL)
616 #define cs_mem_advise_unset_read_mostly(ptr);
638 #if defined(HAVE_ACCEL)
677 #if defined(HAVE_ACCEL)
711 #if defined(HAVE_ACCEL)
745 #if defined(HAVE_ACCEL)
774 #if defined(HAVE_ACCEL)
805 #if defined(HAVE_ACCEL)
823 #if defined(HAVE_ACCEL)
881 #if defined(HAVE_OPENMP_TARGET)
895 cs_omp_target_select_default_device(
void);
899 #if defined(HAVE_SYCL)
915 cs_sycl_select_default_device(
void);
942 #if defined(HAVE_ACCEL)
946 cs_set_alloc_mode_r(T* &host_ptr,
956 #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.cpp:829
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.cpp:886
void * bft_mem_free(void *ptr, const char *var_name, const char *file_name, int line_num)
Free allocated memory.
Definition: bft_mem.cpp:977
cs_alloc_mode_t
Definition: bft_mem.h:50
@ CS_ALLOC_HOST
Definition: bft_mem.h:52
void cs_copy_h2d(void *dest, const void *src, size_t size)
Copy data from host to device.
Definition: cs_base_accel.cxx:1672
void cs_copy_d2h(void *dest, const void *src, size_t size)
Copy data from device to host.
Definition: cs_base_accel.cxx:1709
void cs_copy_d2d(void *dest, const void *src, size_t size)
Copy data from device to device.
Definition: cs_base_accel.cxx:1746
static void * cs_get_device_ptr(void *ptr)
Return matching device pointer for a given pointer.
Definition: cs_base_accel.h:355
#define cs_mem_advise_set_read_mostly(ptr)
Advise memory system that a given allocation will be mostly read.
Definition: cs_base_accel.h:597
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:225
#define cs_mem_advise_unset_read_mostly(ptr)
Advise memory system that a given allocation will be mostly read.
Definition: cs_base_accel.h:616
static void cs_prefetch_d2h(void *ptr, size_t size)
Prefetch data from device to host.
Definition: cs_base_accel.h:814
static int cs_get_device_id(void)
Return currently associated device id.
Definition: cs_base_accel.h:184
#define cs_associate_device_ptr(_host_ptr, _ni, _size)
Associate device memory with a given host memory pointer.
Definition: cs_base_accel.h:531
#define cs_set_alloc_mode(_host_ptr, mode)
Set allocation mode for an already allocated pointer.
Definition: cs_base_accel.h:578
static void cs_sync_d2h(void *ptr)
Synchronize data from device to host.
Definition: cs_base_accel.h:719
#define cs_disassociate_device_ptr(_host_ptr)
Detach device memory from a given host memory pointer.
Definition: cs_base_accel.h:553
#define cs_alloc_mode
Definition: cs_base_accel.h:151
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:685
#define cs_alloc_mode_read_mostly
Definition: cs_base_accel.h:152
#define cs_mpi_device_support
Definition: cs_base_accel.h:154
static void cs_prefetch_h2d(void *ptr, size_t size)
Prefetch data from host to device.
Definition: cs_base_accel.h:783
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:282
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:498
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:321
static void cs_sync_d2h_if_needed(void *ptr)
Synchronize data from device to host, only if needed.
Definition: cs_base_accel.h:753
static void cs_sync_h2d(const void *ptr)
Synchronize data from host to device.
Definition: cs_base_accel.h:646
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:454
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:404
#define restrict
Definition: cs_defs.h:141
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define CS_UNUSED(x)
Definition: cs_defs.h:514
#define END_C_DECLS
Definition: cs_defs.h:529
@ p
Definition: cs_field_pointer.h:67