Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_neumann.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!
34 use utils, only : neko_error
35 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
36 implicit none
37 private
38
39#ifdef HAVE_HIP
40 interface
41 subroutine hip_neumann_apply_scalar(msk, facet, x, flux, area, &
42 lx, m, strm) &
43 bind(c, name = 'hip_neumann_apply_scalar')
44 use, intrinsic :: iso_c_binding
45 implicit none
46 integer(c_int) :: m, lx
47 type(c_ptr), value :: msk, facet, x, flux, area, strm
48 end subroutine hip_neumann_apply_scalar
49
50 subroutine hip_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y,&
51 flux_z, area, lx, m, strm) &
52 bind(c, name = 'hip_neumann_apply_vector')
53 use, intrinsic :: iso_c_binding
54 implicit none
55 integer(c_int) :: m, lx
56 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
57 area, strm
58 end subroutine hip_neumann_apply_vector
59 end interface
60#elif HAVE_CUDA
61 interface
62 subroutine cuda_neumann_apply_scalar(msk, facet, x, flux, area, &
63 lx, m, strm) &
64 bind(c, name = 'cuda_neumann_apply_scalar')
65 use, intrinsic :: iso_c_binding
66 implicit none
67 integer(c_int) :: m, lx
68 type(c_ptr), value :: msk, facet, x, flux, area, strm
69 end subroutine cuda_neumann_apply_scalar
70
71 subroutine cuda_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
72 flux_z, area, lx, m, strm) &
73 bind(c, name = 'cuda_neumann_apply_vector')
74 use, intrinsic :: iso_c_binding
75 implicit none
76 integer(c_int) :: m, lx
77 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
78 area, strm
79 end subroutine cuda_neumann_apply_vector
80 end interface
81#elif HAVE_OPENCL
82 interface
83 subroutine opencl_neumann_apply_scalar(msk, facet, x, flux, area, &
84 lx, m, strm) &
85 bind(c, name = 'opencl_neumann_apply_scalar')
86 use, intrinsic :: iso_c_binding
87 implicit none
88 integer(c_int) :: m, lx
89 type(c_ptr), value :: msk, facet, x, flux, area, strm
90 end subroutine opencl_neumann_apply_scalar
91
92 subroutine opencl_neumann_apply_vector(msk, facet, x, y, z, flux_x, &
93 flux_y, flux_z, area, lx, m, strm) &
94 bind(c, name = 'opencl_neumann_apply_vector')
95 use, intrinsic :: iso_c_binding
96 implicit none
97 integer(c_int) :: m, lx
98 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
99 area, strm
100 end subroutine opencl_neumann_apply_vector
101 end interface
102#elif HAVE_METAL
103 interface
104 subroutine metal_neumann_apply_scalar(msk, facet, x, flux, area, &
105 lx, m, strm) &
106 bind(c, name = 'metal_neumann_apply_scalar')
107 use, intrinsic :: iso_c_binding
108 implicit none
109 integer(c_int) :: m, lx
110 type(c_ptr), value :: msk, facet, x, flux, area, strm
111 end subroutine metal_neumann_apply_scalar
112
113 subroutine metal_neumann_apply_vector(msk, facet, x, y, z, flux_x, &
114 flux_y, flux_z, area, lx, m, strm) &
115 bind(c, name = 'metal_neumann_apply_vector')
116 use, intrinsic :: iso_c_binding
117 implicit none
118 integer(c_int) :: m, lx
119 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
120 area, strm
121 end subroutine metal_neumann_apply_vector
122 end interface
123#endif
124
126
127contains
128
129 subroutine device_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
130 integer, intent(in) :: m, lx
131 type(c_ptr) :: msk, facet, x, flux, area, strm
132
133 if (m .lt. 1) return
134#ifdef HAVE_HIP
135 call hip_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
136#elif HAVE_CUDA
137 call cuda_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
138#elif HAVE_OPENCL
139 call opencl_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
140#elif HAVE_METAL
141 call metal_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
142#else
143 call neko_error('No device backend configured')
144#endif
145
146 end subroutine device_neumann_apply_scalar
147
148 subroutine device_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
149 flux_z, area, lx, m, strm)
150 integer, intent(in) :: m, lx
151 type(c_ptr) :: msk, facet, x, y, z, flux_x, flux_y, flux_z, area, strm
152
153 if (m .lt. 1) return
154#ifdef HAVE_HIP
155 call hip_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, flux_z, &
156 area, lx, m, strm)
157#elif HAVE_CUDA
158 call cuda_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
159 flux_z, area, lx, m, strm)
160#elif HAVE_OPENCL
161 call opencl_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
162 flux_z, area, lx, m, strm)
163#elif HAVE_METAL
164 call metal_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
165 flux_z, area, lx, m, strm)
166#else
167 call neko_error('No device backend configured')
168#endif
169
170 end subroutine device_neumann_apply_vector
171
172end module device_neumann
subroutine, public device_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
subroutine, public device_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, flux_z, area, lx, m, strm)
Utilities.
Definition utils.f90:35
void opencl_neumann_apply_vector(void *msk, void *facet, void *x, void *y, void *z, void *flux_x, void *flux_y, void *flux_z, void *area, int *lx, int *m, cl_command_queue cmd_queue)
Definition neumann.c:87
void opencl_neumann_apply_scalar(void *msk, void *facet, void *x, void *flux, void *area, int *lx, int *m, cl_command_queue cmd_queue)
Definition neumann.c:52
void cuda_neumann_apply_scalar(void *msk, void *facet, void *x, void *flux, void *area, int *lx, int *m, cudaStream_t strm)
Definition neumann.cu:44
void cuda_neumann_apply_vector(void *msk, void *facet, void *x, void *y, void *z, void *flux_x, void *flux_y, void *flux_z, void *area, int *lx, int *m, cudaStream_t strm)
Definition neumann.cu:66