Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_vreman_nut.F90
Go to the documentation of this file.
1! Copyright (c) 2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
34 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
35 use num_types, only : rp, c_rp
36 use utils, only : neko_error
38 use mpi_f08, only : mpi_sum, mpi_in_place, mpi_allreduce
39
40 implicit none
41 private
42
43#ifdef HAVE_HIP
44 interface
45 subroutine hip_vreman_nut_compute(a11_d, a12_d, a13_d, &
46 a21_d, a22_d, a23_d, &
47 a31_d, a32_d, a33_d, &
48 delta_d, nut_d, mult_d, c, eps, n) &
49 bind(c, name = 'hip_vreman_nut_compute')
50 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
51 import c_rp
52 type(c_ptr), value :: a11_d, a12_d, a13_d, &
53 a21_d, a22_d, a23_d, &
54 a31_d, a32_d, a33_d, &
55 delta_d, nut_d, mult_d
56 integer(c_int) :: n
57 real(c_rp) :: c, eps
58 end subroutine hip_vreman_nut_compute
59
60
61 subroutine hip_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
62 a21_d, a22_d, a23_d, &
63 a31_d, a32_d, a33_d, &
64 delta_d, nut_d, mult_d, c, eps, n, &
65 dTdx_d, dTdy_d, dTdz_d, g, ri_c, ref_temp) &
66 bind(c, name = 'hip_vreman_nut_compute_buoy')
67 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
68 import c_rp
69 type(c_ptr), value :: a11_d, a12_d, a13_d, &
70 a21_d, a22_d, a23_d, &
71 a31_d, a32_d, a33_d, &
72 delta_d, nut_d, mult_d
73 integer(c_int) :: n
74 real(c_rp) :: c, eps
75 type(c_ptr), value :: dTdx_d, dTdy_d, dTdz_d
76 real(c_rp) :: g(3)
77 real(c_rp) :: ri_c, ref_temp
78 end subroutine hip_vreman_nut_compute_buoy
79
80 end interface
81#elif HAVE_CUDA
82 interface
83 subroutine cuda_vreman_nut_compute(a11_d, a12_d, a13_d, &
84 a21_d, a22_d, a23_d, &
85 a31_d, a32_d, a33_d, &
86 delta_d, nut_d, mult_d, c, eps, n) &
87 bind(c, name = 'cuda_vreman_nut_compute')
88 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
89 import c_rp
90 type(c_ptr), value :: a11_d, a12_d, a13_d, &
91 a21_d, a22_d, a23_d, &
92 a31_d, a32_d, a33_d, &
93 delta_d, nut_d, mult_d
94 integer(c_int) :: n
95 real(c_rp) :: c, eps
96 end subroutine cuda_vreman_nut_compute
97
98
99 subroutine cuda_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
100 a21_d, a22_d, a23_d, &
101 a31_d, a32_d, a33_d, &
102 delta_d, nut_d, mult_d, c, eps, n, &
103 dTdx_d, dTdy_d, dTdz_d, g, ri_c, ref_temp) &
104 bind(c, name = 'cuda_vreman_nut_compute_buoy')
105 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
106 import c_rp
107 type(c_ptr), value :: a11_d, a12_d, a13_d, &
108 a21_d, a22_d, a23_d, &
109 a31_d, a32_d, a33_d, &
110 delta_d, nut_d, mult_d
111 integer(c_int) :: n
112 real(c_rp) :: c, eps
113 type(c_ptr), value :: dTdx_d, dTdy_d, dTdz_d
114 real(c_rp) :: g(3)
115 real(c_rp) :: ri_c, ref_temp
116 end subroutine cuda_vreman_nut_compute_buoy
117
118 end interface
119#elif HAVE_OPENCL
120 interface
121 subroutine opencl_vreman_nut_compute(a11_d, a12_d, a13_d, &
122 a21_d, a22_d, a23_d, &
123 a31_d, a32_d, a33_d, &
124 delta_d, nut_d, mult_d, c, eps, n) &
125 bind(c, name = 'opencl_vreman_nut_compute')
126 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
127 import c_rp
128 type(c_ptr), value :: a11_d, a12_d, a13_d, &
129 a21_d, a22_d, a23_d, &
130 a31_d, a32_d, a33_d, &
131 delta_d, nut_d, mult_d
132 integer(c_int) :: n
133 real(c_rp) :: c, eps
134 end subroutine opencl_vreman_nut_compute
135
136
137 subroutine opencl_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
138 a21_d, a22_d, a23_d, &
139 a31_d, a32_d, a33_d, &
140 delta_d, nut_d, mult_d, c, eps, n, &
141 dTdx_d, dTdy_d, dTdz_d, g, ri_c, ref_temp) &
142 bind(c, name = 'opencl_vreman_nut_compute_buoy')
143 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
144 import c_rp
145 type(c_ptr), value :: a11_d, a12_d, a13_d, &
146 a21_d, a22_d, a23_d, &
147 a31_d, a32_d, a33_d, &
148 delta_d, nut_d, mult_d
149 integer(c_int) :: n
150 real(c_rp) :: c, eps
151 type(c_ptr), value :: dTdx_d, dTdy_d, dTdz_d
152 real(c_rp) :: g(3)
153 real(c_rp) :: ri_c, ref_temp
154 end subroutine opencl_vreman_nut_compute_buoy
155
156 end interface
157#elif HAVE_METAL
158 interface
159 subroutine metal_vreman_nut_compute(a11_d, a12_d, a13_d, &
160 a21_d, a22_d, a23_d, &
161 a31_d, a32_d, a33_d, &
162 delta_d, nut_d, mult_d, c, eps, n) &
163 bind(c, name = 'metal_vreman_nut_compute')
164 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
165 import c_rp
166 type(c_ptr), value :: a11_d, a12_d, a13_d, &
167 a21_d, a22_d, a23_d, &
168 a31_d, a32_d, a33_d, &
169 delta_d, nut_d, mult_d
170 integer(c_int) :: n
171 real(c_rp) :: c, eps
172 end subroutine metal_vreman_nut_compute
173
174
175 subroutine metal_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
176 a21_d, a22_d, a23_d, &
177 a31_d, a32_d, a33_d, &
178 delta_d, nut_d, mult_d, c, eps, n, &
179 dTdx_d, dTdy_d, dTdz_d, g, ri_c, ref_temp) &
180 bind(c, name = 'metal_vreman_nut_compute_buoy')
181 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
182 import c_rp
183 type(c_ptr), value :: a11_d, a12_d, a13_d, &
184 a21_d, a22_d, a23_d, &
185 a31_d, a32_d, a33_d, &
186 delta_d, nut_d, mult_d
187 integer(c_int) :: n
188 real(c_rp) :: c, eps
189 type(c_ptr), value :: dTdx_d, dTdy_d, dTdz_d
190 real(c_rp) :: g(3)
191 real(c_rp) :: ri_c, ref_temp
192 end subroutine metal_vreman_nut_compute_buoy
193
194 end interface
195#endif
196
199
200contains
201
203 subroutine device_vreman_nut_compute(a11_d, a12_d, a13_d, &
204 a21_d, a22_d, a23_d, &
205 a31_d, a32_d, a33_d, &
206 delta_d, nut_d, mult_d, c, eps, n)
207 type(c_ptr) :: a11_d, a12_d, a13_d, &
208 a21_d, a22_d, a23_d, &
209 a31_d, a32_d, a33_d, &
210 delta_d, nut_d, mult_d
211 integer :: n
212 real(kind=rp) :: c, eps
213#if HAVE_HIP
214 call hip_vreman_nut_compute(a11_d, a12_d, a13_d, &
215 a21_d, a22_d, a23_d, &
216 a31_d, a32_d, a33_d, &
217 delta_d, nut_d, mult_d, c, eps, n)
218#elif HAVE_CUDA
219 call cuda_vreman_nut_compute(a11_d, a12_d, a13_d, &
220 a21_d, a22_d, a23_d, &
221 a31_d, a32_d, a33_d, &
222 delta_d, nut_d, mult_d, c, eps, n)
223#elif HAVE_OPENCL
224 call opencl_vreman_nut_compute(a11_d, a12_d, a13_d, &
225 a21_d, a22_d, a23_d, &
226 a31_d, a32_d, a33_d, &
227 delta_d, nut_d, mult_d, c, eps, n)
228#elif HAVE_METAL
229 call metal_vreman_nut_compute(a11_d, a12_d, a13_d, &
230 a21_d, a22_d, a23_d, &
231 a31_d, a32_d, a33_d, &
232 delta_d, nut_d, mult_d, c, eps, n)
233#else
234 call neko_error('no device backend configured')
235#endif
236 end subroutine device_vreman_nut_compute
237
238
239 subroutine device_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
240 a21_d, a22_d, a23_d, &
241 a31_d, a32_d, a33_d, &
242 delta_d, nut_d, mult_d, c, eps, n, &
243 dTdx_d, dTdy_d, dTdz_d, g, ri_c, ref_temp)
244 type(c_ptr) :: a11_d, a12_d, a13_d, &
245 a21_d, a22_d, a23_d, &
246 a31_d, a32_d, a33_d, &
247 delta_d, nut_d, mult_d
248 type(c_ptr) :: dtdx_d, dtdy_d, dtdz_d
249 integer :: n
250 real(kind=rp) :: c, eps
251 real(kind=rp) :: g(3), ri_c, ref_temp
252#if HAVE_HIP
253 call hip_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
254 a21_d, a22_d, a23_d, &
255 a31_d, a32_d, a33_d, &
256 delta_d, nut_d, mult_d, c, eps, n, &
257 dtdx_d, dtdy_d, dtdz_d, g, ri_c, ref_temp)
258#elif HAVE_CUDA
259 call cuda_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
260 a21_d, a22_d, a23_d, &
261 a31_d, a32_d, a33_d, &
262 delta_d, nut_d, mult_d, c, eps, n, &
263 dtdx_d, dtdy_d, dtdz_d, g, ri_c, ref_temp)
264#elif HAVE_OPENCL
265 call opencl_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
266 a21_d, a22_d, a23_d, &
267 a31_d, a32_d, a33_d, &
268 delta_d, nut_d, mult_d, c, eps, n, &
269 dtdx_d, dtdy_d, dtdz_d, g, ri_c, ref_temp)
270#elif HAVE_METAL
271 call metal_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, &
272 a21_d, a22_d, a23_d, &
273 a31_d, a32_d, a33_d, &
274 delta_d, nut_d, mult_d, c, eps, n, &
275 dtdx_d, dtdy_d, dtdz_d, g, ri_c, ref_temp)
276#else
277 call neko_error('no device backend configured (vreman buoyancy)')
278#endif
279 end subroutine device_vreman_nut_compute_buoy
280
281
282end module device_vreman_nut
Definition comm.F90:1
type(mpi_datatype), public mpi_real_precision
MPI type for working precision of REAL types.
Definition comm.F90:54
integer, public pe_size
MPI size of communicator.
Definition comm.F90:62
type(mpi_comm), public neko_comm
MPI communicator.
Definition comm.F90:46
subroutine, public device_vreman_nut_compute(a11_d, a12_d, a13_d, a21_d, a22_d, a23_d, a31_d, a32_d, a33_d, delta_d, nut_d, mult_d, c, eps, n)
Compute the eddy viscosity field for the Sigma model indevice.
subroutine, public device_vreman_nut_compute_buoy(a11_d, a12_d, a13_d, a21_d, a22_d, a23_d, a31_d, a32_d, a33_d, delta_d, nut_d, mult_d, c, eps, n, dtdx_d, dtdy_d, dtdz_d, g, ri_c, ref_temp)
integer, parameter, public c_rp
Definition num_types.f90:15
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Utilities.
Definition utils.f90:35
void opencl_vreman_nut_compute(void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *mult, real *c, real *eps, int *n)
Definition vreman_nut.c:51
void opencl_vreman_nut_compute_buoy(void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *mult, real *c, real *eps, int *n, void *dTdx, void *dTdy, void *dTdz, real *g, real *ri_c, real *ref_temp)
Definition vreman_nut.c:100
void cuda_vreman_nut_compute(void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *mult, real *c, real *eps, int *n)
Definition vreman_nut.cu:50
void cuda_vreman_nut_compute_buoy(void *a11, void *a12, void *a13, void *a21, void *a22, void *a23, void *a31, void *a32, void *a33, void *delta, void *nut, void *mult, real *c, real *eps, int *n, void *dTdx, void *dTdy, void *dTdz, real *g, real *ri_c, real *ref_temp)
Definition vreman_nut.cu:70