Neko 1.99.1
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!
34 use num_types, only : rp, c_rp
35 use utils, only : neko_error
36 use, intrinsic :: iso_c_binding
37 implicit none
38
39#ifdef HAVE_HIP
40 interface
41 subroutine hip_inhom_dirichlet_apply_vector(msk, x, y, z, &
42 bla_x, bla_y, bla_z, m, strm) &
43 bind(c, name='hip_inhom_dirichlet_apply_vector')
44 use, intrinsic :: iso_c_binding
45 import c_rp
46 implicit none
47 integer(c_int) :: m
48 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
50 end interface
51#elif HAVE_CUDA
52 interface
53 subroutine cuda_inhom_dirichlet_apply_vector(msk, x, y, z, &
54 bla_x, bla_y, bla_z, m, strm) &
55 bind(c, name='cuda_inhom_dirichlet_apply_vector')
56 use, intrinsic :: iso_c_binding
57 import c_rp
58 implicit none
59 integer(c_int) :: m
60 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
62 end interface
63#elif HAVE_OPENCL
64 interface
65 subroutine opencl_inhom_dirichlet_apply_vector(msk, x, y, z, &
66 bla_x, bla_y, bla_z, m, strm) &
67 bind(c, name='opencl_inhom_dirichlet_apply_vector')
68 use, intrinsic :: iso_c_binding
69 import c_rp
70 implicit none
71 integer(c_int) :: m
72 type(c_ptr), value :: msk, x, y, z, bla_x, bla_y, bla_z, strm
74 end interface
75
76#endif
77
78#ifdef HAVE_HIP
79 interface
80 subroutine hip_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
81 bind(c, name='hip_inhom_dirichlet_apply_scalar')
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, bla_x, strm
88 end interface
89#elif HAVE_CUDA
90 interface
91 subroutine cuda_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
92 bind(c, name='cuda_inhom_dirichlet_apply_scalar')
93 use, intrinsic :: iso_c_binding
94 import c_rp
95 implicit none
96 integer(c_int) :: m
97 type(c_ptr), value :: msk, x, bla_x, strm
99 end interface
100#elif HAVE_OPENCL
101 interface
102 subroutine opencl_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm) &
103 bind(c, name='opencl_inhom_dirichlet_apply_scalar')
104 use, intrinsic :: iso_c_binding
105 import c_rp
106 implicit none
107 integer(c_int) :: m
108 type(c_ptr), value :: msk, x, bla_x, strm
110 end interface
111#endif
112
113contains
114
115 subroutine device_inhom_dirichlet_apply_vector(msk, x, y, z, &
116 bla_x, bla_y, bla_z, m, strm)
117 integer, intent(in) :: m
118 type(c_ptr) :: msk, x, y, z, bla_x, bla_y, bla_z, strm
119
120 if (m .lt. 1) return
121#ifdef HAVE_HIP
122 call hip_inhom_dirichlet_apply_vector(msk, x, y, z, &
123 bla_x, bla_y, bla_z, m, strm)
124#elif HAVE_CUDA
125 call cuda_inhom_dirichlet_apply_vector(msk, x, y, z, &
126 bla_x, bla_y, bla_z, m, strm)
127#elif HAVE_OPENCL
128 call opencl_inhom_dirichlet_apply_vector(msk, x, y, z, &
129 bla_x, bla_y, bla_z, m, strm)
130#else
131 call neko_error('No device backend configured')
132#endif
133
135
136 subroutine device_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
137 integer, intent(in) :: m
138 type(c_ptr) :: msk, x, bla_x, strm
139
140 if (m .lt. 1) return
141#ifdef HAVE_HIP
142 call hip_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
143#elif HAVE_CUDA
144 call cuda_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
145#elif HAVE_OPENCL
146 call opencl_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
147#else
148 call neko_error('No device backend configured')
149#endif
150
152
153end 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)
subroutine device_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
subroutine device_inhom_dirichlet_apply_vector(msk, x, y, z, bla_x, bla_y, bla_z, m, strm)
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