1 #ifndef __CS_BASE_CUDA_H__ 
    2 #define __CS_BASE_CUDA_H__ 
   32 #if defined(HAVE_CUDA) 
   51 #define CS_CUDA_CHECK(a) { \ 
   52     cudaError_t _l_ret_code = a; \ 
   53     if (cudaSuccess != _l_ret_code) { \ 
   54       bft_error(__FILE__, __LINE__, 0, "[CUDA error] %d: %s\n  running: %s", \
 
   55                 _l_ret_code, ::cudaGetErrorString(_l_ret_code), #a); \
 
   59 #define CS_CUDA_CHECK_CALL(a, file_name, line_num) { \ 
   60     cudaError_t _l_ret_code = a; \ 
   61     if (cudaSuccess != _l_ret_code) { \ 
   62       bft_error(file_name, line_num, 0, "[CUDA error] %d: %s\n  running: %s", \
 
   63                 _l_ret_code, ::cudaGetErrorString(_l_ret_code), #a); \
 
   71 #define CS_CUDA_WARP_SIZE 32 
   85 extern int  cs_glob_cuda_device_id;
 
   89 extern int  cs_glob_cuda_max_threads_per_block;
 
   90 extern int  cs_glob_cuda_max_block_size;
 
   91 extern int  cs_glob_cuda_max_blocks;
 
   92 extern int  cs_glob_cuda_n_mp;  
 
   97 extern bool cs_glob_cuda_allow_graph;
 
  128 cs_cuda_mem_malloc_device(
size_t        n,
 
  129                           const char   *var_name,
 
  130                           const char   *file_name,
 
  154 cs_cuda_mem_malloc_host(
size_t        n,
 
  155                         const char   *var_name,
 
  156                         const char   *file_name,
 
  180 cs_cuda_mem_malloc_managed(
size_t        n,
 
  181                            const char   *var_name,
 
  182                            const char   *file_name,
 
  206 cs_cuda_mem_free(
void         *
p,
 
  207                  const char   *var_name,
 
  208                  const char   *file_name,
 
  232 cs_cuda_mem_free_host(
void         *
p,
 
  233                       const char   *var_name,
 
  234                       const char   *file_name,
 
  252 cs_cuda_copy_h2d(
void         *dst,
 
  274 cs_cuda_copy_h2d_async(
void        *dst,
 
  295 cs_cuda_copy_d2h(
void        *dst,
 
  316 cs_cuda_copy_d2h_async(
void        *dst,
 
  337 cs_cuda_prefetch_h2d(
void    *dst,
 
  357 cs_cuda_prefetch_d2h(
void    *dst,
 
  375 cs_cuda_copy_d2d(
void        *dst,
 
  398 cs_cuda_get_host_ptr(
const void  *ptr);
 
  410 cs_cuda_mem_set_advise_read_mostly(
const void  *ptr,
 
  423 cs_cuda_mem_unset_advise_read_mostly(
const void  *ptr,
 
  445 static inline unsigned int 
  447                   unsigned int  block_size)
 
  449   return (n % block_size) ?  n/block_size + 1 : n/block_size;
 
  454 #if defined(__NVCC__) 
  469 template <
typename T>
 
  471 cs_sync_or_copy_h2d(
const T        *val_h,
 
  478   const T  *_val_d = NULL;
 
  484     size_t size = n_vals * 
sizeof(T);
 
  487       CS_CUDA_CHECK(cudaMalloc(&_buf_d, size));
 
  488       cs_cuda_copy_h2d(_buf_d, val_h, size);
 
  489       _val_d = (
const T *)_buf_d;
 
  531 cs_cuda_get_stream(
int  stream_id);
 
  546 cs_base_cuda_device_info(
cs_log_t  log_id);
 
  557 cs_base_cuda_version_info(
cs_log_t  log_id);
 
  568 cs_base_cuda_compiler_info(
cs_log_t  log_id);
 
  582 cs_base_cuda_select_default_device(
void);
 
  593 cs_base_cuda_get_device(
void);
 
cs_alloc_mode_t
Definition: bft_mem.h:50
@ CS_ALLOC_HOST
Definition: bft_mem.h:52
@ CS_ALLOC_HOST_DEVICE_SHARED
Definition: bft_mem.h:57
const void * cs_get_device_ptr_const(const void *ptr)
Return matching device pointer for a given constant pointer.
Definition: cs_base_accel.cxx:888
void cs_sync_h2d(const void *ptr)
Synchronize data from host to device.
Definition: cs_base_accel.cxx:1256
cs_alloc_mode_t cs_check_device_ptr(const void *ptr)
Check if a pointer is associated with a device.
Definition: cs_base_accel.cxx:1031
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define END_C_DECLS
Definition: cs_defs.h:529
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ p
Definition: cs_field_pointer.h:67
cs_log_t
Definition: cs_log.h:48