gesvd_native.hh
Go to the documentation of this file.
1#pragma once
2
3// The gesvd drivers' own shape ceilings, sycl-free, read by gesvd's can_run and the drivers.
4
5#include <complex>
6#include <cstddef>
7#include <cstdint>
8#include <type_traits>
9
11
12// gesvdj_cta's smallest work-group at tile capacity C: 32 / P problems (P = min(C, 32)) plus
13// the pivot-pair table, as gesvdj_cta.cc allocates. evidence: docs/design/gesvd.md#gesvdj_cta-local-memory-budget-formula
14template <typename T>
15constexpr std::size_t gesvdj_slm_bytes(std::size_t C, bool want_vectors) {
16 using Real = std::conditional_t<std::is_same_v<T, std::complex<float>>, float,
17 std::conditional_t<std::is_same_v<T, std::complex<double>>, double, T>>;
18 constexpr bool kComplex = !std::is_same_v<T, Real>;
19 const std::size_t P = C < 32 ? C : 32;
20 const std::size_t rot = C / 2 > 0 ? C / 2 : 1;
21 const std::size_t tile = (C + 1) * C;
22 const std::size_t per_prob = (want_vectors ? 2 : 1) * tile * sizeof(T) + C * sizeof(Real) +
23 2 * rot * sizeof(Real) + (kComplex ? rot * sizeof(T) : 0) + C * sizeof(std::int16_t);
24 return (32 / P) * per_prob + (C - 1) * rot * sizeof(std::int16_t);
25}
26
27// Largest max(m, n) gesvdj_cta accepts: the widest C whose smallest work-group fits the budget.
28template <typename T>
29constexpr std::int64_t gesvd_jacobi_max_dim(bool want_vectors, std::size_t slm_budget_bytes) {
30 for (std::size_t C = 64; C >= 4; C /= 2)
31 if (gesvdj_slm_bytes<T>(C, want_vectors) <= slm_budget_bytes) return static_cast<std::int64_t>(C);
32 return 0;
33}
34
35// Largest max(m, n) gesvd_cta accepts: one sub-group per matrix.
36inline constexpr std::int64_t kGesvdCtaMaxDim = 32;
37
38} // namespace batchlas::sycl_gesvd
constexpr std::size_t gesvdj_slm_bytes(std::size_t C, bool want_vectors)
constexpr std::int64_t kGesvdCtaMaxDim
constexpr std::int64_t gesvd_jacobi_max_dim(bool want_vectors, std::size_t slm_budget_bytes)