getrf_native.hh
Go to the documentation of this file.
1#pragma once
2
3// Native batched GETRF, declarations only. The blocked driver's panel leaf IS the CTA tier's
4// device function, so both TUs must sit in one device-code cluster. PIVOT CONTRACT: the
5// int64_t span packs 1-based int32 in its first half (as_span<int>()) -- an interchange list,
6// not a permutation; complex pivots on cabs1, not cuBLAS's modulus. evidence: docs/perf/lu.md
7
8#include <src/util/internal-api.hh>
9#include <src/util/resident_capacity.hh>
14
15#include <cstddef>
16#include <cstdint>
17#include <functional>
18
20
21// A RUNTIME local_mem_size budget, not device_limits.hh's build-time constant, and it must
22// cover the pivot-search scratch as well as the tile; 0 = absent. `min_blocks_per_sm` scales
23// the ADVERTISED capacity, residency is getrf_leaf_fits. evidence: docs/perf/lu.md#lu-the-occupancy-rule
24template <typename T>
25BATCHLAS_INTERNAL_API int getrf_cta_max_n_for_slm(
26 std::size_t slm_budget_bytes,
27 int min_blocks_per_sm = resident::kMinBlocksPerSm);
28
29template <typename T>
30BATCHLAS_INTERNAL_API bool getrf_blocked_available();
31
32// THE REGISTER-RESIDENT TIER, and the ONE place its ceiling is spelled: a compile-time
33// property of the kernel, so no budget enters. evidence: docs/perf/lu.md#one-spelling-per-ceiling
34template <typename T>
35BATCHLAS_INTERNAL_API int getrf_tiny_max_n();
36
37inline constexpr int kGetrfTinyWgSize = 64; // getrf_tiny_dispatch refuses a smaller MAX_WORK_GROUP_SIZE
38
39// NOT zero: a short or empty `info` span means "not requested" and draws pool scratch.
40template <typename T>
41BATCHLAS_INTERNAL_API std::size_t getrf_tiny_buffer_size(
43
44template <typename T>
45BATCHLAS_INTERNAL_API Event getrf_tiny_dispatch(Queue& ctx,
47 Span<int64_t> pivots,
48 Span<std::byte> workspace,
49 Span<int32_t> info);
50
51// Zero is a legitimate size, and neither query may touch A.data_ptr().
52template <typename T>
53BATCHLAS_INTERNAL_API std::size_t getrf_cta_buffer_size(Queue& ctx,
55
56template <typename T>
57BATCHLAS_INTERNAL_API std::size_t getrf_blocked_buffer_size(Queue& ctx,
59
60template <typename T>
61BATCHLAS_INTERNAL_API unsigned getrf_blocked_debug_params(Queue& ctx, int n); // nb | leaf<<16
62
63// The leading panel's leaf AS THE DRIVER WOULD TAKE IT: getrf_blocked_debug_params' leaf
64// field is a pure fit query. 1 resident, 2 global, 3 register, 0 degenerate.
65template <typename T>
66BATCHLAS_INTERNAL_API unsigned getrf_blocked_debug_leaf(Queue& ctx, int n);
67
68// Mandatory: getrf_blocked_dispatch throws on an empty seam (inject the public gemm).
69template <typename T>
70using GetrfTrailingGemm = std::function<Event(
71 Queue&,
76
77// Positional form of the routed batchlas::trsm -- alpha comes THIRD, not last.
78template <typename T>
79using GetrfPanelSolveTrsm = std::function<Event(
80 Queue&,
83 T, Side, Uplo, Transpose, Diag)>;
84
85template <typename T>
86BATCHLAS_INTERNAL_API Event getrf_cta_dispatch(Queue& ctx,
88 Span<int64_t> pivots,
89 Span<std::byte> workspace,
90 Span<int32_t> info);
91
92template <typename T>
93BATCHLAS_INTERNAL_API Event getrf_blocked_dispatch(Queue& ctx,
95 Span<int64_t> pivots,
96 Span<std::byte> workspace,
97 Span<int32_t> info,
98 GetrfTrailingGemm<T> trailing_gemm,
99 GetrfPanelSolveTrsm<T> panel_trsm);
100
101// Budgets an explicit SLM tree argmax: sycl::reduce_over_group fails to launch at
102// specific byte counts near 48 KB. evidence: docs/perf/lu.md#lu-the-48-kb-launch-hole
103template <typename T>
104BATCHLAS_INTERNAL_API bool getrf_cta_fits(
105 int n, std::size_t slm_budget_bytes,
106 int min_blocks_per_sm = resident::kMinBlocksPerSm);
107
108template <typename T>
109BATCHLAS_INTERNAL_API unsigned getrf_cta_debug_launch(Queue& ctx, int m, int n); // G | wg<<16
110
111template <typename T>
112BATCHLAS_INTERNAL_API bool getrf_leaf_fits(int m, int n, std::size_t slm_budget_bytes);
113
114// THE TWO PANEL LEAVES, one contract: `piv_stride` is the matrix ORDER, `piv_base` the
115// panel's first global row, `info_ptr` READ as well as written (zero it before panel 0).
116// The register leaf adds a WIDTH ceiling `nb` (a short final panel arrives with n < nb)
117// and a REGISTER height ceiling `max_m`; 0 = absent. evidence: docs/perf/lu.md#the-register-panel-leaf
118template <typename T>
119BATCHLAS_INTERNAL_API int getrf_panel_reg_nb();
120
121template <typename T>
122BATCHLAS_INTERNAL_API int getrf_panel_reg_max_m();
123
124template <typename T>
125BATCHLAS_INTERNAL_API bool getrf_panel_reg_fits(int m, int n, int max_wg);
126
127template <typename T>
128BATCHLAS_INTERNAL_API unsigned getrf_panel_reg_debug_launch(Queue& ctx, int m, int n);
129
130template <typename T>
131BATCHLAS_INTERNAL_API Event getrf_panel_reg_factorize(Queue& ctx,
132 T* a_ptr, int ld, int stride,
133 int m, int n, int batch,
134 int* piv_ptr, int piv_stride,
135 int piv_base, int32_t* info_ptr);
136
137template <typename T>
138BATCHLAS_INTERNAL_API Event getrf_panel_factorize(Queue& ctx,
139 T* a_ptr, int ld, int stride,
140 int m, int n, int batch,
141 int* piv_ptr, int piv_stride, int piv_base,
142 int32_t* info_ptr,
143 bool* used_resident_out);
144
145} // namespace batchlas::sycl_getrf
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
ComputePrecision
Internal compute precision of a GEMM (the cuBLAS cublasComputeType_t).
Definition enums.hh:505
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 int getrf_panel_reg_nb()
BATCHLAS_INTERNAL_API Event getrf_tiny_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< int64_t > pivots, Span< std::byte > workspace, Span< int32_t > info)
BATCHLAS_INTERNAL_API unsigned getrf_panel_reg_debug_launch(Queue &ctx, int m, int n)
std::function< Event( Queue &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, T, T, Transpose, Transpose, ComputePrecision)> GetrfTrailingGemm
BATCHLAS_INTERNAL_API int getrf_panel_reg_max_m()
BATCHLAS_INTERNAL_API std::size_t getrf_blocked_buffer_size(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A)
BATCHLAS_INTERNAL_API Event getrf_blocked_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< int64_t > pivots, Span< std::byte > workspace, Span< int32_t > info, GetrfTrailingGemm< T > trailing_gemm, GetrfPanelSolveTrsm< T > panel_trsm)
BATCHLAS_INTERNAL_API Event getrf_panel_reg_factorize(Queue &ctx, T *a_ptr, int ld, int stride, int m, int n, int batch, int *piv_ptr, int piv_stride, int piv_base, int32_t *info_ptr)
BATCHLAS_INTERNAL_API bool getrf_cta_fits(int n, std::size_t slm_budget_bytes, int min_blocks_per_sm=resident::kMinBlocksPerSm)
BATCHLAS_INTERNAL_API std::size_t getrf_cta_buffer_size(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A)
BATCHLAS_INTERNAL_API bool getrf_blocked_available()
BATCHLAS_INTERNAL_API unsigned getrf_blocked_debug_params(Queue &ctx, int n)
BATCHLAS_INTERNAL_API int getrf_tiny_max_n()
BATCHLAS_INTERNAL_API unsigned getrf_blocked_debug_leaf(Queue &ctx, int n)
BATCHLAS_INTERNAL_API unsigned getrf_cta_debug_launch(Queue &ctx, int m, int n)
constexpr int kGetrfTinyWgSize
BATCHLAS_INTERNAL_API bool getrf_leaf_fits(int m, int n, std::size_t slm_budget_bytes)
BATCHLAS_INTERNAL_API Event getrf_panel_factorize(Queue &ctx, T *a_ptr, int ld, int stride, int m, int n, int batch, int *piv_ptr, int piv_stride, int piv_base, int32_t *info_ptr, bool *used_resident_out)
BATCHLAS_INTERNAL_API Event getrf_cta_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< int64_t > pivots, Span< std::byte > workspace, Span< int32_t > info)
std::function< Event( Queue &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, T, Side, Uplo, Transpose, Diag)> GetrfPanelSolveTrsm
BATCHLAS_INTERNAL_API bool getrf_panel_reg_fits(int m, int n, int max_wg)
BATCHLAS_INTERNAL_API int getrf_cta_max_n_for_slm(std::size_t slm_budget_bytes, int min_blocks_per_sm=resident::kMinBlocksPerSm)
BATCHLAS_INTERNAL_API std::size_t getrf_tiny_buffer_size(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A)
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.