Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
spalding_device.F90
Go to the documentation of this file.
1! Copyright (c) 2025, 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!
35 use num_types, only : rp, c_rp
36 use, intrinsic :: iso_c_binding, only : c_ptr
37 use utils, only : neko_error
38 implicit none
39 private
40
41#ifdef HAVE_HIP
42 interface
43 subroutine hip_spalding_compute(u_d, v_d, w_d, &
44 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
45 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
46 kappa, B, tstep) &
47 bind(c, name = 'hip_spalding_compute')
48 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
49 use num_types, only : c_rp
50 implicit none
51 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
52 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
53 real(c_rp) :: kappa, B
54 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
55 integer(c_int) :: n_nodes, tstep
56 end subroutine hip_spalding_compute
57 end interface
58#elif HAVE_CUDA
59 interface
60 subroutine cuda_spalding_compute(u_d, v_d, w_d, &
61 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
62 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
63 kappa, B, tstep) &
64 bind(c, name = 'cuda_spalding_compute')
65 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
66 use num_types, only : c_rp
67 implicit none
68 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
69 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
70 real(c_rp) :: kappa, B
71 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
72 integer(c_int) :: n_nodes, tstep
73 end subroutine cuda_spalding_compute
74 end interface
75#elif HAVE_OPENCL
76 interface
77 subroutine opencl_spalding_compute(u_d, v_d, w_d, &
78 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
79 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
80 kappa, B, tstep) &
81 bind(c, name = 'opencl_spalding_compute')
82 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
83 use num_types, only : c_rp
84 implicit none
85 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
86 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
87 real(c_rp) :: kappa, B
88 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
89 integer(c_int) :: n_nodes, tstep
90 end subroutine opencl_spalding_compute
91 end interface
92#elif HAVE_METAL
93 interface
94 subroutine metal_spalding_compute(u_d, v_d, w_d, &
95 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
96 tau_x_d, tau_y_d, tau_z_d, n_nodes, &
97 kappa, B, tstep) &
98 bind(c, name = 'metal_spalding_compute')
99 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
100 use num_types, only : c_rp
101 implicit none
102 type(c_ptr), value :: u_d, v_d, w_d, rho_w_d
103 type(c_ptr), value :: n_x_d, n_y_d, n_z_d, h_d, nu_d
104 real(c_rp) :: kappa, B
105 type(c_ptr), value :: tau_x_d, tau_y_d, tau_z_d
106 integer(c_int) :: n_nodes, tstep
107 end subroutine metal_spalding_compute
108 end interface
109#endif
111
112contains
116 subroutine spalding_compute_device(u_d, v_d, w_d, &
117 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, tau_x_d, tau_y_d, tau_z_d, &
118 n_nodes, kappa, B, tstep)
119 integer, intent(in) :: n_nodes, tstep
120 type(c_ptr), intent(in) :: u_d, v_d, w_d, rho_w_d
121 type(c_ptr), intent(in) :: n_x_d, n_y_d, n_z_d, h_d, nu_d
122 type(c_ptr), intent(inout) :: tau_x_d, tau_y_d, tau_z_d
123 real(kind=rp), intent(in) :: kappa, b
124
125#if HAVE_HIP
126 call hip_spalding_compute(u_d, v_d, w_d, &
127 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
128 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
129#elif HAVE_CUDA
130 call cuda_spalding_compute(u_d, v_d, w_d, &
131 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
132 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
133#elif HAVE_OPENCL
134 call opencl_spalding_compute(u_d, v_d, w_d, &
135 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
136 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
137#elif HAVE_METAL
138 call metal_spalding_compute(u_d, v_d, w_d, &
139 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
140 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
141#else
142 call neko_error('No device backend configured')
143#endif
144
145 end subroutine spalding_compute_device
146end module spalding_device
integer, parameter, public c_rp
Definition num_types.f90:15
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Implements the device kernel for the spalding_t type.
subroutine, public spalding_compute_device(u_d, v_d, w_d, n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
Compute the wall shear stress on device using Spalding's model.
Utilities.
Definition utils.f90:35
void opencl_spalding_compute(void *u_d, void *v_d, void *w_d, void *n_x_d, void *n_y_d, void *n_z_d, void *nu_d, void *rho_w_d, void *h_d, void *tau_x_d, void *tau_y_d, void *tau_z_d, int *n_nodes, real *kappa, real *B, int *tstep)
Definition spalding.c:49
void cuda_spalding_compute(void *u_d, void *v_d, void *w_d, void *n_x_d, void *n_y_d, void *n_z_d, void *nu_d, void *rho_w_d, void *h_d, void *tau_x_d, void *tau_y_d, void *tau_z_d, int *n_nodes, real *kappa, real *B, int *tstep)
Definition spalding.cu:43