TDLS 0.4.0
Tiny Device-callable Linear Solvers
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1#ifndef TDLS_SOLVERS_ARROWHEAD_LUPP_CONFIG_HPP
2#define TDLS_SOLVERS_ARROWHEAD_LUPP_CONFIG_HPP
3
4
5
38
39
40
41#include <type_traits>
42
43#include <tdls/core/macros.hpp>
47
48
49
50namespace tdls {
51
52
53
63enum class ArrowheadStorage {
64 Full,
65 Packed,
66 Csr,
68 Bsr
71};
72
73
74
78 Dense,
80};
81
82
83
94 MinFlops,
102};
103
104
105
113 int border = 1;
115 int block = 1;
117 int blocks = 1;
122
125 [[nodiscard]] TDLS_HOST_DEVICE constexpr int n() const noexcept {
126 return border + block * blocks;
127 }
128};
129
130
131
135template<typename T>
137
141 ArrowheadCoupling coupling = ArrowheadCoupling::Dense;
142
147 ArrowheadStorage storage = ArrowheadStorage::Full;
148
154 MatrixLayout layout = MatrixLayout::RowMajor;
155
174
193 ArrowheadCondensation condensation = ArrowheadCondensation::MinFlops;
194
206
231 RowInterchange block_row_interchange = RowInterchange::Auto;
232
242
247 StructuralReal<T> block_oot_pivot_threshold = std::is_same_v<T, float> ? T(1e-6f) : T(1e-12);
248
251
275
284 bool gather_rhs = false;
285
293 bool schur_in_place = false;
294
300 bool unroll_loops = true;
301
312};
313
314
315
316namespace detail {
317
324template<typename T>
325[[nodiscard]] constexpr TiledLUppConfig<T>
328 c.tile_size = config.block_tile_size;
329 c.relative_pivot_threshold = config.block_relative_pivot_threshold;
330 c.oot_pivot_threshold = config.block_oot_pivot_threshold;
331 c.unroll_loops = config.unroll_loops;
332 c.layout = config.layout;
333 return c;
334}
335
343template<typename T>
344[[nodiscard]] constexpr TiledLUppConfig<T>
347 c.row_interchange = RowInterchange::Physical;
348 return c;
349}
350
357template<typename T>
358[[nodiscard]] TDLS_HOST_DEVICE constexpr bool
359arrowhead_register_blocks(const ArrowheadLUppConfig<T>& config, const int S) noexcept {
360 return physical_rows<T>(config.block_row_interchange, S);
361}
362
370template<typename T>
371[[nodiscard]] TDLS_HOST_DEVICE constexpr int
373 [[maybe_unused]] const bool reg) noexcept {
374 if (config.rhs_pass_width >= 0) return config.rhs_pass_width;
375#if TDLS_TARGET_GPU
376 return reg ? 2 : 0;
377#else
378 return 0;
379#endif
380}
381
395template<typename T>
396[[nodiscard]] TDLS_HOST_DEVICE constexpr bool
397arrowhead_register_blocks_here(const RowInterchange interchange, const int S) noexcept {
398 return physical_rows_here<T>(interchange, S);
399}
400
406[[nodiscard]] TDLS_HOST_DEVICE constexpr int
407arrowhead_rhs_pass_width_here(const int width, [[maybe_unused]] const bool reg) noexcept {
408 if (width >= 0) return width;
409#if defined(TDLS_DETAIL_SIDE_DISPATCH)
410 if (!std::is_constant_evaluated()) return on_device_side() && reg ? 2 : 0;
411#endif
412#if TDLS_TARGET_GPU
413 return reg ? 2 : 0;
414#else
415 return 0;
416#endif
417}
418
427template<typename T, bool gpu>
428[[nodiscard]] constexpr ArrowheadLUppConfig<T>
430 const bool reg = physical_rows_on<T, gpu>(config.block_row_interchange, S);
431 config.block_row_interchange = reg ? RowInterchange::Physical : RowInterchange::Logical;
432 if (config.rhs_pass_width < 0) config.rhs_pass_width = gpu && reg ? 2 : 0;
433 return config;
434}
435
442template<typename T>
443[[nodiscard]] constexpr TiledLUppConfig<T>
446 c.tile_size = config.border_tile_size;
447 c.unroll_loops = config.unroll_loops;
448 return c;
449}
450
451} // namespace detail
452
453
454
455} // namespace tdls
456
457
458
459#endif // TDLS_SOLVERS_ARROWHEAD_LUPP_CONFIG_HPP
constexpr TiledLUppConfig< T > arrowhead_physical_block_config(const ArrowheadLUppConfig< T > &config) noexcept
TiledLUpp configuration of the diagonal blocks eliminated in registers: that of arrowhead_block_confi...
Definition config.hpp:345
TDLS_HOST_DEVICE constexpr bool arrowhead_register_blocks(const ArrowheadLUppConfig< T > &config, const int S) noexcept
Whether the diagonal blocks of S unknowns are eliminated in registers (ArrowheadLUppConfig::block_row...
Definition config.hpp:359
TDLS_HOST_DEVICE constexpr int arrowhead_rhs_pass_width_here(const int width, const bool reg) noexcept
arrowhead_rhs_pass_width decided at run time on the side of the code, as arrowhead_register_blocks_he...
Definition config.hpp:407
TDLS_HOST_DEVICE constexpr int arrowhead_rhs_pass_width(const ArrowheadLUppConfig< T > &config, const bool reg) noexcept
The width of the passes over [A_kb | y_k] (ArrowheadLUppConfig::rhs_pass_width), -1 resolved: 2 on GP...
Definition config.hpp:372
TDLS_HOST_DEVICE constexpr bool arrowhead_register_blocks_here(const RowInterchange interchange, const int S) noexcept
Whether the diagonal blocks of S unknowns are eliminated in registers, decided at run time on the sid...
Definition config.hpp:397
ArrowheadStorage
Storage of an arrowhead matrix.
Definition config.hpp:63
@ Packed
Abb, the couplings A_bk, then the A_kb, then the D_k, each by rows or by columns.
@ Full
the full n x n matrix, zeros included: (r, c) at r * n + c, or c * n + r
constexpr TiledLUppConfig< T > arrowhead_block_config(const ArrowheadLUppConfig< T > &config) noexcept
TiledLUpp configuration of the diagonal blocks of an ArrowheadLUpp solver.
Definition config.hpp:326
constexpr ArrowheadLUppConfig< T > arrowhead_resolved_config(ArrowheadLUppConfig< T > config, const int S) noexcept
The configuration with the choices of the given hardware made explicit: block_row_interchange Physica...
Definition config.hpp:429
constexpr TiledLUppConfig< T > arrowhead_border_config(const ArrowheadLUppConfig< T > &config) noexcept
TiledLUpp configuration of the border system of an ArrowheadLUpp solver, a local row-major array what...
Definition config.hpp:444
ArrowheadCondensation
Condensation of an accepted block: what its Schur update and its recovery data spare,...
Definition config.hpp:93
ArrowheadCoupling
Pattern of the border-to-block couplings A_bk, the entries of the border rows in the columns of a blo...
Definition config.hpp:77
@ Dense
every border row may touch every unknown of every block
@ Diagonal
unknown i of a block touches border row coupling_row + i only
Toolchain detection and portability macros.
#define TDLS_HOST_DEVICE
__host__ __device__ under CUDA, the equivalent attributes under HIP, empty elsewhere.
Definition macros.hpp:50
Shared vocabulary and conventions of the solver families.
RowInterchange
Row interchanges of a factorization with partial pivoting.
Definition options.hpp:59
MatrixLayout
Memory layout of a dense matrix.
Definition options.hpp:213
Compile-time knobs of the ArrowheadLUpp solvers, carrying the tuned defaults.
Definition config.hpp:136
bool schur_in_place
Definition config.hpp:293
bool streamed_out_of_line
Definition config.hpp:311
ArrowheadStorage storage
Definition config.hpp:147
bool unroll_loops
Definition config.hpp:300
bool gather_rhs
Definition config.hpp:284
StructuralReal< T > block_oot_pivot_threshold
Definition config.hpp:247
int border_tile_size
Tile size of TiledLUpp on the border system.
Definition config.hpp:250
ArrowheadCondensation condensation
Definition config.hpp:193
MatrixLayout layout
Definition config.hpp:154
StructuralReal< T > block_relative_pivot_threshold
Definition config.hpp:241
StructuralReal< T > condensation_pivot_threshold
Definition config.hpp:173
ArrowheadCoupling coupling
Definition config.hpp:141
int rhs_pass_width
Definition config.hpp:274
RowInterchange block_row_interchange
Definition config.hpp:231
int block_tile_size
Definition config.hpp:205
Shape of an arrowhead matrix: a template argument of the compile-time solver, a function argument of ...
Definition config.hpp:111
int coupling_row
Definition config.hpp:121
int blocks
Number of diagonal blocks.
Definition config.hpp:117
int block
Number of unknowns of a diagonal block.
Definition config.hpp:115
int border
Number of border unknowns, ordered first.
Definition config.hpp:113
TDLS_HOST_DEVICE constexpr int n() const noexcept
Dimension of the matrix.
Definition config.hpp:125
Floating-point value stored as an odd integer mantissa and a power-of-two exponent,...
Definition structural_real.hpp:68
Compile-time knobs of the TiledLUpp solvers, carrying the tuned defaults.
Definition config.hpp:50
StructuralReal< T > relative_pivot_threshold
Definition config.hpp:139
MatrixLayout layout
Definition config.hpp:194
RowInterchange row_interchange
Definition config.hpp:99
int tile_size
Definition config.hpp:63
StructuralReal< T > oot_pivot_threshold
Definition config.hpp:111
bool unroll_loops
Definition config.hpp:174
Exact floating-point value admissible as a template argument.
Compile-time configuration of the TiledLUpp solver family.