Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_constrain_mixed_bc.F90
Go to the documentation of this file.
1! Copyright (c) 2026, 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!
39 use num_types, only : c_rp, rp
40 use utils, only : neko_error
41 use device, only : glb_cmd_queue
42 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
43 implicit none
44 private
45
46#ifdef HAVE_HIP
47 interface
48 subroutine hip_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
49 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm) &
50 bind(c, name = 'hip_constrain_mixed_bc_zero')
51 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
52 implicit none
53 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
54 integer(c_int) :: m
55 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
56 end subroutine hip_constrain_mixed_bc_zero
57
58 subroutine hip_constrain_mixed_bc_set(mixed_msk, x, y, z, &
59 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
60 values_n, values_t1, values_t2, m, strm) &
61 bind(c, name = 'hip_constrain_mixed_bc_set')
62 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
63 implicit none
64 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
65 integer(c_int) :: m
66 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2
67 type(c_ptr), value :: values_n, values_t1, values_t2, strm
68 end subroutine hip_constrain_mixed_bc_set
69
70 subroutine hip_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
71 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
72 value_n, value_t1, value_t2, m, strm) &
73 bind(c, name = 'hip_constrain_mixed_bc_set_const')
74 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
75 import c_rp
76 implicit none
77 real(c_rp) :: value_n, value_t1, value_t2
78 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
79 integer(c_int) :: m
80 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
82 end interface
83#elif HAVE_CUDA
84 interface
85 subroutine cuda_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
86 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm) &
87 bind(c, name = 'cuda_constrain_mixed_bc_zero')
88 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
89 implicit none
90 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
91 integer(c_int) :: m
92 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
93 end subroutine cuda_constrain_mixed_bc_zero
94
95 subroutine cuda_constrain_mixed_bc_set(mixed_msk, x, y, z, &
96 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
97 values_n, values_t1, values_t2, m, strm) &
98 bind(c, name = 'cuda_constrain_mixed_bc_set')
99 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
100 implicit none
101 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
102 integer(c_int) :: m
103 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2
104 type(c_ptr), value :: values_n, values_t1, values_t2, strm
105 end subroutine cuda_constrain_mixed_bc_set
106
107 subroutine cuda_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
108 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
109 value_n, value_t1, value_t2, m, strm) &
110 bind(c, name = 'cuda_constrain_mixed_bc_set_const')
111 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
112 import c_rp
113 implicit none
114 real(c_rp) :: value_n, value_t1, value_t2
115 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
116 integer(c_int) :: m
117 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
119 end interface
120#elif HAVE_OPENCL
121 interface
122 subroutine opencl_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
123 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm) &
124 bind(c, name = 'opencl_constrain_mixed_bc_zero')
125 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
126 implicit none
127 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
128 integer(c_int) :: m
129 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
130 end subroutine opencl_constrain_mixed_bc_zero
131
132 subroutine opencl_constrain_mixed_bc_set(mixed_msk, x, y, z, &
133 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
134 values_n, values_t1, values_t2, m, strm) &
135 bind(c, name = 'opencl_constrain_mixed_bc_set')
136 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
137 implicit none
138 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
139 integer(c_int) :: m
140 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2
141 type(c_ptr), value :: values_n, values_t1, values_t2, strm
142 end subroutine opencl_constrain_mixed_bc_set
143
144 subroutine opencl_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
145 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
146 value_n, value_t1, value_t2, m, strm) &
147 bind(c, name = 'opencl_constrain_mixed_bc_set_const')
148 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
149 import c_rp
150 implicit none
151 real(c_rp) :: value_n, value_t1, value_t2
152 integer(c_int) :: constraint_n, constraint_t1, constraint_t2
153 integer(c_int) :: m
154 type(c_ptr), value :: mixed_msk, x, y, z, n, t1, t2, strm
156 end interface
157#endif
158
162
163contains
164
181 subroutine device_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
182 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm)
183 integer, intent(in) :: constraint_n, constraint_t1, constraint_t2
184 integer, intent(in) :: m
185 type(c_ptr), intent(in) :: mixed_msk, x, y, z
186 type(c_ptr), intent(in) :: n, t1, t2
187 type(c_ptr), intent(in), optional :: strm
188 type(c_ptr) :: strm_
189
190 if (m .lt. 1) return
191
192 if (present(strm)) then
193 strm_ = strm
194 else
195 strm_ = glb_cmd_queue
196 end if
197
198#ifdef HAVE_HIP
199 call hip_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
200 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm_)
201#elif HAVE_CUDA
202 call cuda_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
203 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm_)
204#elif HAVE_OPENCL
205 call opencl_constrain_mixed_bc_zero(mixed_msk, x, y, z, &
206 constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm_)
207#else
208 call neko_error('No device backend configured for mixed BC constraint')
209#endif
210
211 end subroutine device_constrain_mixed_bc_zero
212
235 subroutine device_constrain_mixed_bc_set(mixed_msk, x, y, z, &
236 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
237 values_n, values_t1, values_t2, m, strm)
238 integer, intent(in) :: constraint_n, constraint_t1, constraint_t2
239 integer, intent(in) :: m
240 type(c_ptr), intent(in) :: mixed_msk, x, y, z
241 type(c_ptr), intent(in) :: n, t1, t2
242 type(c_ptr), intent(in) :: values_n, values_t1, values_t2
243 type(c_ptr), intent(in), optional :: strm
244 type(c_ptr) :: strm_
245
246 if (m .lt. 1) return
247
248 if (present(strm)) then
249 strm_ = strm
250 else
251 strm_ = glb_cmd_queue
252 end if
253
254#ifdef HAVE_HIP
255 call hip_constrain_mixed_bc_set(mixed_msk, x, y, z, &
256 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
257 values_n, values_t1, values_t2, m, strm_)
258#elif HAVE_CUDA
259 call cuda_constrain_mixed_bc_set(mixed_msk, x, y, z, &
260 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
261 values_n, values_t1, values_t2, m, strm_)
262#elif HAVE_OPENCL
263 call opencl_constrain_mixed_bc_set(mixed_msk, x, y, z, &
264 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
265 values_n, values_t1, values_t2, m, strm_)
266#else
267 call neko_error('No device backend configured for mixed BC constraint')
268#endif
269
270 end subroutine device_constrain_mixed_bc_set
271
291 subroutine device_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
292 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
293 value_n, value_t1, value_t2, m, strm)
294 integer, intent(in) :: constraint_n, constraint_t1, constraint_t2
295 integer, intent(in) :: m
296 real(kind=rp), intent(in) :: value_n, value_t1, value_t2
297 type(c_ptr), intent(in) :: mixed_msk, x, y, z
298 type(c_ptr), intent(in) :: n, t1, t2
299 type(c_ptr), intent(in), optional :: strm
300 type(c_ptr) :: strm_
301
302 if (m .lt. 1) return
303
304 if (present(strm)) then
305 strm_ = strm
306 else
307 strm_ = glb_cmd_queue
308 end if
309
310#ifdef HAVE_HIP
311 call hip_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
312 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
313 value_n, value_t1, value_t2, m, strm_)
314#elif HAVE_CUDA
315 call cuda_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
316 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
317 value_n, value_t1, value_t2, m, strm_)
318#elif HAVE_OPENCL
319 call opencl_constrain_mixed_bc_set_const(mixed_msk, x, y, z, &
320 constraint_n, constraint_t1, constraint_t2, n, t1, t2, &
321 value_n, value_t1, value_t2, m, strm_)
322#else
323 call neko_error('No device backend configured for mixed BC constraint')
324#endif
325
327
void opencl_constrain_mixed_bc_set(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, void *values_n, void *values_t1, void *values_t2, int *m, cl_command_queue cmd_queue)
void opencl_constrain_mixed_bc_set_const(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, real *value_n, real *value_t1, real *value_t2, int *m, cl_command_queue cmd_queue)
void opencl_constrain_mixed_bc_zero(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, int *m, cl_command_queue cmd_queue)
void cuda_constrain_mixed_bc_zero(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, int *m, cudaStream_t strm)
void cuda_constrain_mixed_bc_set(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, void *values_n, void *values_t1, void *values_t2, int *m, cudaStream_t strm)
void cuda_constrain_mixed_bc_set_const(void *mixed_msk, void *x, void *y, void *z, int *constraint_n, int *constraint_t1, int *constraint_t2, void *n, void *t1, void *t2, real *value_n, real *value_t1, real *value_t2, int *m, cudaStream_t strm)
Device wrappers for basis-aware mixed boundary-condition constraint kernels. These routines operate o...
subroutine, public device_constrain_mixed_bc_zero(mixed_msk, x, y, z, constraint_n, constraint_t1, constraint_t2, n, t1, t2, m, strm)
Constrain mixed-boundary projections by zeroing the selected local components on the device.
subroutine, public device_constrain_mixed_bc_set_const(mixed_msk, x, y, z, constraint_n, constraint_t1, constraint_t2, n, t1, t2, value_n, value_t1, value_t2, m, strm)
Constrain mixed-boundary projections by assigning prescribed local components derived from a constant...
subroutine, public device_constrain_mixed_bc_set(mixed_msk, x, y, z, constraint_n, constraint_t1, constraint_t2, n, t1, t2, values_n, values_t1, values_t2, m, strm)
Constrain mixed-boundary projections by assigning prescribed local components derived from nodewise t...
Device abstraction, common interface for various accelerators.
Definition device.F90:34
type(c_ptr), bind(C), public glb_cmd_queue
Global command queue.
Definition device.F90:52
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