Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_sigma_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_sigma_nut_compute(g11_d, g12_d, g13_d, &
46 g21_d, g22_d, g23_d, &
47 g31_d, g32_d, g33_d, &
48 delta_d, nut_d, mult_d, c, eps, n) &
49 bind(c, name = 'hip_sigma_nut_compute')
50 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
51 import c_rp
52 type(c_ptr), value :: g11_d, g12_d, g13_d, &
53 g21_d, g22_d, g23_d, &
54 g31_d, g32_d, g33_d, &
55 delta_d, nut_d, mult_d
56 integer(c_int) :: n
57 real(c_rp) :: c, eps
58 end subroutine hip_sigma_nut_compute
59 end interface
60#elif HAVE_CUDA
61 interface
62 subroutine cuda_sigma_nut_compute(g11_d, g12_d, g13_d, &
63 g21_d, g22_d, g23_d, &
64 g31_d, g32_d, g33_d, &
65 delta_d, nut_d, mult_d, c, eps, n) &
66 bind(c, name = 'cuda_sigma_nut_compute')
67 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
68 import c_rp
69 type(c_ptr), value :: g11_d, g12_d, g13_d, &
70 g21_d, g22_d, g23_d, &
71 g31_d, g32_d, g33_d, &
72 delta_d, nut_d, mult_d
73 integer(c_int) :: n
74 real(c_rp) :: c, eps
75 end subroutine cuda_sigma_nut_compute
76 end interface
77#elif HAVE_OPENCL
78 interface
79 subroutine opencl_sigma_nut_compute(g11_d, g12_d, g13_d, &
80 g21_d, g22_d, g23_d, &
81 g31_d, g32_d, g33_d, &
82 delta_d, nut_d, mult_d, c, eps, n) &
83 bind(c, name = 'opencl_sigma_nut_compute')
84 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
85 import c_rp
86 type(c_ptr), value :: g11_d, g12_d, g13_d, &
87 g21_d, g22_d, g23_d, &
88 g31_d, g32_d, g33_d, &
89 delta_d, nut_d, mult_d
90 integer(c_int) :: n
91 real(c_rp) :: c, eps
92 end subroutine opencl_sigma_nut_compute
93 end interface
94#elif HAVE_METAL
95 interface
96 subroutine metal_sigma_nut_compute(g11_d, g12_d, g13_d, &
97 g21_d, g22_d, g23_d, &
98 g31_d, g32_d, g33_d, &
99 delta_d, nut_d, mult_d, c, eps, n) &
100 bind(c, name = 'metal_sigma_nut_compute')
101 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
102 import c_rp
103 type(c_ptr), value :: g11_d, g12_d, g13_d, &
104 g21_d, g22_d, g23_d, &
105 g31_d, g32_d, g33_d, &
106 delta_d, nut_d, mult_d
107 integer(c_int) :: n
108 real(c_rp) :: c, eps
109 end subroutine metal_sigma_nut_compute
110 end interface
111#endif
112
114
115contains
116
118 subroutine device_sigma_nut_compute(g11_d, g12_d, g13_d, &
119 g21_d, g22_d, g23_d, &
120 g31_d, g32_d, g33_d, &
121 delta_d, nut_d, mult_d, c, eps, n)
122 type(c_ptr) :: g11_d, g12_d, g13_d, &
123 g21_d, g22_d, g23_d, &
124 g31_d, g32_d, g33_d, &
125 delta_d, nut_d, mult_d
126 integer :: n
127 real(kind=rp) :: c, eps
128#if HAVE_HIP
129 call hip_sigma_nut_compute(g11_d, g12_d, g13_d, &
130 g21_d, g22_d, g23_d, &
131 g31_d, g32_d, g33_d, &
132 delta_d, nut_d, mult_d, c, eps, n)
133#elif HAVE_CUDA
134 call cuda_sigma_nut_compute(g11_d, g12_d, g13_d, &
135 g21_d, g22_d, g23_d, &
136 g31_d, g32_d, g33_d, &
137 delta_d, nut_d, mult_d, c, eps, n)
138#elif HAVE_OPENCL
139 call opencl_sigma_nut_compute(g11_d, g12_d, g13_d, &
140 g21_d, g22_d, g23_d, &
141 g31_d, g32_d, g33_d, &
142 delta_d, nut_d, mult_d, c, eps, n)
143#elif HAVE_METAL
144 call metal_sigma_nut_compute(g11_d, g12_d, g13_d, &
145 g21_d, g22_d, g23_d, &
146 g31_d, g32_d, g33_d, &
147 delta_d, nut_d, mult_d, c, eps, n)
148#else
149 call neko_error('no device backend configured')
150#endif
151 end subroutine device_sigma_nut_compute
152
153
154end module device_sigma_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_sigma_nut_compute(g11_d, g12_d, g13_d, g21_d, g22_d, g23_d, g31_d, g32_d, g33_d, delta_d, nut_d, mult_d, c, eps, 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_sigma_nut_compute(void *g11, void *g12, void *g13, void *g21, void *g22, void *g23, void *g31, void *g32, void *g33, void *delta, void *nut, void *mult, real *c, real *eps, int *n)
Definition sigma_nut.c:49
void cuda_sigma_nut_compute(void *g11, void *g12, void *g13, void *g21, void *g22, void *g23, void *g31, void *g32, void *g33, void *delta, void *nut, void *mult, real *c, real *eps, int *n)
Definition sigma_nut.cu:47