Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_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_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
46 s12_d, s13_d, s23_d, &
47 delta_d, nut_d, mult_d, c_s, n) &
48 bind(c, name = 'hip_smagorinsky_nut_compute')
49 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
50 import c_rp
51 type(c_ptr), value :: s11_d, s22_d, s33_d, &
52 s12_d, s13_d, s23_d, &
53 delta_d, nut_d, mult_d
54 integer(c_int) :: n
55 real(c_rp) :: c_s
56 end subroutine hip_smagorinsky_nut_compute
57 end interface
58#elif HAVE_CUDA
59 interface
60 subroutine cuda_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
61 s12_d, s13_d, s23_d, &
62 delta_d, nut_d, mult_d, c_s, n) &
63 bind(c, name = 'cuda_smagorinsky_nut_compute')
64 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
65 import c_rp
66 type(c_ptr), value :: s11_d, s22_d, s33_d, &
67 s12_d, s13_d, s23_d, &
68 delta_d, nut_d, mult_d
69 integer(c_int) :: n
70 real(c_rp) :: c_s
71 end subroutine cuda_smagorinsky_nut_compute
72 end interface
73#elif HAVE_OPENCL
74 interface
75 subroutine opencl_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
76 s12_d, s13_d, s23_d, &
77 delta_d, nut_d, mult_d, c_s, n) &
78 bind(c, name = 'opencl_smagorinsky_nut_compute')
79 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
80 import c_rp
81 type(c_ptr), value :: s11_d, s22_d, s33_d, &
82 s12_d, s13_d, s23_d, &
83 delta_d, nut_d, mult_d
84 integer(c_int) :: n
85 real(c_rp) :: c_s
87 end interface
88#elif HAVE_METAL
89 interface
90 subroutine metal_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
91 s12_d, s13_d, s23_d, &
92 delta_d, nut_d, mult_d, c_s, n) &
93 bind(c, name = 'metal_smagorinsky_nut_compute')
94 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
95 import c_rp
96 type(c_ptr), value :: s11_d, s22_d, s33_d, &
97 s12_d, s13_d, s23_d, &
98 delta_d, nut_d, mult_d
99 integer(c_int) :: n
100 real(c_rp) :: c_s
101 end subroutine metal_smagorinsky_nut_compute
102 end interface
103#endif
104
106
107contains
108
110 subroutine device_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
111 s12_d, s13_d, s23_d, &
112 delta_d, nut_d, mult_d, c_s, n)
113 type(c_ptr) :: s11_d, s22_d, s33_d, &
114 s12_d, s13_d, s23_d, &
115 delta_d, nut_d, mult_d
116 integer :: n
117 real(kind=rp) :: c_s
118#if HAVE_HIP
119 call hip_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
120 s12_d, s13_d, s23_d, &
121 delta_d, nut_d, mult_d, c_s, n)
122#elif HAVE_CUDA
123 call cuda_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
124 s12_d, s13_d, s23_d, &
125 delta_d, nut_d, mult_d, c_s, n)
126#elif HAVE_OPENCL
127 call opencl_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
128 s12_d, s13_d, s23_d, &
129 delta_d, nut_d, mult_d, c_s, n)
130#elif HAVE_METAL
131 call metal_smagorinsky_nut_compute(s11_d, s22_d, s33_d, &
132 s12_d, s13_d, s23_d, &
133 delta_d, nut_d, mult_d, c_s, n)
134#else
135 call neko_error('no device backend configured')
136#endif
137 end subroutine device_smagorinsky_nut_compute
138
139
140end module device_smagorinsky_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_smagorinsky_nut_compute(s11_d, s22_d, s33_d, s12_d, s13_d, s23_d, delta_d, nut_d, mult_d, c_s, n)
Compute the eddy viscosity field for the Sigma model indevice.
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_smagorinsky_nut_compute(void *s11, void *s22, void *s33, void *s12, void *s13, void *s23, void *delta, void *nut, void *mult, real *c_s, int *n)
void cuda_smagorinsky_nut_compute(void *s11, void *s22, void *s33, void *s12, void *s13, void *s23, void *delta, void *nut, void *mult, real *c_s, int *n)