Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2021-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!
33submodule(ax_product) ax_helm_fctry
39 use ax_helm_sx, only : ax_helm_sx_t
41 use ax_helm, only : ax_helm_t
42 use ax_helm_cpu, only : ax_helm_cpu_t
58 implicit none
59
60 ! List of all possible types created by the allocator routine
61 character(len=20) :: AX_HELM_KNOWN_TYPES(7) = [character(len=20) :: &
62 "standard", &
63 "full", &
64 "one_sided_svv", &
65 "full_one_sided_svv", &
66 "factorized_svv", &
67 "full_factorized_svv", &
68 "standard_compr"]
69
70contains
71
72 !> Allocate a Helmholtz problem matrix-vector product.
73 !! The implementation is selected by name and compute backend.
74 !! @param object The matrix-vector product type to be allocated.
75 !! @param type_name The name of the matrix-vector product type.
76 module subroutine ax_helm_allocator(object, type_name)
77 class(ax_t), allocatable, intent(inout) :: object
78 character(len=*), intent(in) :: type_name
79 integer :: i
80
81 if (allocated(object)) then
82 call object%free()
83 deallocate(object)
84 end if
85
86 select case (trim(type_name))
87 case ("standard")
88 if (neko_bcknd_sx .eq. 1) then
89 allocate(ax_helm_sx_t::object)
90 else if (neko_bcknd_xsmm .eq. 1) then
91 allocate(ax_helm_xsmm_t::object)
92 else if (neko_bcknd_device .eq. 1) then
93 allocate(ax_helm_device_t::object)
94 else
95 allocate(ax_helm_cpu_t::object)
96 end if
97 case ("standard_compr")
98 ! The XSMM backend has no compressed product and computes the
99 ! standard one
100 if (neko_bcknd_sx .eq. 1) then
101 allocate(ax_helm_compr_sx_t::object)
102 else if (neko_bcknd_xsmm .eq. 1) then
103 allocate(ax_helm_xsmm_t::object)
104 else if (neko_bcknd_device .eq. 1) then
105 allocate(ax_helm_compr_device_t::object)
106 else
107 allocate(ax_helm_compr_cpu_t::object)
108 end if
109 case ("full")
110 if (neko_bcknd_xsmm .eq. 1) then
111 call neko_error("Full stress formulation is only available " // &
112 "on the CPU and device")
113 else if (neko_bcknd_device .eq. 1) then
114 allocate(ax_helm_full_device_t::object)
115 else
116 allocate(ax_helm_full_cpu_t::object)
117 end if
118 case ("one_sided_svv", "factorized_svv")
119 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
120 call neko_error("SVV is not available with the SX or " // &
121 "XSMM backend")
122 else if (neko_bcknd_device .eq. 1) then
123 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
124 call neko_error("SVV is only available on CPU, " // &
125 "CUDA, and HIP backends")
126 end if
127 if (trim(type_name) .eq. "factorized_svv") then
128 allocate(ax_helm_svv_factorized_device_t::object)
129 else
130 allocate(ax_helm_svv_one_sided_device_t::object)
131 end if
132 else
133 if (trim(type_name) .eq. "factorized_svv") then
134 allocate(ax_helm_svv_factorized_cpu_t::object)
135 else
136 allocate(ax_helm_svv_one_sided_cpu_t::object)
137 end if
138 end if
139 case ("full_one_sided_svv", "full_factorized_svv")
140 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
141 call neko_error("Full stress formulation is only available &
142 &on the CPU and device")
143 else if (neko_bcknd_device .eq. 1) then
144 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
145 call neko_error("Full-stress SVV is only " // &
146 "available on CPU, CUDA, and HIP backends")
147 end if
148 if (trim(type_name) .eq. "full_factorized_svv") then
150 else
152 end if
153 else
154 if (trim(type_name) .eq. "full_factorized_svv") then
155 allocate(ax_helm_svv_factorized_full_cpu_t::object)
156 else
157 allocate(ax_helm_svv_one_sided_full_cpu_t::object)
158 end if
159 end if
160 case default
161 do i = 1, ax_helm_registry_size
162 if (trim(type_name) .eq. &
163 trim(ax_helm_registry(i)%type_name)) then
164 call ax_helm_registry(i)%allocator(object)
165 return
166 end if
167 end do
168
169 call neko_type_error("matrix-vector product", type_name, &
170 ax_helm_known_types)
171 end select
172
173 end subroutine ax_helm_allocator
174
175 !> Register a custom matrix-vector product allocator.
176 !! Called in custom user modules inside the `module_name_register_types`
177 !! routine to add a custom type allocator to the registry.
178 !! @param type_name The name of the type to allocate.
179 !! @param allocator The allocator for the custom user type.
180 module subroutine register_ax_helm(type_name, allocator)
181 character(len=*), intent(in) :: type_name
182 procedure(ax_helm_allocate), pointer, intent(in) :: allocator
183 type(ax_helm_allocator_entry), allocatable :: temp(:)
184 integer :: i
185
186 do i = 1, size(ax_helm_known_types)
187 if (trim(type_name) .eq. trim(ax_helm_known_types(i))) then
188 call neko_type_registration_error("matrix-vector product", &
189 type_name, .true.)
190 end if
191 end do
192
193 do i = 1, ax_helm_registry_size
194 if (trim(type_name) .eq. trim(ax_helm_registry(i)%type_name)) then
195 call neko_type_registration_error("matrix-vector product", &
196 type_name, .false.)
197 end if
198 end do
199
200 if (ax_helm_registry_size .eq. 0) then
201 allocate(ax_helm_registry(1))
202 else
203 allocate(temp(ax_helm_registry_size + 1))
204 temp(1:ax_helm_registry_size) = ax_helm_registry
205 call move_alloc(temp, ax_helm_registry)
206 end if
207
208 ax_helm_registry_size = ax_helm_registry_size + 1
209 ax_helm_registry(ax_helm_registry_size)%type_name = type_name
210 ax_helm_registry(ax_helm_registry_size)%allocator => allocator
211 end subroutine register_ax_helm
212
213end submodule ax_helm_fctry
CPU Helmholtz matrix-vector product on compressed geometric factors.
Device Helmholtz matrix-vector product on compressed geometric factors.
SX Helmholtz matrix-vector product on compressed geometric factors.
CPU implementation of the factorized SVV Helmholtz operator.
Device implementation of the factorized SVV Helmholtz operator.
CPU implementation of the factorized full-stress SVV Helmholtz operator.
Device implementation of the factorized full-stress SVV Helmholtz operator.
CPU implementation of the one-sided SVV Helmholtz operator.
CPU implementation of the full-stress one-sided SVV Helmholtz operator.
Device implementation of the full-stress one-sided SVV operator.
Defines a Matrix-vector product.
Definition ax.f90:34
Build configurations.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_hip
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_cuda
integer, parameter neko_bcknd_xsmm
Data and filter construction for spectral vanishing viscosity.
Utilities.
Definition utils.f90:35
subroutine, public neko_type_registration_error(base_type, wrong_type, known)
Definition utils.f90:433
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:415
Matrix-vector product for a Helmholtz problem.
Definition ax_helm.f90:44
CPU matrix-vector product for a Helmholtz problem, reading the geometric factors from their compress...
Device matrix-vector product for a Helmholtz problem, reading the geometric factors from their compr...
SX matrix-vector product for a Helmholtz problem, reading the geometric factors from their compresse...
CPU matrix-vector product for a Helmholtz problem.
CPU matrix-vector product for a Helmholtz problem with full stress tensor.
CPU matrix-vector product for a factorized SVV Helmholtz problem.
Device matrix-vector product for a factorized SVV Helmholtz problem.
CPU matrix-vector product for a factorized full-stress SVV Helmholtz problem.
Device matrix-vector product for an SVV Helmholtz problem.
Spectral vanishing viscosity configuration and coefficients.