Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_one_sided_device.F90
Go to the documentation of this file.
1! Copyright (c) 2025-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!
34 use ax_helm_svv, only : ax_helm_svv_t
35 use num_types, only : rp
36 use coefs, only : coef_t
37 use space, only : space_t
38 use mesh, only : mesh_t
39 use device_math, only : device_addcol4
40 use device, only : device_get_ptr
41 use utils, only : neko_error
42 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
43 implicit none
44 private
45
48 contains
50 procedure, pass(this) :: compute => ax_helm_svv_one_sided_device_compute
52
53#ifdef HAVE_HIP
54 interface
55 subroutine hip_ax_helm_svv_one_sided(w_d, u_d, dx_d, dy_d, dz_d, h1_d, &
56 drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
57 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, svv_h1_d, &
58 filter_r_d, filter_s_d, filter_t_d, nelv, lx) &
59 bind(c, name='hip_ax_helm_svv_one_sided')
60 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
61 type(c_ptr), value :: w_d, u_d
62 type(c_ptr), value :: dx_d, dy_d, dz_d, h1_d
63 type(c_ptr), value :: drdx_d, drdy_d, drdz_d
64 type(c_ptr), value :: dsdx_d, dsdy_d, dsdz_d
65 type(c_ptr), value :: dtdx_d, dtdy_d, dtdz_d
66 type(c_ptr), value :: jacinv_d, w3_d, svv_h1_d
67 type(c_ptr), value :: filter_r_d, filter_s_d, filter_t_d
68 integer(c_int) :: nelv, lx
69 end subroutine hip_ax_helm_svv_one_sided
70 end interface
71#elif HAVE_CUDA
72 interface
73 subroutine cuda_ax_helm_svv_one_sided(w_d, u_d, dx_d, dy_d, dz_d, h1_d, &
74 drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
75 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, svv_h1_d, &
76 filter_r_d, filter_s_d, filter_t_d, nelv, lx) &
77 bind(c, name='cuda_ax_helm_svv_one_sided')
78 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
79 type(c_ptr), value :: w_d, u_d
80 type(c_ptr), value :: dx_d, dy_d, dz_d, h1_d
81 type(c_ptr), value :: drdx_d, drdy_d, drdz_d
82 type(c_ptr), value :: dsdx_d, dsdy_d, dsdz_d
83 type(c_ptr), value :: dtdx_d, dtdy_d, dtdz_d
84 type(c_ptr), value :: jacinv_d, w3_d, svv_h1_d
85 type(c_ptr), value :: filter_r_d, filter_s_d, filter_t_d
86 integer(c_int) :: nelv, lx
87 end subroutine cuda_ax_helm_svv_one_sided
88 end interface
89#endif
90
91contains
92
100 subroutine ax_helm_svv_one_sided_device_compute(this, w, u, coef, msh, Xh)
101 class(ax_helm_svv_one_sided_device_t), intent(in) :: this
102 type(mesh_t), intent(in) :: msh
103 type(space_t), intent(in) :: Xh
104 type(coef_t), intent(in) :: coef
105 real(kind=rp), intent(inout) :: w(xh%lx, xh%ly, xh%lz, msh%nelv)
106 real(kind=rp), intent(in) :: u(xh%lx, xh%ly, xh%lz, msh%nelv)
107 type(c_ptr) :: u_d, w_d
108 type(c_ptr) :: filter_r_d, filter_s_d, filter_t_d
109
110 u_d = device_get_ptr(u)
111 w_d = device_get_ptr(w)
112
113 if (index(this%svv%direction, "r") > 0) then
114 filter_r_d = this%svv%filter%fh_d
115 else
116 filter_r_d = this%svv%ident_d
117 end if
118
119 if (index(this%svv%direction, "s") > 0) then
120 filter_s_d = this%svv%filter%fht_d
121 else
122 filter_s_d = this%svv%ident_d
123 end if
124
125 if (index(this%svv%direction, "t") > 0) then
126 filter_t_d = this%svv%filter%fht_d
127 else
128 filter_t_d = this%svv%ident_d
129 end if
130
131#ifdef HAVE_HIP
132 call hip_ax_helm_svv_one_sided(w_d, u_d, xh%dx_d, xh%dy_d, xh%dz_d, &
133 coef%h1_d, coef%drdx_d, coef%drdy_d, coef%drdz_d, &
134 coef%dsdx_d, coef%dsdy_d, coef%dsdz_d, &
135 coef%dtdx_d, coef%dtdy_d, coef%dtdz_d, coef%jacinv_d, &
136 xh%w3_d, this%svv%h1_d, filter_r_d, filter_s_d, filter_t_d, &
137 msh%nelv, xh%lx)
138#elif HAVE_CUDA
139 call cuda_ax_helm_svv_one_sided(w_d, u_d, xh%dx_d, xh%dy_d, xh%dz_d, &
140 coef%h1_d, coef%drdx_d, coef%drdy_d, coef%drdz_d, &
141 coef%dsdx_d, coef%dsdy_d, coef%dsdz_d, &
142 coef%dtdx_d, coef%dtdy_d, coef%dtdz_d, coef%jacinv_d, &
143 xh%w3_d, this%svv%h1_d, filter_r_d, filter_s_d, filter_t_d, &
144 msh%nelv, xh%lx)
145#elif HAVE_OPENCL
146 call neko_error('OPENCL is not implemented for SVV')
147#elif HAVE_METAL
148 call neko_error('Metal is not implemented for SVV')
149#else
150 call neko_error('No supported device backend is enabled for SVV')
151#endif
152
153 if (coef%ifh2) then
154 call device_addcol4(w_d, coef%h2_d, coef%B_d, u_d, coef%dof%size())
155 end if
156
158
void cuda_ax_helm_svv_one_sided(void *w, void *u, void *dx, void *dy, void *dz, void *h1, void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *jacinv, void *w3, void *h1_svv, void *filter_r, void *filter_s, void *filter_t, int *nelv, int *lx)
Return the device pointer for an associated Fortran array.
Definition device.F90:113
subroutine ax_helm_svv_one_sided_device_compute(this, w, u, coef, msh, xh)
Compute the product.
Base type for an SVV Helmholtz operator.
Coefficients.
Definition coef.f90:34
subroutine, public device_addcol4(a_d, b_d, c_d, d_d, n, strm)
Returns .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a function space.
Definition space.f90:34
Utilities.
Definition utils.f90:35
Helmholtz operator carrying a non-owning SVV object.
Device matrix-vector product for an SVV Helmholtz problem.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:93
The function space for the SEM solution fields.
Definition space.f90:64