53#define CS_CUDA_CHECK(a) { \
54 cudaError_t _l_ret_code = a; \
55 if (cudaSuccess != _l_ret_code) { \
56 bft_error(__FILE__, __LINE__, 0, "[CUDA error] %d: %s\n running: %s", \
57 _l_ret_code, ::cudaGetErrorString(_l_ret_code), #a); \
61#define CS_CUDA_CHECK_CALL(a, file_name, line_num) { \
62 cudaError_t _l_ret_code = a; \
63 if (cudaSuccess != _l_ret_code) { \
64 bft_error(file_name, line_num, 0, "[CUDA error] %d: %s\n running: %s", \
65 _l_ret_code, ::cudaGetErrorString(_l_ret_code), #a); \
73#define CS_CUDA_WARP_SIZE 32
83extern int cs_glob_cuda_device_id;
87extern int cs_glob_cuda_shared_mem_per_block;
88extern int cs_glob_cuda_max_threads_per_block;
89extern int cs_glob_cuda_max_block_size;
90extern int cs_glob_cuda_max_blocks;
91extern int cs_glob_cuda_n_mp;
95extern ncclComm_t cs_glob_nccl_comm;
98extern ncclDataType_t cs_datatype_to_nccl[];
105extern bool cs_glob_cuda_allow_graph;
130cs_cuda_copy_h2d(
void *dst,
152cs_cuda_copy_h2d_async(
void *dst,
173cs_cuda_copy_d2h(
void *dst,
194cs_cuda_copy_d2h_async(
void *dst,
213cs_cuda_copy_d2d(
void *dst,
236cs_cuda_get_host_ptr(
const void *ptr);
257static inline unsigned int
259 unsigned int block_size)
261 return (n % block_size) ? n/block_size + 1 : n/block_size;
281cs_sync_or_copy_h2d(
const T *val_h,
288 const T *_val_d = NULL;
294 size_t size = n_vals *
sizeof(T);
297 CS_CUDA_CHECK(cudaMalloc(&_buf_d, size));
298 cs_cuda_copy_h2d(_buf_d, val_h, size);
299 _val_d = (
const T *)_buf_d;
341cs_cuda_get_stream(
int stream_id);
354cs_cuda_get_stream_prefetch(
void);
369cs_cuda_get_stream_id(cudaStream_t stream);
389cs_cuda_get_2_stage_reduce_buffers(
int stream_id,
392 unsigned int grid_size,
408cs_base_cuda_device_info(
cs_log_t log_id);
419cs_base_cuda_version_info(
cs_log_t log_id);
430cs_base_cuda_compiler_info(
cs_log_t log_id);
441cs_base_cuda_nccl_info(
cs_log_t log_id);
455cs_base_cuda_select_default_device(
void);
466cs_base_cuda_get_device(
void);
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_log_t
Definition: cs_log.h:44
void cs_sync_h2d(const void *ptr)
Synchronize data from host to device.
Definition: cs_mem.h:935
cs_alloc_mode_t cs_check_device_ptr(const void *ptr)
Check if a pointer is associated with a device.
Definition: cs_mem.h:727
const void * cs_get_device_ptr_const(const void *ptr)
Return matching device pointer for a given constant pointer.
Definition: cs_mem.h:687
cs_alloc_mode_t
Definition: cs_mem.h:46
@ CS_ALLOC_HOST
Definition: cs_mem.h:48
@ CS_ALLOC_HOST_DEVICE_SHARED
Definition: cs_mem.h:53