syrk.hh
Go to the documentation of this file.
1#pragma once
2
3#include <batchlas/export.hh>
8
9namespace batchlas {
10
11// Signature aliases for explicit instantiation; see BATCHLAS_INSTANTIATE in
12// src/util/template-instantiations.hh. Keep in sync with the declarations below.
13namespace sig {
14template <typename T>
15using syrk = Event(Queue&,
16 const MatrixView<T, MatrixFormat::Dense>&,
17 const MatrixView<T, MatrixFormat::Dense>&,
18 T, T, Uplo, Transpose);
19
20// Spelled out, not aliased to sig::syrk: a vendor parameter order may differ
21// from the public one (trsm's alpha is last).
22template <typename T>
23using syrk_vendor = Event(Queue&,
24 const MatrixView<T, MatrixFormat::Dense>&,
25 const MatrixView<T, MatrixFormat::Dense>&,
26 T,
27 T,
28 Uplo,
29 Transpose);
30} // namespace sig
31
32
33/// @brief Batched symmetric rank-k update.
34///
35/// For every batch item computes
36/// \f[ C := \alpha A A^T + \beta C \quad (\texttt{NoTrans},\ A \text{ is } n \times k), \qquad
37/// C := \alpha A^T A + \beta C \quad (\texttt{Trans},\ A \text{ is } k \times n) \f]
38/// with `C` symmetric n x n. Only the triangle of `C` named by `uplo` is written;
39/// the other triangle is left exactly as it was, uninitialised memory included
40/// (use `MatrixView::symmetrize` to mirror it).
41///
42/// Constrained to real `T`; the complex spelling is herk. Also callable as
43/// `syrk(ctx, A, C, SyrkOptions<T>{...})`, with owning `Matrix` arguments, and
44/// without `Ba` (taken from `ctx.backend()`).
45///
46/// Each call takes a kernel family from the tuned table for its shape (@ref selection_tables):
47/// `gram` (one tile covers `C`, n <= 128), `triangular` (`float` only: 128-wide tiles of the
48/// requested half) or `vendor` (the library's per-item `?syrk` loop). Pin one with
49/// `BATCHLAS_SYRK_ROUTE` = `auto` | `native` | `vendor` | `gram` | `triangular`.
50///
51/// @tparam Ba backend the call is compiled for; must match `ctx`'s device
52/// @tparam T `float` or `double`
53/// @param ctx queue the work is enqueued on
54/// @param A batch of n x k (NoTrans) or k x n (Trans) matrices; not modified
55/// @param C batch of n x n matrices; the `uplo` triangle is updated in place
56/// @param alpha scale of the product
57/// @param beta scale of the input `C`
58/// @param uplo which triangle of `C` is written
59/// @param transA `Transpose::NoTrans` or `Transpose::Trans` (`ConjTrans` is accepted and means `Trans`)
60/// @return event of the last enqueued kernel; `C` is valid once it completes
61/// @pre `A` and `C` have the same batch size and conforming shapes per item.
62/// @throws std::invalid_argument if the shapes do not conform, or if `BATCHLAS_SYRK_ROUTE` names
63/// a family that is not compiled for `T` or cannot run this call (`native` and `vendor`
64/// instead fall back to the tuned choice with a warning)
65/// @throws std::runtime_error if no family can run the call in a build with the vendor BLAS
66/// (a heterogeneous batch: every family takes one (n, k) per launch)
67/// @throws batchlas::NoRouteError in a build without the vendor BLAS for `Ba`,
68/// unless the call is `Backend::CUDA` on a GPU, with homogeneous operands,
69/// batch <= 65535, and either `T` is `float` (the `triangular` tiles) or the
70/// `gram` tile admits the shape (@ref md_docs_2perf_2level3).
71/// @see herk, syr2k, SyrkOptions, @ref md_docs_2cpp-api
72/// @ingroup api_blas3
73template <Backend Ba, RealScalar T>
74BATCHLAS_API Event syrk(Queue& ctx,
77 T alpha,
78 T beta,
79 Uplo uplo,
80 Transpose transA);
81
82} // namespace batchlas
83
84
85namespace batchlas::backend {
86
87// Declaration only: each vendor TU defines and instantiates it for its Backend.
88// The public syrk is defined in src/ops/syrk/syrk.cc, outside every vendor TU.
89// evidence: docs/design/vendor-independence.md#the-entry-point-facade
90/// @brief Vendor-library implementation of syrk (cuBLAS, rocBLAS, host BLAS).
91///
92/// Not an entry point: batchlas::syrk calls it. Same arguments and semantics.
93/// @ingroup api_dispatch
94template <Backend Back, RealScalar T>
95BATCHLAS_API Event syrk_vendor(Queue& ctx,
98 T alpha,
99 T beta,
100 Uplo uplo,
101 Transpose transA);
102
103} // namespace batchlas::backend
104
105namespace batchlas {
106
107// Owning-argument (`f(ctx, Matrix, ...)`) and backend-deducing (`f(ctx, ...)`)
108// overloads; see blas/queue-dispatch.hh.
109
110
112
113} // namespace batchlas
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.
Event syrk(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Uplo uplo, Transpose transA)
Batched symmetric rank-k update.
Event syrk_vendor(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Uplo uplo, Transpose transA)
Vendor-library implementation of syrk (cuBLAS, rocBLAS, host BLAS).
Transpose
The operator op() applied to an operand: op(A) = A, A^T or A^H.
Definition enums.hh:171
Uplo
Which triangle of a symmetric, Hermitian or triangular operand is referenced.
Definition enums.hh:287
The batched containers: Matrix (owning), MatrixView (non-owning), KernelMatrixView (device-side),...
Backend deduction from the Queue and the USM pointer check.
#define BATCHLAS_DISPATCH_ON_QUEUE(NAME)
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.