choice.hh
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief potrf: tiny, cta, lpanel:panel, blocked, vendor. evidence: docs/perf/potrf.md @ingroup api_selection_ops
5
7
8#include <array>
9#include <complex>
10#include <string_view>
11#include <type_traits>
12#include <variant>
13
15
16struct Tiny : select::NoFields<"tiny"> {}; ///< potrf_tiny_dispatch: registers; n <= potrf_tiny_max_n, max_wg >= 64
17struct Cta : select::NoFields<"cta"> {}; ///< potrf_cta_dispatch: whole matrix in SLM; n <= the CTA SLM ceiling
18/// potrf_lpanel_dispatch: SLM-resident panels; Lower only, n <= the LPanel SLM ceiling for `panel`.
19struct Lpanel {
20 int panel = 8; ///< potrf_lpanel_dispatch's nb_hint; 16 is instantiated for float only
21 static constexpr std::string_view name = "lpanel";
22 static constexpr std::array<std::string_view, 1> fields{"panel"};
23 std::array<int, 1> values() const { return {panel}; }
24 static Lpanel from(std::array<int, 1> v) { return {v[0]}; }
25 bool operator==(const Lpanel&) const = default;
26};
27struct Blocked : select::NoFields<"blocked"> {}; ///< potrf_blocked_dispatch + gemm/trsm, Lower; nb/W: PotrfBlockedConst + env
28struct Vendor : select::NoFields<"vendor"> {}; ///< backend::potrf_vendor; needs the solver library
29
30using PotrfChoice = std::variant<Tiny, Cta, Lpanel, Blocked, Vendor>; ///< natives need a GPU, sub-group 32, n >= 1
31
32/// Every compiled choice, once, in tie-break order (§6.3): simpler first, vendor last.
33template <class T>
34constexpr auto candidates() {
35 if constexpr (std::is_same_v<T, float>)
36 return std::array<PotrfChoice, 6>{Tiny{}, Cta{}, Lpanel{8}, Lpanel{16}, Blocked{}, Vendor{}};
37 else
38 return std::array<PotrfChoice, 5>{Tiny{}, Cta{}, Lpanel{8}, Blocked{}, Vendor{}};
39}
40
41inline constexpr select::OpSpec spec{Op::potrf, select::Lib::solver}; ///< default last resort: blocked, vendor
42
43/// Table keys: uplo exact (L|U); n log-distance, weight 3 (work ~ n^3); batch log, weight 1.
44/// evidence: docs/design/flat-kernel-selection.md (§5.4)
45inline constexpr std::array<std::string_view, 3> key_names{"uplo:exact", "n:log:3", "batch:log"};
46
47/// The tuner's coarse grid (§6.2): today's sweep grid, so converted and tuned tables line up.
48inline constexpr std::array<int, 34> grid_n{1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48,
49 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 288, 320, 384, 448, 512, 640, 768, 1024, 1280};
50inline constexpr std::array<int, 5> grid_batch{128, 512, 2048, 8192, 32768}; ///< batch axis of the grid
51
52} // namespace batchlas::ops::potrf
constexpr std::array< int, 5 > grid_batch
batch axis of the grid
Definition choice.hh:50
std::variant< Tiny, Cta, Lpanel, Blocked, Vendor > PotrfChoice
natives need a GPU, sub-group 32, n >= 1
Definition choice.hh:30
constexpr std::array< std::string_view, 3 > key_names
Table keys: uplo exact (L|U); n log-distance, weight 3 (work ~ n^3); batch log, weight 1.
Definition choice.hh:45
constexpr std::array< int, 34 > grid_n
The tuner's coarse grid (§6.2): today's sweep grid, so converted and tuned tables line up.
Definition choice.hh:48
constexpr select::OpSpec spec
default last resort: blocked, vendor
Definition choice.hh:41
constexpr auto candidates()
Every compiled choice, once, in tie-break order (§6.3): simpler first, vendor last.
Definition choice.hh:34
Flat kernel selection: one choose() per op over measured per-device tables.
potrf_blocked_dispatch + gemm/trsm, Lower; nb/W: PotrfBlockedConst + env
Definition choice.hh:27
potrf_cta_dispatch: whole matrix in SLM; n <= the CTA SLM ceiling
Definition choice.hh:17
potrf_lpanel_dispatch: SLM-resident panels; Lower only, n <= the LPanel SLM ceiling for panel.
Definition choice.hh:19
static Lpanel from(std::array< int, 1 > v)
Definition choice.hh:24
bool operator==(const Lpanel &) const =default
std::array< int, 1 > values() const
Definition choice.hh:23
static constexpr std::array< std::string_view, 1 > fields
Definition choice.hh:22
static constexpr std::string_view name
Definition choice.hh:21
int panel
potrf_lpanel_dispatch's nb_hint; 16 is instantiated for float only
Definition choice.hh:20
potrf_tiny_dispatch: registers; n <= potrf_tiny_max_n, max_wg >= 64
Definition choice.hh:16
backend::potrf_vendor; needs the solver library
Definition choice.hh:28
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