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#endif
78
79contains
83 subroutine spalding_compute_device(u_d, v_d, w_d, &
84 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, &
85 n_nodes, kappa, B, tstep)
86 integer, intent(in) :: n_nodes, tstep
87 type(c_ptr), intent(in) :: u_d, v_d, w_d, rho_w_d
88 type(c_ptr), intent(in) :: n_x_d, n_y_d, n_z_d, h_d, nu_d
89 type(c_ptr), intent(inout) :: tau_x_d, tau_y_d, tau_z_d
90 real(kind=rp), intent(in) :: kappa, b
91
92#if HAVE_HIP
93 call hip_spalding_compute(u_d, v_d, w_d, &
94 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
95 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
96#elif HAVE_CUDA
97 call cuda_spalding_compute(u_d, v_d, w_d, &
98 n_x_d, n_y_d, n_z_d, nu_d, rho_w_d, h_d, &
99 tau_x_d, tau_y_d, tau_z_d, n_nodes, kappa, b, tstep)
100#elif HAVE_OPENCL
101 call neko_error("OPENCL is not implemented for Spalding's model")
102#else
103 call neko_error('No device backend configured')
104#endif
105
106 end subroutine spalding_compute_device
107end 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 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