can_run.hh
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief geqrf's can_run, a header so host tests can pass a synthetic select::Device. No real test
5/// device lacks a GPU, sub-group 32 or one CTA element of SLM. @ingroup api_selection_ops
6
8
10#include <src/select/select.hh>
12
13#include <cstddef>
14#include <cstdint>
15#include <variant>
16
18
20
21template <class T>
23
24/// Correctness only (R3): each clause is its driver's check. One (m, n, ld, stride) per launch and a wide view's
25/// off-panel update: natives take neither; the vendor (top-level (m, n) per item) takes no heterogeneous batch.
26template <class T>
27bool can_run(const GeqrfChoice& c, const select::Device& d, const MV<T>& A) {
28 const std::int64_t m = A.rows(), n = A.cols();
29 const bool native = d.is_gpu && d.has_sg32 && !A.is_heterogeneous() && m >= n && n >= 1 && A.batch_size() >= 1;
30 const auto budget = static_cast<std::size_t>(d.slm_budget);
31 return std::visit(overloaded{
32 [&](Tiny) { return native && m == n && n <= sycl_geqrf::geqrf_tiny_max_n_for_slm<T>(budget); },
33 [&](Cta) { return native && sycl_geqrf::geqrf_cta_fits<T>(static_cast<int>(m), static_cast<int>(n), budget); },
34 // Blocked's panel leaf IS Cta's device function: it needs the tier present, not the fit.
35 [&](Blocked) {
36 return native && sycl_geqrf::geqrf_blocked_available<T>() &&
38 },
39 [&](Vendor) { return d.has_vendor && !A.is_heterogeneous(); },
40 }, c);
41}
42
43} // namespace batchlas::ops::geqrf
Non-owning view of a batch of matrices: the argument type of every entry point.
Definition matrix.hh:485
int rows() const
Rows per item (the capacity on a heterogeneous batch).
Definition matrix.hh:605
bool is_heterogeneous() const
True when per-item active extents are attached.
Definition matrix.hh:621
int cols() const
Columns per item (the capacity on a heterogeneous batch).
Definition matrix.hh:611
int batch_size() const
Number of batch items.
Definition matrix.hh:603
geqrf: tiny, cta, blocked, vendor.
The batched containers: Matrix (owning), MatrixView (non-owning), KernelMatrixView (device-side),...
std::variant< Tiny, Cta, Blocked, Vendor > GeqrfChoice
fieldless: buckets, packing, nb, leaf derived
Definition choice.hh:20
bool can_run(const GeqrfChoice &c, const select::Device &d, const MV< T > &A)
Correctness only (R3): each clause is its driver's check.
Definition can_run.hh:27
MatrixView< T, MatrixFormat::Dense > MV
Definition can_run.hh:22
BATCHLAS_INTERNAL_API int64_t geqrf_cta_max_elems_for_slm(std::size_t slm_budget_bytes, int min_blocks_per_sm=kGeqrfMinBlocksPerSm)
BATCHLAS_INTERNAL_API bool geqrf_cta_fits(int m, int n, std::size_t slm_budget_bytes, int min_blocks_per_sm=kGeqrfMinBlocksPerSm)
BATCHLAS_INTERNAL_API bool geqrf_blocked_available()
Flat kernel selection: one choose() per op over measured per-device tables.
geqrf_blocked_dispatch + the public gemm, any m >= n
Definition choice.hh:17
geqrf_cta_dispatch: the whole panel in SLM (geqrf_cta_fits)
Definition choice.hh:16
geqrf_tiny_dispatch: square, registers, n <= the tiny ceiling
Definition choice.hh:15
backend::geqrf_vendor; needs the factorization library
Definition choice.hh:18
The device facts a can_run predicate and the table lookup read (§5.1).
Definition select.hh:44
std::int64_t slm_budget
LOCAL_MEM_SIZE less a 4 KiB reserve, bytes: any work-group size.
Definition select.hh:51
bool has_vendor
the asking op's library group (OpSpec::vendor) is compiled in
Definition select.hh:50
std::visit over a choice with one lambda per family.
Definition select.hh:118