|
TDLS 0.2.0
Tiny Device-callable Linear Solvers
|
TiledLUpp solver: LU with partial pivoting on tile grids, one thread / work-item per system. More...
#include <tdls/core/math.hpp>#include <type_traits>#include <tdls/solvers/tiled_lupp/config.hpp>#include <tdls/solvers/tiled_lupp/tile_operations.hpp>Go to the source code of this file.
Classes | |
| struct | tdls::TiledLUppSolverStatic< T, N, Config > |
| Tiled dense LU factorization with logical partial pivoting and out-of-tile pivot recovery, solving one NxN system per call. More... | |
Macros | |
| #define | TDLS_LUPP_A(r, c) |
| Element (r, c) of the factor matrix: contiguous under internal residency, strided otherwise, flat index remapped by Config.layout. | |
| #define | TDLS_LUPP_PIV(i) |
| Pivot entry i: contiguous under internal residency, strided otherwise. | |
| #define | TDLS_LUPP_X(i) |
| Entry i of the solution vector: contiguous under internal residency, strided otherwise. | |
| #define | TDLS_LUPP_B(i) |
| Entry i of the right-hand side: contiguous under internal residency, strided otherwise. | |
| #define | TDLS_LUPP_XW(w, i) |
| Entry i of column w of a multi right-hand-side block: pass_width contiguous columns under internal residency, xcol_stride-strided columns in remote memory. pass_width = 1 collapses to TDLS_LUPP_X exactly. | |
| #define | TDLS_LUPP_BW(w, i) |
| Entry i of column w of a multi right-hand-side block of b, addressed exactly as TDLS_LUPP_XW (b and x share both strides). | |
| #define | TDLS_LUPP_Y(i) |
| Entry i of the fused right-hand side of solve_inplace (y follows the matrix rows through pivoting). | |
TiledLUpp solver: LU with partial pivoting on tile grids, one thread / work-item per system.
The matrix is split into a grid of tile_size x tile_size tiles; Gaussian elimination runs on tiles instead of scalars. The tiles of the current step are copied into local arrays, the working set kept in registers. The full matrix can stay in remote memory (shared, global or plain host memory), walked with a stride, or be a caller-local array that the residency booleans keep in registers too. Pivoting is logical: piv[] maps logical row -> physical row, rows are physically swapped only inside the diagonal tile. When the best in-tile pivot falls below Config.oot_threshold, the search extends below the tile (out-of-tile pivoting) and candidate values are corrected on the fly for the eliminations they have not received yet.
Addressing convention (backend-agnostic, no accessor objects). The solver never sees a thread index: callers pre-offset every remote pointer with the lane/system index and pass a runtime stride. Element (r,c) of the matrix lives at A[((r)*N+(c))*A_stride] under the default row-major layout; Config.layout remaps the flat index to ((c)*N+(r)) for column-major storage, resolved at compile time and with bitwise-identical results. The pivot array and the right-hand sides follow the same convention. Offsets are computed in 32-bit arithmetic: the flat element index (for the matrix, N*N) must stay below 2^31 and the largest element offset of every array (for the matrix, (N*N-1)*A_stride) below 2^32. Each of the three arrays has an internal residency mode (plain caller-local array, stride ignored) selected by the internal_rhs / internal_piv / internal_matrix template booleans. The ternary on a constexpr bool costs nothing. The single form base[e*stride] covers every batched layout without touching the solver: AoS (stride 1), SoA (stride = batch size), AoSoA (stride = W).
Tile grid. full_tiles = N / tile_size full tiles per dimension, plus a last tile of extent last_tile_tail = N - full_tiles * tile_size when N is not a multiple of tile_size; tile_size may exceed N, the grid then being that single partial tile (full_tiles = 0, last_tile_tail = N). Every sweep is a runtime loop over the full tiles followed by an if constexpr (last_tile_tail > 0) epilogue instantiated with the tail extent; phantom slots of partial tiles are skipped at compile time by the extent template parameters.
Factored format. The diagonal of the factored matrix holds the RECIPROCALS of the U pivots (consumers multiply; each division is paid once per pivot). This deliberately differs from the LAPACK getrf convention. A factorization produced here must be consumed by the substitution routines of this solver.
Originally developed and validated in the tfelGPU project.
| #define TDLS_LUPP_A | ( | r, | |
| c ) |
Element (r, c) of the factor matrix: contiguous under internal residency, strided otherwise, flat index remapped by Config.layout.
| #define TDLS_LUPP_B | ( | i | ) |
Entry i of the right-hand side: contiguous under internal residency, strided otherwise.
| #define TDLS_LUPP_BW | ( | w, | |
| i ) |
Entry i of column w of a multi right-hand-side block of b, addressed exactly as TDLS_LUPP_XW (b and x share both strides).
| #define TDLS_LUPP_PIV | ( | i | ) |
Pivot entry i: contiguous under internal residency, strided otherwise.
| #define TDLS_LUPP_X | ( | i | ) |
Entry i of the solution vector: contiguous under internal residency, strided otherwise.
| #define TDLS_LUPP_XW | ( | w, | |
| i ) |
Entry i of column w of a multi right-hand-side block: pass_width contiguous columns under internal residency, xcol_stride-strided columns in remote memory. pass_width = 1 collapses to TDLS_LUPP_X exactly.
| #define TDLS_LUPP_Y | ( | i | ) |
Entry i of the fused right-hand side of solve_inplace (y follows the matrix rows through pivoting).