Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_dynamic_smagorinsky_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_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, &
46 s12_d, s13_d, s23_d, &
47 mult_d, n) &
48 bind(c, name = 'hip_s_abs_compute')
49 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
50 import c_rp
51 type(c_ptr), value :: s_abs_d, s11_d, s22_d, s33_d, &
52 s12_d, s13_d, s23_d, &
53 mult_d
54 integer(c_int) :: n
55 end subroutine hip_s_abs_compute
56 end interface
57 interface
58 subroutine hip_lij_compute_part1(l11_d, l22_d, l33_d, &
59 l12_d, l13_d, l23_d, &
60 u_d, v_d, w_d, &
61 fu_d, fv_d, fw_d, &
62 fuu_d, fvv_d, fww_d, &
63 fuv_d, fuw_d, fvw_d, n) &
64 bind(c, name = 'hip_lij_compute_part1')
65 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
66 import c_rp
67 type(c_ptr), value :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
68 u_d, v_d, w_d, fu_d, fv_d, fw_d, &
69 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
70 integer(c_int) :: n
71 end subroutine hip_lij_compute_part1
72 end interface
73 interface
74 subroutine hip_lij_compute_part2(l11_d, l22_d, l33_d, &
75 l12_d, l13_d, l23_d, &
76 fuu_d, fvv_d, fww_d, &
77 fuv_d, fuw_d, fvw_d, n) &
78 bind(c, name = 'hip_lij_compute_part2')
79 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
80 import c_rp
81 type(c_ptr), value :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
82 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
83 integer(c_int) :: n
84 end subroutine hip_lij_compute_part2
85 end interface
86 interface
87 subroutine hip_mij_compute_part1(m11_d, m22_d, m33_d, &
88 m12_d, m13_d, m23_d, &
89 s_abs_d, s11_d, s22_d, s33_d, &
90 s12_d, s13_d, s23_d, &
91 fs_abs_d, fs11_d, fs22_d, fs33_d, &
92 fs12_d, fs13_d, fs23_d, &
93 fsabss11_d, fsabss22_d, fsabss33_d, &
94 fsabss12_d, fsabss13_d, fsabss23_d, &
95 delta_ratio2, n) &
96 bind(c, name = 'hip_mij_compute_part1')
97 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
98 import c_rp
99 type(c_ptr), value :: m11_d, m22_d, m33_d, &
100 m12_d, m13_d, m23_d, &
101 s_abs_d, s11_d, s22_d, s33_d, &
102 s12_d, s13_d, s23_d, &
103 fs_abs_d, fs11_d, fs22_d, fs33_d, &
104 fs12_d, fs13_d, fs23_d, &
105 fsabss11_d, fsabss22_d, fsabss33_d, &
106 fsabss12_d, fsabss13_d, fsabss23_d
107 real(c_rp) :: delta_ratio2
108 integer(c_int) :: n
109 end subroutine hip_mij_compute_part1
110 end interface
111 interface
112 subroutine hip_mij_nut_compute_part2(m11_d, m22_d, m33_d, &
113 m12_d, m13_d, m23_d, &
114 l11_d, l22_d, l33_d, &
115 l12_d, l13_d, l23_d, &
116 fsabss11_d, fsabss22_d, fsabss33_d, &
117 fsabss12_d, fsabss13_d, fsabss23_d, &
118 num_d, den_d, c_dyn_d, delta_d, &
119 s_abs_d, nut_d, alpha, n) &
120 bind(c, name = 'hip_mij_nut_compute_part2')
121 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
122 import c_rp
123 type(c_ptr), value :: m11_d, m22_d, m33_d, &
124 m12_d, m13_d, m23_d, &
125 l11_d, l22_d, l33_d, &
126 l12_d, l13_d, l23_d, &
127 fsabss11_d, fsabss22_d, fsabss33_d, &
128 fsabss12_d, fsabss13_d, fsabss23_d, &
129 num_d, den_d, c_dyn_d, delta_d, s_abs_d, nut_d
130 real(c_rp) :: alpha
131 integer(c_int) :: n
132 end subroutine hip_mij_nut_compute_part2
133 end interface
134#elif HAVE_CUDA
135 interface
136 subroutine cuda_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, &
137 s12_d, s13_d, s23_d, &
138 mult_d, n) &
139 bind(c, name = 'cuda_s_abs_compute')
140 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
141 import c_rp
142 type(c_ptr), value :: s_abs_d, s11_d, s22_d, s33_d, &
143 s12_d, s13_d, s23_d, &
144 mult_d
145 integer(c_int) :: n
146 end subroutine cuda_s_abs_compute
147 end interface
148 interface
149 subroutine cuda_lij_compute_part1(l11_d, l22_d, l33_d, &
150 l12_d, l13_d, l23_d, &
151 u_d, v_d, w_d, &
152 fu_d, fv_d, fw_d, &
153 fuu_d, fvv_d, fww_d, &
154 fuv_d, fuw_d, fvw_d, n) &
155 bind(c, name = 'cuda_lij_compute_part1')
156 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
157 import c_rp
158 type(c_ptr), value :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
159 u_d, v_d, w_d, fu_d, fv_d, fw_d, &
160 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
161 integer(c_int) :: n
162 end subroutine cuda_lij_compute_part1
163 end interface
164 interface
165 subroutine cuda_lij_compute_part2(l11_d, l22_d, l33_d, &
166 l12_d, l13_d, l23_d, &
167 fuu_d, fvv_d, fww_d, &
168 fuv_d, fuw_d, fvw_d, n) &
169 bind(c, name = 'cuda_lij_compute_part2')
170 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
171 import c_rp
172 type(c_ptr), value :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
173 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
174 integer(c_int) :: n
175 end subroutine cuda_lij_compute_part2
176 end interface
177 interface
178 subroutine cuda_mij_compute_part1(m11_d, m22_d, m33_d, &
179 m12_d, m13_d, m23_d, &
180 s_abs_d, s11_d, s22_d, s33_d, &
181 s12_d, s13_d, s23_d, &
182 fs_abs_d, fs11_d, fs22_d, fs33_d, &
183 fs12_d, fs13_d, fs23_d, &
184 fsabss11_d, fsabss22_d, fsabss33_d, &
185 fsabss12_d, fsabss13_d, fsabss23_d, &
186 delta_ratio2, n) &
187 bind(c, name = 'cuda_mij_compute_part1')
188 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
189 import c_rp
190 type(c_ptr), value :: m11_d, m22_d, m33_d, &
191 m12_d, m13_d, m23_d, &
192 s_abs_d, s11_d, s22_d, s33_d, &
193 s12_d, s13_d, s23_d, &
194 fs_abs_d, fs11_d, fs22_d, fs33_d, &
195 fs12_d, fs13_d, fs23_d, &
196 fsabss11_d, fsabss22_d, fsabss33_d, &
197 fsabss12_d, fsabss13_d, fsabss23_d
198 real(c_rp) :: delta_ratio2
199 integer(c_int) :: n
200 end subroutine cuda_mij_compute_part1
201 end interface
202 interface
203 subroutine cuda_mij_nut_compute_part2(m11_d, m22_d, m33_d, &
204 m12_d, m13_d, m23_d, &
205 l11_d, l22_d, l33_d, &
206 l12_d, l13_d, l23_d, &
207 fsabss11_d, fsabss22_d, fsabss33_d, &
208 fsabss12_d, fsabss13_d, fsabss23_d, &
209 num_d, den_d, c_dyn_d, delta_d, &
210 s_abs_d, nut_d, alpha, n) &
211 bind(c, name = 'cuda_mij_nut_compute_part2')
212 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
213 import c_rp
214 type(c_ptr), value :: m11_d, m22_d, m33_d, &
215 m12_d, m13_d, m23_d, &
216 l11_d, l22_d, l33_d, &
217 l12_d, l13_d, l23_d, &
218 fsabss11_d, fsabss22_d, fsabss33_d, &
219 fsabss12_d, fsabss13_d, fsabss23_d, &
220 num_d, den_d, c_dyn_d, delta_d, s_abs_d, nut_d
221 real(c_rp) :: alpha
222 integer(c_int) :: n
223 end subroutine cuda_mij_nut_compute_part2
224 end interface
225#elif HAVE_OPENCL
226#endif
227
231contains
232
234 subroutine device_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, &
235 s12_d, s13_d, s23_d, &
236 mult_d, n)
237 type(c_ptr) :: s_abs_d, s11_d, s22_d, s33_d, &
238 s12_d, s13_d, s23_d, &
239 mult_d
240 integer :: n
241#if HAVE_HIP
242 call hip_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, &
243 s12_d, s13_d, s23_d, &
244 mult_d, n)
245#elif HAVE_CUDA
246 call cuda_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, &
247 s12_d, s13_d, s23_d, &
248 mult_d, n)
249#elif HAVE_OPENCL
250 call neko_error('opencl backend is not supported for device_s_abs_compute')
251#else
252 call neko_error('no device backend configured')
253#endif
254 end subroutine device_s_abs_compute
255
257 subroutine device_lij_compute_part1(l11_d, l22_d, l33_d, &
258 l12_d, l13_d, l23_d, &
259 u_d, v_d, w_d, &
260 fu_d, fv_d, fw_d, &
261 fuu_d, fvv_d, fww_d, &
262 fuv_d, fuw_d, fvw_d, n)
263 type(c_ptr) :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
264 u_d, v_d, w_d, fu_d, fv_d, fw_d, &
265 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
266 integer :: n
267#if HAVE_HIP
268 call hip_lij_compute_part1(l11_d, l22_d, l33_d, &
269 l12_d, l13_d, l23_d, &
270 u_d, v_d, w_d, &
271 fu_d, fv_d, fw_d, &
272 fuu_d, fvv_d, fww_d, &
273 fuv_d, fuw_d, fvw_d, n)
274#elif HAVE_CUDA
275 call cuda_lij_compute_part1(l11_d, l22_d, l33_d, &
276 l12_d, l13_d, l23_d, &
277 u_d, v_d, w_d, &
278 fu_d, fv_d, fw_d, &
279 fuu_d, fvv_d, fww_d, &
280 fuv_d, fuw_d, fvw_d, n)
281#elif HAVE_OPENCL
282 call neko_error('opencl backend is not supported &
283 &for device_lij_compute_part1')
284#else
285 call neko_error('no device backend configured')
286#endif
287 end subroutine device_lij_compute_part1
288
290 subroutine device_lij_compute_part2(l11_d, l22_d, l33_d, &
291 l12_d, l13_d, l23_d, &
292 fuu_d, fvv_d, fww_d, &
293 fuv_d, fuw_d, fvw_d, n)
294 type(c_ptr) :: l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, &
295 fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d
296 integer :: n
297#if HAVE_HIP
298 call hip_lij_compute_part2(l11_d, l22_d, l33_d, &
299 l12_d, l13_d, l23_d, &
300 fuu_d, fvv_d, fww_d, &
301 fuv_d, fuw_d, fvw_d, n)
302#elif HAVE_CUDA
303 call cuda_lij_compute_part2(l11_d, l22_d, l33_d, &
304 l12_d, l13_d, l23_d, &
305 fuu_d, fvv_d, fww_d, &
306 fuv_d, fuw_d, fvw_d, n)
307#elif HAVE_OPENCL
308 call neko_error('opencl backend is not supported &
309 &for device_lij_compute_part2')
310#else
311 call neko_error('no device backend configured')
312#endif
313 end subroutine device_lij_compute_part2
314
316 subroutine device_mij_compute_part1(m11_d, m22_d, m33_d, &
317 m12_d, m13_d, m23_d, &
318 s_abs_d, s11_d, s22_d, s33_d, &
319 s12_d, s13_d, s23_d, &
320 fs_abs_d, fs11_d, fs22_d, fs33_d, &
321 fs12_d, fs13_d, fs23_d, &
322 fsabss11_d, fsabss22_d, fsabss33_d, &
323 fsabss12_d, fsabss13_d, fsabss23_d, &
324 delta_ratio2, n)
325 type(c_ptr) :: m11_d, m22_d, m33_d, &
326 m12_d, m13_d, m23_d, &
327 s_abs_d, s11_d, s22_d, s33_d, &
328 s12_d, s13_d, s23_d, &
329 fs_abs_d, fs11_d, fs22_d, fs33_d, &
330 fs12_d, fs13_d, fs23_d, &
331 fsabss11_d, fsabss22_d, fsabss33_d, &
332 fsabss12_d, fsabss13_d, fsabss23_d
333 real(kind=rp) :: delta_ratio2
334 integer :: n
335
336#if HAVE_HIP
337 call hip_mij_compute_part1(m11_d, m22_d, m33_d, &
338 m12_d, m13_d, m23_d, &
339 s_abs_d, s11_d, s22_d, s33_d, &
340 s12_d, s13_d, s23_d, &
341 fs_abs_d, fs11_d, fs22_d, fs33_d, &
342 fs12_d, fs13_d, fs23_d, &
343 fsabss11_d, fsabss22_d, fsabss33_d, &
344 fsabss12_d, fsabss13_d, fsabss23_d, &
345 delta_ratio2, n)
346#elif HAVE_CUDA
347 call cuda_mij_compute_part1(m11_d, m22_d, m33_d, &
348 m12_d, m13_d, m23_d, &
349 s_abs_d, s11_d, s22_d, s33_d, &
350 s12_d, s13_d, s23_d, &
351 fs_abs_d, fs11_d, fs22_d, fs33_d, &
352 fs12_d, fs13_d, fs23_d, &
353 fsabss11_d, fsabss22_d, fsabss33_d, &
354 fsabss12_d, fsabss13_d, fsabss23_d, &
355 delta_ratio2, n)
356#elif HAVE_OPENCL
357 call neko_error('opencl backend is not supported for &
358 &device_mij_compute_part1')
359#else
360 call neko_error('no device backend configured')
361#endif
362 end subroutine device_mij_compute_part1
363
365 subroutine device_mij_nut_compute_part2(m11_d, m22_d, m33_d, &
366 m12_d, m13_d, m23_d, &
367 l11_d, l22_d, l33_d, &
368 l12_d, l13_d, l23_d, &
369 fsabss11_d, fsabss22_d, fsabss33_d, &
370 fsabss12_d, fsabss13_d, fsabss23_d, &
371 num_d, den_d, c_dyn_d, delta_d, &
372 s_abs_d, nut_d, alpha, n)
373 type(c_ptr) :: m11_d, m22_d, m33_d, &
374 m12_d, m13_d, m23_d, &
375 l11_d, l22_d, l33_d, &
376 l12_d, l13_d, l23_d, &
377 fsabss11_d, fsabss22_d, fsabss33_d, &
378 fsabss12_d, fsabss13_d, fsabss23_d, &
379 num_d, den_d, c_dyn_d, delta_d, s_abs_d, nut_d
380 real(kind=rp) :: alpha
381 integer :: n
382
383#if HAVE_HIP
384 call hip_mij_nut_compute_part2(m11_d, m22_d, m33_d, &
385 m12_d, m13_d, m23_d, &
386 l11_d, l22_d, l33_d, &
387 l12_d, l13_d, l23_d, &
388 fsabss11_d, fsabss22_d, fsabss33_d, &
389 fsabss12_d, fsabss13_d, fsabss23_d, &
390 num_d, den_d, c_dyn_d, delta_d, &
391 s_abs_d, nut_d, alpha, n)
392#elif HAVE_CUDA
393 call cuda_mij_nut_compute_part2(m11_d, m22_d, m33_d, &
394 m12_d, m13_d, m23_d, &
395 l11_d, l22_d, l33_d, &
396 l12_d, l13_d, l23_d, &
397 fsabss11_d, fsabss22_d, fsabss33_d, &
398 fsabss12_d, fsabss13_d, fsabss23_d, &
399 num_d, den_d, c_dyn_d, delta_d, &
400 s_abs_d, nut_d, alpha, n)
401#elif HAVE_OPENCL
402 call neko_error('opencl backend is not supported for &
403 &device_mij_nut_compute_part2')
404#else
405 call neko_error('no device backend configured')
406#endif
407 end subroutine device_mij_nut_compute_part2
408
409
410end module device_dynamic_smagorinsky_nut
void cuda_mij_compute_part1(void *m11, void *m22, void *m33, void *m12, void *m13, void *m23, void *s_abs, void *s11, void *s22, void *s33, void *s12, void *s13, void *s23, void *fs_abs, void *fs11, void *fs22, void *fs33, void *fs12, void *fs13, void *fs23, void *fsabss11, void *fsabss22, void *fsabss33, void *fsabss12, void *fsabss13, void *fsabss23, real *delta_ratio2, int *n)
void cuda_s_abs_compute(void *s_abs, void *s11, void *s22, void *s33, void *s12, void *s13, void *s23, void *mult, int *n)
void cuda_lij_compute_part1(void *l11, void *l22, void *l33, void *l12, void *l13, void *l23, void *u, void *v, void *w, void *fu, void *fv, void *fw, void *fuu, void *fvv, void *fww, void *fuv, void *fuw, void *fvw, int *n)
void cuda_mij_nut_compute_part2(void *m11, void *m22, void *m33, void *m12, void *m13, void *m23, void *l11, void *l22, void *l33, void *l12, void *l13, void *l23, void *fsabss11, void *fsabss22, void *fsabss33, void *fsabss12, void *fsabss13, void *fsabss23, void *num, void *den, void *c_dyn, void *delta, void *s_abs, void *nut, real *alpha, int *n)
void cuda_lij_compute_part2(void *l11, void *l22, void *l33, void *l12, void *l13, void *l23, void *fuu, void *fvv, void *fww, void *fuv, void *fuw, void *fvw, int *n)
Definition comm.F90:1
type(mpi_comm) neko_comm
MPI communicator.
Definition comm.F90:16
type(mpi_datatype) mpi_real_precision
MPI type for working precision of REAL types.
Definition comm.F90:23
integer pe_size
MPI size of communicator.
Definition comm.F90:31
subroutine, public device_lij_compute_part1(l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, u_d, v_d, w_d, fu_d, fv_d, fw_d, fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d, n)
part 1 of the computing of the lij field
subroutine, public device_mij_nut_compute_part2(m11_d, m22_d, m33_d, m12_d, m13_d, m23_d, l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, fsabss11_d, fsabss22_d, fsabss33_d, fsabss12_d, fsabss13_d, fsabss23_d, num_d, den_d, c_dyn_d, delta_d, s_abs_d, nut_d, alpha, n)
part 1 of the computing of the mij field
subroutine, public device_mij_compute_part1(m11_d, m22_d, m33_d, m12_d, m13_d, m23_d, s_abs_d, s11_d, s22_d, s33_d, s12_d, s13_d, s23_d, fs_abs_d, fs11_d, fs22_d, fs33_d, fs12_d, fs13_d, fs23_d, fsabss11_d, fsabss22_d, fsabss33_d, fsabss12_d, fsabss13_d, fsabss23_d, delta_ratio2, n)
part 1 of the computing of the mij field
subroutine, public device_s_abs_compute(s_abs_d, s11_d, s22_d, s33_d, s12_d, s13_d, s23_d, mult_d, n)
Compute the s_abs field for the Sigma model indevice.
subroutine, public device_lij_compute_part2(l11_d, l22_d, l33_d, l12_d, l13_d, l23_d, fuu_d, fvv_d, fww_d, fuv_d, fuw_d, fvw_d, n)
part 2 of the computing of the lij field
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Utilities.
Definition utils.f90:35