Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
compressible_ops_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, intrinsic :: iso_c_binding, only: c_ptr, c_int
36 use num_types, only: rp, c_rp
37 use field, only: field_t
38 use utils, only: neko_error
39 implicit none
40 private
41
42#ifdef HAVE_HIP
43 interface
44 subroutine hip_compute_max_wave_speed(max_wave_speed_d, u_d, v_d, w_d, &
45 gamma, p_d, rho_d, n) &
46 bind(c, name = 'hip_compute_max_wave_speed')
47 use, intrinsic :: iso_c_binding
48 import c_rp
49 type(c_ptr), value :: max_wave_speed_d, u_d, v_d, w_d, p_d, rho_d
50 real(c_rp) :: gamma
51 integer(c_int) :: n
52 end subroutine hip_compute_max_wave_speed
53 end interface
54
55 interface
56 subroutine hip_compute_entropy(S_d, p_d, rho_d, gamma, n) &
57 bind(c, name = 'hip_compute_entropy')
58 use, intrinsic :: iso_c_binding
59 import c_rp
60 type(c_ptr), value :: S_d, p_d, rho_d
61 real(c_rp) :: gamma
62 integer(c_int) :: n
63 end subroutine hip_compute_entropy
64 end interface
65
66#elif HAVE_CUDA
67 interface
68 subroutine cuda_compute_max_wave_speed(max_wave_speed_d, u_d, v_d, w_d, &
69 gamma, p_d, rho_d, n) &
70 bind(c, name = 'cuda_compute_max_wave_speed')
71 use, intrinsic :: iso_c_binding
72 import c_rp
73 type(c_ptr), value :: max_wave_speed_d, u_d, v_d, w_d, p_d, rho_d
74 real(c_rp) :: gamma
75 integer(c_int) :: n
76 end subroutine cuda_compute_max_wave_speed
77 end interface
78
79 interface
80 subroutine cuda_compute_entropy(S_d, p_d, rho_d, gamma, n) &
81 bind(c, name = 'cuda_compute_entropy')
82 use, intrinsic :: iso_c_binding
83 import c_rp
84 type(c_ptr), value :: S_d, p_d, rho_d
85 real(c_rp) :: gamma
86 integer(c_int) :: n
87 end subroutine cuda_compute_entropy
88 end interface
89
90#elif HAVE_OPENCL
91 interface
92 subroutine opencl_compute_max_wave_speed(max_wave_speed_d, u_d, v_d, w_d, &
93 gamma, p_d, rho_d, n) &
94 bind(c, name = 'opencl_compute_max_wave_speed')
95 use, intrinsic :: iso_c_binding
96 import c_rp
97 type(c_ptr), value :: max_wave_speed_d, u_d, v_d, w_d, p_d, rho_d
98 real(c_rp), value :: gamma
99 integer(c_int), value :: n
100 end subroutine opencl_compute_max_wave_speed
101 end interface
102
103 interface
104 subroutine opencl_compute_entropy(S_d, p_d, rho_d, gamma, n) &
105 bind(c, name = 'opencl_compute_entropy')
106 use, intrinsic :: iso_c_binding
107 import c_rp
108 type(c_ptr), value :: S_d, p_d, rho_d
109 real(c_rp), value :: gamma
110 integer(c_int), value :: n
111 end subroutine opencl_compute_entropy
112 end interface
113#endif
114
117
118contains
119
121 subroutine compressible_ops_device_compute_max_wave_speed(max_wave_speed, u, v, w, gamma, p, rho, n)
122 integer, intent(in) :: n
123 real(kind=rp), intent(in) :: gamma
124 type(field_t), intent(inout) :: max_wave_speed
125 type(field_t), intent(in) :: u, v, w, p, rho
126
127#ifdef HAVE_HIP
128 call hip_compute_max_wave_speed(max_wave_speed%x_d, u%x_d, v%x_d, w%x_d, gamma, p%x_d, rho%x_d, n)
129#elif HAVE_CUDA
130 call cuda_compute_max_wave_speed(max_wave_speed%x_d, u%x_d, v%x_d, w%x_d, gamma, p%x_d, rho%x_d, n)
131#elif HAVE_OPENCL
132 call opencl_compute_max_wave_speed(max_wave_speed%x_d, u%x_d, v%x_d, w%x_d, gamma, p%x_d, rho%x_d, n)
133#else
134 call neko_error('No device backend configured')
135#endif
137
139 subroutine compressible_ops_device_compute_entropy(S, p, rho, gamma, n)
140 integer, intent(in) :: n
141 real(kind=rp), intent(in) :: gamma
142 type(field_t), intent(inout) :: s
143 type(field_t), intent(in) :: p, rho
144
145#ifdef HAVE_HIP
146 call hip_compute_entropy(s%x_d, p%x_d, rho%x_d, gamma, n)
147#elif HAVE_CUDA
148 call cuda_compute_entropy(s%x_d, p%x_d, rho%x_d, gamma, n)
149#elif HAVE_OPENCL
150 call opencl_compute_entropy(s%x_d, p%x_d, rho%x_d, gamma, n)
151#else
152 call neko_error('No device backend configured')
153#endif
155
void opencl_compute_entropy(void *S_d, void *p_d, void *rho_d, real gamma, int n)
void cuda_compute_entropy(void *S_d, void *p_d, void *rho_d, real *gamma, int *n)
void opencl_compute_max_wave_speed(void *max_wave_speed, void *u, void *v, void *w, real gamma, void *p, void *rho, int n)
void cuda_compute_max_wave_speed(void *max_wave_speed_d, void *u_d, void *v_d, void *w_d, real *gamma, void *p_d, void *rho_d, int *n)
Device implementation of compressible flow operations.
subroutine, public compressible_ops_device_compute_entropy(s, p, rho, gamma, n)
Compute entropy field S = 1/(gamma-1) * rho * (log(p) - gamma * log(rho)) on device.
subroutine, public compressible_ops_device_compute_max_wave_speed(max_wave_speed, u, v, w, gamma, p, rho, n)
Compute maximum wave speed for compressible flows on device.
Defines a field.
Definition field.f90:34
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