8.3
general documentation
cs_mem_cuda_priv.h
Go to the documentation of this file.
1#pragma once
2
3/*============================================================================
4 * Private memory handling wrappersfor CUDA
5 *============================================================================*/
6
7/*
8 This file is part of code_saturne, a general-purpose CFD tool.
9
10 Copyright (C) 1998-2024 EDF S.A.
11
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
15 version.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
24 Street, Fifth Floor, Boston, MA 02110-1301, USA.
25*/
26
27/*----------------------------------------------------------------------------*/
28
29#include "cs_defs.h"
30
31#if defined(HAVE_CUDA)
32
33/*----------------------------------------------------------------------------
34 * Standard library headers
35 *----------------------------------------------------------------------------*/
36
37/*----------------------------------------------------------------------------
38 * Local headers
39 *----------------------------------------------------------------------------*/
40
41/*============================================================================
42 * Semi-private function prototypes
43 *
44 * The following functions are intended to be used by the common
45 * host-device memory management functions from cs_mem.cpp, and
46 * not directly by the user.
47 *============================================================================*/
48
49void
50cs_mem_cuda_set_prefetch_stream(cudaStream_t stream);
51
52void *
53cs_mem_cuda_malloc_device(size_t n,
54 const char *var_name,
55 const char *file_name,
56 int line_num);
57
58void *
59cs_mem_cuda_malloc_host(size_t n,
60 const char *var_name,
61 const char *file_name,
62 int line_num);
63
64void *
65cs_mem_cuda_malloc_managed(size_t n,
66 const char *var_name,
67 const char *file_name,
68 int line_num);
69
70void
71cs_mem_cuda_free(void *p,
72 const char *var_name,
73 const char *file_name,
74 int line_num);
75
76void
77cs_mem_cuda_free_host(void *p,
78 const char *var_name,
79 const char *file_name,
80 int line_num);
81
82void
83cs_mem_cuda_copy_h2d(void *dst,
84 const void *src,
85 size_t size);
86
87void
88cs_mem_cuda_copy_h2d_async(void *dst,
89 const void *src,
90 size_t size);
91
92void
93cs_mem_cuda_copy_d2h(void *dst,
94 const void *src,
95 size_t size);
96
97void
98cs_mem_cuda_copy_d2h_async(void *dst,
99 const void *src,
100 size_t size);
101
102void
103cs_mem_cuda_prefetch_h2d(const void *dst,
104 size_t size);
105
106void
107cs_mem_cuda_prefetch_d2h(const void *dst,
108 size_t size);
109
110void
111cs_mem_cuda_copy_d2d(void *dst,
112 const void *src,
113 size_t size);
114
115void *
116cs_mem_cuda_get_host_ptr(const void *ptr);
117
118bool
119cs_mem_cuda_is_device_ptr(const void *ptr);
120
121void
122cs_mem_cuda_set_advise_read_mostly(const void *ptr,
123 size_t size);
124
125void
126cs_mem_cuda_unset_advise_read_mostly(const void *ptr,
127 size_t size);
128
129bool
130cs_mem_cuda_is_device_ptr(const void *ptr);
131
132size_t
133cs_mem_cuda_get_device_memory_usage(void);
134
135#endif /* CS_HAVE_CUDA */
136
137/*----------------------------------------------------------------------------*/
@ p
Definition: cs_field_pointer.h:67