22using SyrkChoice = std::variant<Gram, Triangular, Vendor>;
26 if constexpr (std::is_same_v<T, float>)
return std::array<SyrkChoice, 3>{
Gram{},
Triangular{},
Vendor{}};
27 else return std::array<SyrkChoice, 2>{
Gram{},
Vendor{}};
30inline constexpr std::array<std::string_view, 3>
last_resort{
"triangular",
"gram",
"vendor"};
35inline constexpr std::array<std::string_view, 5>
key_names{
"form:exact",
"trans:exact",
"n:log:2",
"k:log",
38inline std::string_view
form_of(std::int64_t a, std::int64_t b) {
39 return 2 * std::min(a, b) >= std::max(a, b) ?
"sq" : (a > 2 * b ?
"tall" :
"wide");
44inline constexpr std::array<int, 30>
grid_n{1, 2, 4, 8, 16, 32, 64, 128, 129, 256,
45 257, 384, 385, 512, 513, 640, 641, 768, 769, 896,
46 897, 1024, 1025, 1152, 1153, 1536, 1537, 2176, 2177, 4096};
48inline constexpr std::array<std::string_view, 3>
grid_trans{
"N",
"T",
"C"};
49inline constexpr std::array<int, 6>
grid_k{1, 7, 8, 64, 512, 4096};
50inline constexpr std::array<int, 17>
grid_batch{1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 15, 16, 26, 27, 128, 1024, 32768};
58 const std::int64_t t = (n + tile - 1) / tile;
59 return t * (t + 1) / 2;
63inline constexpr int gram_tile(std::int64_t n) {
return n <= 32 ? 32 : (n <= 64 ? 64 : 128); }
66 return (lanes * (lanes + 1) / 2 + 31) / 32 * 32;
70 return std::int64_t(32) *
gram_tile(n) * std::int64_t(
sizeof(T));
77 return text && *text ==
"gram";
bool herk_gram_pinned()
herk's opt-in to the conjugating gram kernel: syrk's pin is exactly gram.
constexpr std::array< int, 17 > grid_batch
constexpr std::int64_t kMaxGridBatch
batch ceiling of both tile kernels
constexpr std::array< std::string_view, 5 > key_names
Keys: form (transcribed squareish ratio of n, k) and trans N|T|C exact; n weight 2 (work ~ n^2 k batc...
std::string_view form_of(std::int64_t a, std::int64_t b)
constexpr std::int64_t triangular_groups(std::int64_t n, std::int64_t tile)
constexpr std::int64_t kMaxGridTiles
triangular's tile-count ceiling
constexpr std::int64_t gram_slm_bytes(std::int64_t n)
constexpr int gram_tile(std::int64_t n)
constexpr select::OpSpec spec
op, vendor library, rules
constexpr auto candidates()
Every compiled choice in tie-break order (§6.3); triangular is float only (R7).
constexpr std::array< int, 6 > grid_k
k axis of the grid
constexpr std::array< std::string_view, 3 > last_resort
none runs
std::variant< Gram, Triangular, Vendor > SyrkChoice
fieldless (tile, leg derived); natives: CUDA GPU
constexpr std::array< int, 30 > grid_n
n axis
constexpr std::array< std::string_view, 3 > grid_trans
trans axis of the grid
constexpr int gram_threads(std::int64_t n)
constexpr int kTriangularWg
syrk_triangular_tiles' 16 x 16 work-group
std::optional< std::string > pin_text(std::string_view op, std::string *source)
Flat kernel selection: one choose() per op over measured per-device tables.
syrk_gram_tiles: one tile covers C; n <= 128, tile SLM fits
syrk_triangular_tiles<float>: 128-wide tiles of one half
backend::syrk_vendor (per-item ?syrk loop)
Base of a family with no knobs: struct Cta : NoFields<"cta"> {};.
What an op's choice.hh declares once: its name, the library its Vendor family calls (one gate for can...