choice.hh
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief geqrf: tiny, cta, blocked, vendor. evidence: docs/perf/qr.md @ingroup api_selection_ops
5
7
8#include <array>
9#include <cstdint>
10#include <string_view>
11#include <variant>
12
13namespace batchlas::ops::geqrf {
14
15struct Tiny : select::NoFields<"tiny"> {}; ///< geqrf_tiny_dispatch: square, registers, n <= the tiny ceiling
16struct Cta : select::NoFields<"cta"> {}; ///< geqrf_cta_dispatch: the whole panel in SLM (geqrf_cta_fits)
17struct Blocked : select::NoFields<"blocked"> {}; ///< geqrf_blocked_dispatch + the public gemm, any m >= n
18struct Vendor : select::NoFields<"vendor"> {}; ///< backend::geqrf_vendor; needs the factorization library
19
20using GeqrfChoice = std::variant<Tiny, Cta, Blocked, Vendor>; ///< fieldless: buckets, packing, nb, leaf derived
21
22/// Every compiled choice, once, in tie-break order (§6.3): narrowest first, vendor last.
23template <class T>
24constexpr auto candidates() { return select::all_of<GeqrfChoice>(); }
25
26inline constexpr select::OpSpec spec{Op::geqrf, select::Lib::factorization}; ///< last resort (§5.5): blocked, vendor
27
28/// Keys: form sq | tall (m > n) | wide (m < n), exact; n log weight 3; aspect log. Work ~ n^3 * aspect.
29inline constexpr std::array<std::string_view, 3> key_names{"form:exact", "n:log:3", "aspect:log"};
30
31template <class Int> /// The aspect key: max(m, n) / min(m, n), 1 for an empty view.
32constexpr std::int64_t aspect_of(Int m, Int n) {
33 const std::int64_t lo = m < n ? m : n, hi = m < n ? n : m;
34 return lo < 1 ? 1 : hi / lo;
35}
36
37/// Rows: sq x grid_n, tall x grid_n x grid_aspect, wide x grid_wide_n x grid_wide_aspect; both
38/// sides of every transcribed threshold (the transcriber, tuned/README.md, spells the same grid).
39inline constexpr std::array<int, 52> grid_n{1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 14, 16, 17, 20, 21, 22,
40 23, 24, 28, 31, 32, 33, 40, 47, 48, 49, 56, 63, 64, 75, 76, 80, 96,
41 97, 112, 128, 160, 192, 224, 255, 256, 288, 384, 512, 768, 1024, 1536, 2048,
42 3072, 4096, 8192};
43inline constexpr std::array<int, 11> grid_aspect{1, 2, 3, 4, 5, 7, 8, 12, 16, 64, 256};
44inline constexpr std::array<int, 4> grid_wide_n{2, 64, 1024, 8192};
45inline constexpr std::array<int, 3> grid_wide_aspect{1, 4, 64};
46
47} // namespace batchlas::ops::geqrf
constexpr auto all_of()
Every alternative of a field-less choice variant, in declaration (= tie-break) order.
Definition select.hh:110
std::variant< Tiny, Cta, Blocked, Vendor > GeqrfChoice
fieldless: buckets, packing, nb, leaf derived
Definition choice.hh:20
constexpr auto candidates()
Every compiled choice, once, in tie-break order (§6.3): narrowest first, vendor last.
Definition choice.hh:24
constexpr std::array< int, 11 > grid_aspect
Definition choice.hh:43
constexpr std::int64_t aspect_of(Int m, Int n)
The aspect key: max(m, n) / min(m, n), 1 for an empty view.
Definition choice.hh:32
constexpr std::array< int, 52 > grid_n
Rows: sq x grid_n, tall x grid_n x grid_aspect, wide x grid_wide_n x grid_wide_aspect; both sides of ...
Definition choice.hh:39
constexpr std::array< int, 3 > grid_wide_aspect
Definition choice.hh:45
constexpr select::OpSpec spec
last resort (§5.5): blocked, vendor
Definition choice.hh:26
constexpr std::array< int, 4 > grid_wide_n
Definition choice.hh:44
constexpr std::array< std::string_view, 3 > key_names
Keys: form sq | tall (m > n) | wide (m < n), exact; n log weight 3; aspect log. Work ~ n^3 * aspect.
Definition choice.hh:29
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
Base of a family with no knobs: struct Cta : NoFields<"cta"> {};.
Definition select.hh:101
What an op's choice.hh declares once: its name, the library its Vendor family calls (one gate for can...
Definition select.hh:529