trsm_native.hh
Go to the documentation of this file.
1#pragma once
2
3// Native batched TRSM declarations: V1 (CTA solver, one work-group per matrix)
4// and V2 (blocked driver that calls V1 on each diagonal block). See docs/perf/trsm.md.
5
6#include <src/util/internal-api.hh>
9
10#include <functional>
12
13namespace batchlas::sycl_trsm {
14
15// Zero means "no native TRSM kernel in this build": trsm's can_run (src/ops/trsm/trsm.cc)
16// then refuses cta and blocked.
17template <typename T>
19
20template <typename T>
22
23template <typename T>
24BATCHLAS_INTERNAL_API Event trsm_native_v1_dispatch(Queue& ctx,
27 T alpha,
28 Side side,
29 Uplo uplo,
30 Transpose transA,
31 Diag diag);
32
33// V1's work-group width: no rung may leave over half its lanes without a rhs column.
34// evidence: docs/perf/blackwell.md#trsm-v1-ladder-cap
35inline constexpr int kTrsmV1MaxWg = 256;
36constexpr int trsm_v1_ladder_wg(int max_wg, int cu, int q, int bs) {
37 int wg = 32;
38 for (int cand : {kTrsmV1MaxWg, 128, 64, 32}) {
39 if (cand > max_wg) continue;
40 if (cand > 32 && cand / 2 >= q) continue;
41 wg = cand;
42 const long long groups_c = (q + cand - 1) / cand;
43 if (static_cast<long long>(bs) * groups_c >= 4LL * cu) break;
44 }
45 return wg;
46}
47
48// Side::Left sub-group kernel, orders 1..32 (throws above), sub-group 32, work-group
49// kTrsmSgLeftWgSize (static_assert in trsm_sg_left.cc). trsm's `sg_left` choice.
50inline constexpr int kTrsmSgLeftMaxN = 32;
51inline constexpr int kTrsmSgLeftWgSize = 128;
52template <typename T>
53BATCHLAS_INTERNAL_API Event trsm_native_sg_left_dispatch(Queue& ctx,
56 T alpha,
57 Uplo uplo,
58 Transpose transA,
59 Diag diag);
60
61// Trailing-update GEMM, REQUIRED (empty throws): the caller passes the public gemm,
62// which keeps this layer dispatch-free and lets gemm pick its kernel; the native
63// kernel collapses on the strided sub-views a panel passes.
64// evidence: docs/perf/trsm.md#the-final-grid-after-the-routed-trailing-gemm
65template <typename T>
66using TrsmTrailingGemm = std::function<Event(
67 Queue&,
72
73template <typename T>
74BATCHLAS_INTERNAL_API Event trsm_native_blocked(Queue& ctx,
77 T alpha,
78 Side side,
79 Uplo uplo,
80 Transpose transA,
81 Diag diag,
82 TrsmTrailingGemm<T> trailing_gemm);
83
84} // namespace batchlas::sycl_trsm
Non-owning view of a batch of matrices: the argument type of every entry point.
Definition matrix.hh:485
Enumerations, scalar traits and scalar concepts shared by every public header.
Transpose
The operator op() applied to an operand: op(A) = A, A^T or A^H.
Definition enums.hh:171
Diag
Whether a triangular operand's diagonal is read or assumed to be one.
Definition enums.hh:303
ComputePrecision
Internal compute precision of a GEMM (the cuBLAS cublasComputeType_t).
Definition enums.hh:505
Uplo
Which triangle of a symmetric, Hermitian or triangular operand is referenced.
Definition enums.hh:287
Side
Side on which a special operand multiplies: op(A) * B or B * op(A).
Definition enums.hh:319
The batched containers: Matrix (owning), MatrixView (non-owning), KernelMatrixView (device-side),...
BATCHLAS_INTERNAL_API Event trsm_native_sg_left_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, T alpha, Uplo uplo, Transpose transA, Diag diag)
BATCHLAS_INTERNAL_API Event trsm_native_blocked(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, T alpha, Side side, Uplo uplo, Transpose transA, Diag diag, TrsmTrailingGemm< T > trailing_gemm)
std::function< Event( Queue &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, const MatrixView< T, MatrixFormat::Dense > &, T, T, Transpose, Transpose, ComputePrecision)> TrsmTrailingGemm
BATCHLAS_INTERNAL_API Event trsm_native_v1_dispatch(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, T alpha, Side side, Uplo uplo, Transpose transA, Diag diag)
constexpr int trsm_v1_ladder_wg(int max_wg, int cu, int q, int bs)
bool trsm_blocked_available()
constexpr int kTrsmSgLeftWgSize
constexpr int kTrsmSgLeftMaxN
constexpr int kTrsmV1MaxWg
Completion handle of enqueued work, returned by every entry point.
Event()
An empty Event, already complete.
Where BatchLAS work runs: a device, a backend, an ordered SYCL queue and a workspace arena.
batchlas::Device, batchlas::Event and batchlas::Queue: where work runs and how it is ordered.