Neko 1.99.9
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
53 implicit none
54
55 ! List of all possible types created by the allocator routine
56 character(len=20) :: AX_HELM_KNOWN_TYPES(5) = [character(len=20) :: &
57 "standard", &
58 "full", &
59 "standard_svv", &
60 "full_svv", &
61 "standard_compr"]
62
63contains
64
69 module subroutine ax_helm_allocator(object, type_name)
70 class(ax_t), allocatable, intent(inout) :: object
71 character(len=*), intent(in) :: type_name
72 integer :: i
73
74 if (allocated(object)) then
75 call object%free()
76 deallocate(object)
77 end if
78
79 select case (trim(type_name))
80 case ("standard")
81 if (neko_bcknd_sx .eq. 1) then
82 allocate(ax_helm_sx_t::object)
83 else if (neko_bcknd_xsmm .eq. 1) then
84 allocate(ax_helm_xsmm_t::object)
85 else if (neko_bcknd_device .eq. 1) then
86 allocate(ax_helm_device_t::object)
87 else
88 allocate(ax_helm_cpu_t::object)
89 end if
90 case ("standard_compr")
91 ! The XSMM backend has no compressed product and computes the
92 ! standard one
93 if (neko_bcknd_sx .eq. 1) then
94 allocate(ax_helm_compr_sx_t::object)
95 else if (neko_bcknd_xsmm .eq. 1) then
96 allocate(ax_helm_xsmm_t::object)
97 else if (neko_bcknd_device .eq. 1) then
98 allocate(ax_helm_compr_device_t::object)
99 else
100 allocate(ax_helm_compr_cpu_t::object)
101 end if
102 case ("full")
103 if (neko_bcknd_xsmm .eq. 1) then
104 call neko_error("Full stress formulation is only available " // &
105 "on the CPU and device")
106 else if (neko_bcknd_device .eq. 1) then
107 allocate(ax_helm_full_device_t::object)
108 else
109 allocate(ax_helm_full_cpu_t::object)
110 end if
111 case ("standard_svv")
112 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
113 call neko_error("SVV is not available with the SX or " // &
114 "XSMM backend")
115 else if (neko_bcknd_device .eq. 1) then
116 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
117 call neko_error("SVV is only available on CPU, " // &
118 "CUDA, and HIP backends")
119 end if
120 allocate(ax_helm_svv_one_sided_device_t::object)
121 else
122 allocate(ax_helm_svv_one_sided_cpu_t::object)
123 end if
124 case ("full_svv")
125 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
126 call neko_error("Full stress formulation is only available &
127 &on the CPU and device")
128 else if (neko_bcknd_device .eq. 1) then
129 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
130 call neko_error("Full-stress SVV is only " // &
131 "available on CPU, CUDA, and HIP backends")
132 end if
134 else
135 allocate(ax_helm_svv_one_sided_full_cpu_t::object)
136 end if
137 case default
138 do i = 1, ax_helm_registry_size
139 if (trim(type_name) .eq. &
140 trim(ax_helm_registry(i)%type_name)) then
141 call ax_helm_registry(i)%allocator(object)
142 return
143 end if
144 end do
145
146 call neko_type_error("matrix-vector product", type_name, &
147 ax_helm_known_types)
148 end select
149
150 end subroutine ax_helm_allocator
151
157 module subroutine register_ax_helm(type_name, allocator)
158 character(len=*), intent(in) :: type_name
159 procedure(ax_helm_allocate), pointer, intent(in) :: allocator
160 type(ax_helm_allocator_entry), allocatable :: temp(:)
161 integer :: i
162
163 do i = 1, size(ax_helm_known_types)
164 if (trim(type_name) .eq. trim(ax_helm_known_types(i))) then
165 call neko_type_registration_error("matrix-vector product", &
166 type_name, .true.)
167 end if
168 end do
169
170 do i = 1, ax_helm_registry_size
171 if (trim(type_name) .eq. trim(ax_helm_registry(i)%type_name)) then
172 call neko_type_registration_error("matrix-vector product", &
173 type_name, .false.)
174 end if
175 end do
176
177 if (ax_helm_registry_size .eq. 0) then
178 allocate(ax_helm_registry(1))
179 else
180 allocate(temp(ax_helm_registry_size + 1))
181 temp(1:ax_helm_registry_size) = ax_helm_registry
182 call move_alloc(temp, ax_helm_registry)
183 end if
184
185 ax_helm_registry_size = ax_helm_registry_size + 1
186 ax_helm_registry(ax_helm_registry_size)%type_name = type_name
187 ax_helm_registry(ax_helm_registry_size)%allocator => allocator
188 end subroutine register_ax_helm
189
190end 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 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.
Device matrix-vector product for an SVV Helmholtz problem.
Spectral vanishing viscosity configuration and coefficients.