Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_inhom_dirichlet.F90
Go to the documentation of this file.
1! Copyright (c) 2021-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 utils, only : neko_error
37 use, intrinsic :: iso_c_binding
38 implicit none
39
40#ifdef HAVE_HIP
41 interface
42 subroutine hip_inhom_dirichlet_apply_vector(msk, x, y, z, &
43 bla_x, bla_y, bla_z, m, strm) &
44 bind(c, name = 'hip_inhom_dirichlet_apply_vector')
45 use, intrinsic :: iso_c_binding
46 import c_rp
47 implicit none
48 integer(c_int) :: m
49 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
51 end interface
52#elif HAVE_CUDA
53 interface
54 subroutine cuda_inhom_dirichlet_apply_vector(msk, x, y, z, &
55 bla_x, bla_y, bla_z, m, strm) &
56 bind(c, name = 'cuda_inhom_dirichlet_apply_vector')
57 use, intrinsic :: iso_c_binding
58 import c_rp
59 implicit none
60 integer(c_int) :: m
61 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
63 end interface
64#elif HAVE_OPENCL
65 interface
66 subroutine opencl_inhom_dirichlet_apply_vector(msk, x, y, z, &
67 bla_x, bla_y, bla_z, m, strm) &
68 bind(c, name = 'opencl_inhom_dirichlet_apply_vector')
69 use, intrinsic :: iso_c_binding
70 import c_rp
71 implicit none
72 integer(c_int) :: m
73 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
75 end interface
76
77#elif HAVE_METAL
78 interface
79 subroutine metal_inhom_dirichlet_apply_vector(msk, x, y, z, &
80 bla_x, bla_y, bla_z, m, strm) &
81 bind(c, name = 'metal_inhom_dirichlet_apply_vector')
82 use, intrinsic :: iso_c_binding
83 import c_rp
84 implicit none
85 integer(c_int) :: m
86 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
87 end subroutine metal_inhom_dirichlet_apply_vector
88 end interface
89
90#endif
91
92#ifdef HAVE_HIP
93 interface
94 subroutine hip_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
95 bind(c, name = 'hip_inhom_dirichlet_apply_scalar')
96 use, intrinsic :: iso_c_binding
97 import c_rp
98 implicit none
99 integer(c_int) :: m
100 type(c_ptr), value :: msk, x, bla_x, strm
102 end interface
103#elif HAVE_CUDA
104 interface
105 subroutine cuda_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
106 bind(c, name = 'cuda_inhom_dirichlet_apply_scalar')
107 use, intrinsic :: iso_c_binding
108 import c_rp
109 implicit none
110 integer(c_int) :: m
111 type(c_ptr), value :: msk, x, bla_x, strm
113 end interface
114#elif HAVE_OPENCL
115 interface
116 subroutine opencl_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
117 bind(c, name = 'opencl_inhom_dirichlet_apply_scalar')
118 use, intrinsic :: iso_c_binding
119 import c_rp
120 implicit none
121 integer(c_int) :: m
122 type(c_ptr), value :: msk, x, bla_x, strm
124 end interface
125#elif HAVE_METAL
126 interface
127 subroutine metal_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
128 bind(c, name = 'metal_inhom_dirichlet_apply_scalar')
129 use, intrinsic :: iso_c_binding
130 import c_rp
131 implicit none
132 integer(c_int) :: m
133 type(c_ptr), value :: msk, x, bla_x, strm
134 end subroutine metal_inhom_dirichlet_apply_scalar
135 end interface
136#endif
137
138contains
139
150 subroutine device_inhom_dirichlet_apply_vector(msk, x, y, z, &
151 bla_x, bla_y, bla_z, m, strm)
152 integer, intent(in) :: m
153 type(c_ptr) :: msk, x, y, z, bla_x, bla_y, bla_z, strm
154
155 if (m .lt. 1) return
156#ifdef HAVE_HIP
157 call hip_inhom_dirichlet_apply_vector(msk, x, y, z, &
158 bla_x, bla_y, bla_z, m, strm)
159#elif HAVE_CUDA
160 call cuda_inhom_dirichlet_apply_vector(msk, x, y, z, &
161 bla_x, bla_y, bla_z, m, strm)
162#elif HAVE_OPENCL
163 call opencl_inhom_dirichlet_apply_vector(msk, x, y, z, &
164 bla_x, bla_y, bla_z, m, strm)
165#elif HAVE_METAL
166 call metal_inhom_dirichlet_apply_vector(msk, x, y, z, &
167 bla_x, bla_y, bla_z, m, strm)
168#else
169 call neko_error('No device backend configured')
170#endif
171
173
180 subroutine device_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
181 integer, intent(in) :: m
182 type(c_ptr) :: msk, x, bla_x, strm
183
184 if (m .lt. 1) return
185#ifdef HAVE_HIP
186 call hip_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
187#elif HAVE_CUDA
188 call cuda_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
189#elif HAVE_OPENCL
190 call opencl_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
191#elif HAVE_METAL
192 call metal_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
193#else
194 call neko_error('No device backend configured')
195#endif
196
198
199end module device_inhom_dirichlet
void opencl_inhom_dirichlet_apply_scalar(void *msk, void *x, void *bla_x, int *m, cl_command_queue cmd_queue)
void opencl_inhom_dirichlet_apply_vector(void *msk, void *x, void *y, void *z, void *bla_x, void *bla_y, void *bla_z, int *m, cl_command_queue cmd_queue)
void cuda_inhom_dirichlet_apply_scalar(void *msk, void *x, void *bla_x, int *m, cudaStream_t strm)
void cuda_inhom_dirichlet_apply_vector(void *msk, void *x, void *y, void *z, void *bla_x, void *bla_y, void *bla_z, int *m, cudaStream_t strm)
Device backend wrappers for inhomogeneous Dirichlet boundary conditions.
subroutine device_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
Apply an inhomogeneous Dirichlet condition to a scalar field on the device.
subroutine device_inhom_dirichlet_apply_vector(msk, x, y, z, bla_x, bla_y, bla_z, m, strm)
Apply an inhomogeneous Dirichlet condition to a vector field on the 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
Utilities.
Definition utils.f90:35