getrs_native.hh
Go to the documentation of this file.
1#pragma once
2
3// Native batched GETRS declarations: the composed tier (row permutation + two routed
4// trsm) and the fused narrow-RHS tier; selected in src/ops/getrs/getrs.cc. evidence: docs/perf/lu.md
5
6#include <src/util/internal-api.hh>
11
12#include <cstddef>
13#include <cstdint>
14#include <functional>
15
17
18template <typename T>
19BATCHLAS_INTERNAL_API bool getrs_blocked_available();
20
21// Size via BumpAllocator::measuring(), never a hand sum; zero is a legitimate size.
22template <typename T>
23BATCHLAS_INTERNAL_API std::size_t getrs_blocked_buffer_size(Queue& ctx,
26 Transpose transA);
27
28// Positional form of the ROUTED batchlas::trsm -- alpha comes THIRD, not last.
29template <typename T>
30using GetrsSolveTrsm = std::function<Event(
31 Queue&,
34 T, Side, Uplo, Transpose, Diag)>;
35
36template <typename T>
37BATCHLAS_INTERNAL_API Event getrs_blocked_dispatch(Queue& ctx,
40 Transpose transA,
41 Span<int64_t> pivots,
42 Span<std::byte> workspace,
43 GetrsSolveTrsm<T> solve_trsm = {});
44
45// Boundary on B.cols(): interchange walk below, in-place gather at or above; both spell
46// the same permutation. evidence: docs/perf/lu.md#getrs-collapsed-permutation
47inline constexpr int kGetrsPermGatherMinNrhs = 16;
48
49// Test-only: 1 = gather, 0 = walk; the gather falls back to the walk when SLM is short.
50template <typename T>
51BATCHLAS_INTERNAL_API int getrs_perm_spelling_debug(Queue& ctx, int n, int nrhs);
52
53// Pivots are getrf's: a 1-based INTERCHANGE LIST, not a permutation vector -- packed int32
54// on CUDA/ROCm, int64 on Netlib (getrf_native.hh PIVOT CONTRACT). getrs must match getrf.
55
56// A capability, not a speed window: above this width the kernel is not instantiated.
57inline constexpr int64_t kGetrsFusedMaxRhs = 8;
58
59template <typename T>
60BATCHLAS_INTERNAL_API bool getrs_fused_available();
61
62// Pass a DEVICE-queried slm_budget_bytes; device_limits.hh's constant admits a route that cannot launch.
63template <typename T>
64BATCHLAS_INTERNAL_API std::size_t getrs_fused_max_rhs_elems(std::size_t slm_budget_bytes);
65
66template <typename T>
67BATCHLAS_INTERNAL_API std::size_t getrs_fused_buffer_size(Queue& ctx,
70 Transpose transA);
71
72template <typename T>
73BATCHLAS_INTERNAL_API Event getrs_fused_dispatch(Queue& ctx,
76 Transpose transA,
77 Span<int64_t> pivots,
78 Span<std::byte> workspace);
79
80// posv's `cta` choice (src/ops/posv/): both Cholesky solves in one kernel, same capacity and ceiling.
81template <typename T>
82BATCHLAS_INTERNAL_API Event potrs_fused_dispatch(Queue& ctx,
85 Uplo uplo);
86
87} // namespace batchlas::sycl_getrs
Non-owning view of a batch of matrices: the argument type of every entry point.
Definition matrix.hh:485
Enumerations, scalar traits and scalar concepts shared by every public header.
Transpose
The operator op() applied to an operand: op(A) = A, A^T or A^H.
Definition enums.hh:171
Diag
Whether a triangular operand's diagonal is read or assumed to be one.
Definition enums.hh:303
Uplo
Which triangle of a symmetric, Hermitian or triangular operand is referenced.
Definition enums.hh:287
Side
Side on which a special operand multiplies: op(A) * B or B * op(A).
Definition enums.hh:319
The batched containers: Matrix (owning), MatrixView (non-owning), KernelMatrixView (device-side),...
BATCHLAS_INTERNAL_API Event potrs_fused_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Uplo uplo)
std::function< Event( Queue &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, T, Side, Uplo, Transpose, Diag)> GetrsSolveTrsm
BATCHLAS_INTERNAL_API std::size_t getrs_fused_max_rhs_elems(std::size_t slm_budget_bytes)
BATCHLAS_INTERNAL_API int getrs_perm_spelling_debug(Queue &ctx, int n, int nrhs)
BATCHLAS_INTERNAL_API std::size_t getrs_fused_buffer_size(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Transpose transA)
constexpr int64_t kGetrsFusedMaxRhs
BATCHLAS_INTERNAL_API Event getrs_blocked_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Transpose transA, Span< int64_t > pivots, Span< std::byte > workspace, GetrsSolveTrsm< T > solve_trsm={})
constexpr int kGetrsPermGatherMinNrhs
BATCHLAS_INTERNAL_API bool getrs_blocked_available()
BATCHLAS_INTERNAL_API std::size_t getrs_blocked_buffer_size(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Transpose transA)
BATCHLAS_INTERNAL_API Event getrs_fused_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Transpose transA, Span< int64_t > pivots, Span< std::byte > workspace)
BATCHLAS_INTERNAL_API bool getrs_fused_available()
Completion handle of enqueued work, returned by every entry point.
Event()
An empty Event, already complete.
Where BatchLAS work runs: a device, a backend, an ordered SYCL queue and a workspace arena.
Non-owning view of size() contiguous elements of type T.
Definition sycl-span.hh:39
batchlas::Device, batchlas::Event and batchlas::Queue: where work runs and how it is ordered.
batchlas::Span, the non-owning pointer + length every entry point takes for 1-D data.