9.2
general documentation
cs_mem_hip_priv.h
Go to the documentation of this file.
1#pragma once
2
3/*============================================================================
4 * Private memory handling wrappers for HIP
5 *============================================================================*/
6
7/*
8 This file is part of code_saturne, a general-purpose CFD tool.
9
10 Copyright (C) 1998-2026 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 "base/cs_defs.h"
30
31#if defined(HAVE_HIP)
32
33#if defined(__HIPCC__)
34#include "hip/hip_runtime.h"
35#endif
36
37/*----------------------------------------------------------------------------
38 * Standard library headers
39 *----------------------------------------------------------------------------*/
40
41/*----------------------------------------------------------------------------
42 * Local headers
43 *----------------------------------------------------------------------------*/
44
45/*============================================================================
46 * Semi-private function prototypes
47 *
48 * The following functions are intended to be used by the common
49 * host-device memory management functions from cs_mem.cpp, and
50 * not directly by the user.
51 *============================================================================*/
52
53void
54cs_mem_hip_set_prefetch_stream(hipStream_t stream);
55
56void *
57cs_mem_hip_malloc_device(size_t n,
58 const char *var_name,
59 const char *file_name,
60 int line_num);
61
62void *
63cs_mem_hip_malloc_host(size_t n,
64 const char *var_name,
65 const char *file_name,
66 int line_num);
67
68void *
69cs_mem_hip_malloc_managed(size_t n,
70 const char *var_name,
71 const char *file_name,
72 int line_num);
73
74void
75cs_mem_hip_free(void *p,
76 const char *var_name,
77 const char *file_name,
78 int line_num);
79
80void
81cs_mem_hip_free_host(void *p,
82 const char *var_name,
83 const char *file_name,
84 int line_num);
85
86void
87cs_mem_hip_copy_h2d(void *dst,
88 const void *src,
89 size_t size);
90
91void
92cs_mem_hip_copy_h2d_async(void *dst,
93 const void *src,
94 size_t size);
95
96void
97cs_mem_hip_copy_d2h(void *dst,
98 const void *src,
99 size_t size);
100
101void
102cs_mem_hip_copy_d2h_async(void *dst,
103 const void *src,
104 size_t size);
105
106void
107cs_mem_hip_prefetch_h2d(const void *dst,
108 size_t size);
109
110void
111cs_mem_hip_prefetch_d2h(const void *dst,
112 size_t size);
113
114void
115cs_mem_hip_copy_d2d(void *dst,
116 const void *src,
117 size_t size);
118
119void *
120cs_mem_hip_get_host_ptr(const void *ptr);
121
122void
123cs_mem_hip_set_advise_read_mostly(const void *ptr,
124 size_t size);
125
126void
127cs_mem_hip_unset_advise_read_mostly(const void *ptr,
128 size_t size);
129
130size_t
131cs_mem_hip_get_device_memory_usage(void);
132
133#endif /* CS_HAVE_HIP */
134
135/*----------------------------------------------------------------------------*/
@ p
Definition: cs_field_pointer.h:63