choice.hh
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief trmm: triangular, expand, vendor. evidence: docs/perf/level3.md @ingroup api_selection_ops
5
7
8#include <array>
9#include <cstdint>
10#include <string_view>
11#include <variant>
12
14
15struct Triangular : select::NoFields<"triangular"> {}; ///< trmm_triangular_tiles: Side::Left; tile grid <= 65535
16struct Expand : select::NoFields<"expand"> {}; ///< expand_triangular + the public gemm; scratch must fit
17struct Vendor : select::NoFields<"vendor"> {}; ///< backend::trmm_vendor (cublas?trmm loop)
18
19using TrmmChoice = std::variant<Triangular, Expand, Vendor>; ///< row tile (trmm_row_tile) derived; natives: CUDA GPU
20
21template <class T> /// Every compiled choice, in tie-break order (§6.3): triangular, expand, vendor.
22constexpr auto candidates() { return select::all_of<TrmmChoice>(); }
23
24inline constexpr std::array<std::string_view, 3> last_resort{"expand", "triangular", "vendor"}; ///< nothing runs
25// §5.5: Expand serves both sides, Triangular Left only.
26inline constexpr select::OpSpec spec{Op::trmm, select::Lib::level3, {last_resort}}; ///< op, vendor library, rules
27
28inline constexpr std::int64_t kMaxGridBatch = 65535; ///< both natives: batch in grid z; 65536 throws
29inline constexpr std::int64_t kMaxGridTiles = 65535; ///< triangular: row x column tiles in grid y
30inline constexpr int kNativeWg = 256; ///< widest native work-group: the 128-row tile, the expansion
31
32/// Keys: side exact; order = A.rows(), weight 2 (work ~ order^2 q batch); q = B.cols() (Left) or B.rows() (Right).
33inline constexpr std::array<std::string_view, 4> key_names{"side:exact", "order:log:2", "q:log", "batch:log"};
34
35// The transcription grid (tuned/README.md); the transcribed rule read only the side.
36inline constexpr std::array<int, 9> grid_order{1, 16, 32, 64, 128, 256, 512, 1024, 2048}; ///< order axis
37inline constexpr std::array<int, 5> grid_q{1, 16, 128, 1024, 4096}; ///< q axis of the grid
38inline constexpr std::array<int, 4> grid_batch{1, 128, 1024, 32768}; ///< batch axis of the grid
39
40} // namespace batchlas::ops::trmm
constexpr auto all_of()
Every alternative of a field-less choice variant, in declaration (= tie-break) order.
Definition select.hh:110
constexpr std::array< int, 9 > grid_order
order axis
Definition choice.hh:36
constexpr std::array< int, 5 > grid_q
q axis of the grid
Definition choice.hh:37
constexpr std::array< std::string_view, 4 > key_names
Keys: side exact; order = A.rows(), weight 2 (work ~ order^2 q batch); q = B.cols() (Left) or B....
Definition choice.hh:33
constexpr std::int64_t kMaxGridTiles
triangular: row x column tiles in grid y
Definition choice.hh:29
constexpr std::array< int, 4 > grid_batch
batch axis of the grid
Definition choice.hh:38
constexpr auto candidates()
Every compiled choice, in tie-break order (§6.3): triangular, expand, vendor.
Definition choice.hh:22
constexpr std::array< std::string_view, 3 > last_resort
nothing runs
Definition choice.hh:24
constexpr std::int64_t kMaxGridBatch
both natives: batch in grid z; 65536 throws
Definition choice.hh:28
constexpr int kNativeWg
widest native work-group: the 128-row tile, the expansion
Definition choice.hh:30
constexpr select::OpSpec spec
op, vendor library, rules
Definition choice.hh:26
std::variant< Triangular, Expand, Vendor > TrmmChoice
row tile (trmm_row_tile) derived; natives: CUDA GPU
Definition choice.hh:19
Flat kernel selection: one choose() per op over measured per-device tables.
expand_triangular + the public gemm; scratch must fit
Definition choice.hh:16
trmm_triangular_tiles: Side::Left; tile grid <= 65535
Definition choice.hh:15
backend::trmm_vendor (cublas?trmm loop)
Definition choice.hh:17
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