Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_factorized_device.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!
33!> Device implementation of the factorized SVV Helmholtz operator.
35 use ax_helm_svv, only : ax_helm_svv_t
36 use num_types, only : rp
37 use coefs, only : coef_t
38 use space, only : space_t
39 use mesh, only : mesh_t
40 use device_math, only : device_addcol4
41 use device, only : device_get_ptr
42 use utils, only : neko_error
43 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
44 implicit none
45 private
46
47 !> Device matrix-vector product for a factorized SVV Helmholtz problem.
49 contains
50 !> Compute the product.
51 procedure, pass(this) :: compute => ax_helm_svv_factorized_device_compute
53
54#ifdef HAVE_HIP
55 interface
56 subroutine hip_ax_helm_svv_factorized(w_d, u_d, dx_d, dy_d, dz_d, h1_d, &
57 Br_d, Bs_d, Bt_d, svv_h1_d, G11_d, G22_d, G33_d, &
58 G12_d, G13_d, G23_d, nelv, lx) &
59 bind(c, name='hip_ax_helm_svv_factorized')
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 :: Br_d, Bs_d, Bt_d, svv_h1_d
64 type(c_ptr), value :: G11_d, G22_d, G33_d
65 type(c_ptr), value :: G12_d, G13_d, G23_d
66 integer(c_int) :: nelv, lx
67 end subroutine hip_ax_helm_svv_factorized
68 end interface
69#elif HAVE_CUDA
70 interface
71 subroutine cuda_ax_helm_svv_factorized(w_d, u_d, dx_d, dy_d, dz_d, h1_d, &
72 Br_d, Bs_d, Bt_d, svv_h1_d, G11_d, G22_d, G33_d, &
73 G12_d, G13_d, G23_d, nelv, lx) &
74 bind(c, name='cuda_ax_helm_svv_factorized')
75 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
76 type(c_ptr), value :: w_d, u_d
77 type(c_ptr), value :: dx_d, dy_d, dz_d, h1_d
78 type(c_ptr), value :: Br_d, Bs_d, Bt_d, svv_h1_d
79 type(c_ptr), value :: G11_d, G22_d, G33_d
80 type(c_ptr), value :: G12_d, G13_d, G23_d
81 integer(c_int) :: nelv, lx
82 end subroutine cuda_ax_helm_svv_factorized
83 end interface
84#endif
85
86contains
87
88 !> Compute the factorized SVV Helmholtz product.
89 !! @param this Device factorized SVV Helmholtz operator.
90 !! @param w Result.
91 !! @param u Input field.
92 !! @param coef Coefficients.
93 !! @param msh Mesh.
94 !! @param Xh Function space.
95 subroutine ax_helm_svv_factorized_device_compute(this, w, u, coef, msh, Xh)
96 class(ax_helm_svv_factorized_device_t), intent(in) :: this
97 type(mesh_t), intent(in) :: msh
98 type(space_t), intent(in) :: Xh
99 type(coef_t), intent(in) :: coef
100 real(kind=rp), intent(inout) :: w(xh%lx, xh%ly, xh%lz, msh%nelv)
101 real(kind=rp), intent(in) :: u(xh%lx, xh%ly, xh%lz, msh%nelv)
102 type(c_ptr) :: u_d, w_d
103
104 u_d = device_get_ptr(u)
105 w_d = device_get_ptr(w)
106
107#ifdef HAVE_HIP
108 call hip_ax_helm_svv_factorized(w_d, u_d, xh%dx_d, xh%dy_d, xh%dz_d, &
109 coef%h1_d, this%svv%Br_d, this%svv%Bs_d, this%svv%Bt_d, &
110 this%svv%h1_d, coef%G11_d, coef%G22_d, coef%G33_d, &
111 coef%G12_d, coef%G13_d, coef%G23_d, &
112 msh%nelv, xh%lx)
113#elif HAVE_CUDA
114 call cuda_ax_helm_svv_factorized(w_d, u_d, xh%dx_d, xh%dy_d, xh%dz_d, &
115 coef%h1_d, this%svv%Br_d, this%svv%Bs_d, this%svv%Bt_d, &
116 this%svv%h1_d, coef%G11_d, coef%G22_d, coef%G33_d, &
117 coef%G12_d, coef%G13_d, coef%G23_d, &
118 msh%nelv, xh%lx)
119#elif HAVE_OPENCL
120 call neko_error('OPENCL is not implemented for factorized SVV')
121#endif
122
123 if (coef%ifh2) then
124 call device_addcol4(w_d, coef%h2_d, coef%B_d, u_d, coef%dof%size())
125 end if
126
128
void cuda_ax_helm_svv_factorized(void *w, void *u, void *dx, void *dy, void *dz, void *h1, void *Br, void *Bs, void *Bt, void *h1_svv, void *g11, void *g22, void *g33, void *g12, void *g13, void *g23, int *nelv, int *lx)
Return the device pointer for an associated Fortran array.
Definition device.F90:113
Device implementation of the factorized SVV Helmholtz operator.
subroutine ax_helm_svv_factorized_device_compute(this, w, u, coef, msh, xh)
Compute the factorized SVV Helmholtz 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 a factorized SVV Helmholtz problem.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
The function space for the SEM solution fields.
Definition space.f90:64