no_route.hh
Go to the documentation of this file.
1#pragma once
2
3// What a call throws when nothing in this build can serve it: no native kernel for
4// the shape and no vendor library compiled in. SYCL-free, so the op enum can key
5// installed headers too.
6
7#include <complex>
8#include <cstdint>
9#include <stdexcept>
10#include <string>
11#include <string_view>
12#include <type_traits>
13
15#include <batchlas/error.hh>
16
17namespace batchlas {
18
19// The public ops that can lack an implementation in a build (one per
20// include/batchlas/blas/functions/*.hh).
27
28enum class ScalarKind : uint8_t { F32, F64, C32, C64 };
29
30template <typename T>
31inline constexpr ScalarKind scalar_kind_of =
32 std::is_same_v<T, float> ? ScalarKind::F32 :
33 std::is_same_v<T, double> ? ScalarKind::F64 :
34 std::is_same_v<T, std::complex<float>> ? ScalarKind::C32 :
36
37inline constexpr std::string_view to_string(ScalarKind s) {
38 switch (s) {
39 case ScalarKind::F32: return "float";
40 case ScalarKind::F64: return "double";
41 case ScalarKind::C32: return "complex<float>";
42 case ScalarKind::C64: return "complex<double>";
43 }
44 return "?";
45}
46
47inline constexpr std::string_view op_name(Op o) {
48 switch (o) {
49 case Op::gemm: return "gemm"; case Op::gemv: return "gemv";
50 case Op::trsm: return "trsm"; case Op::trmm: return "trmm";
51 case Op::symm: return "symm"; case Op::hemm: return "hemm";
52 case Op::syrk: return "syrk"; case Op::herk: return "herk";
53 case Op::syr2k: return "syr2k"; case Op::her2k: return "her2k";
54 case Op::potrf: return "potrf"; case Op::getrf: return "getrf";
55 case Op::getrs: return "getrs"; case Op::getri: return "getri";
56 case Op::geqrf: return "geqrf"; case Op::orgqr: return "orgqr";
57 case Op::ormqr: return "ormqr"; case Op::syev: return "syev";
58 case Op::gesvd: return "gesvd"; case Op::spmm: return "spmm";
59 case Op::gesv: return "gesv"; case Op::posv: return "posv";
60 case Op::COUNT: return "?";
61 }
62 return "?";
63}
64
65// The usual cause is a deliberate -DBATCHLAS_ENABLE_VENDOR_BLAS=OFF, so the message
66// says which build switch brings an implementation back. A batchlas::unsupported (so also a
67// std::runtime_error); exported, or catch-by-type breaks under -fvisibility=hidden.
68class BATCHLAS_API NoRouteError : public batchlas::unsupported {
69public:
71 : batchlas::unsupported(build_message(op, scalar, detail)),
72 op_(op), backend_(backend), scalar_(scalar) {}
73
74 Op op() const { return op_; }
75 Backend backend() const { return backend_; }
76 ScalarKind scalar() const { return scalar_; }
77
78private:
79 static std::string build_message(Op op, ScalarKind scalar, const std::string& detail) {
80 std::string m = "BatchLAS: no route for ";
81 m += op_name(op);
82 m += "<";
83 m += to_string(scalar);
84 m += "> on this backend";
85 if (!detail.empty()) {
86 m += " (" + detail + ")";
87 }
88 m += ".\n";
89 m += " This build has no vendor library for that op, and BatchLAS has no\n"
90 " native kernel for it yet. If you configured with\n"
91 " -DBATCHLAS_ENABLE_VENDOR_BLAS=OFF, re-enabling it restores this op;\n"
92 " otherwise the vendor library was not found at configure time.";
93 return m;
94 }
95
96 Op op_;
97 Backend backend_;
98 ScalarKind scalar_;
99};
100
101} // namespace batchlas
ScalarKind scalar() const
Definition no_route.hh:76
Backend backend() const
Definition no_route.hh:75
NoRouteError(Op op, Backend backend, ScalarKind scalar, std::string detail)
Definition no_route.hh:70
No kernel, backend or vendor entry point in this build on this device serves the request.
Definition error.hh:122
unsupported(const std::string &what_arg)
Definition error.hh:124
Enumerations, scalar traits and scalar concepts shared by every public header.
The BatchLAS exception hierarchy.
Event gemv(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const VectorView< T > &X, const VectorView< T > &Y, T alpha, T beta, Transpose transA)
Batched general matrix-vector multiply.
Event syr2k(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Uplo uplo, Transpose transA)
Batched symmetric rank-2k update.
Event herk(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &C, float_t< T > alpha, float_t< T > beta, Uplo uplo, Transpose transA)
Batched Hermitian rank-k update.
Event hemm(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Side side, Uplo uplo)
Batched Hermitian matrix-matrix multiply.
Event gemm(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Transpose transA, Transpose transB, ComputePrecision precision=ComputePrecision::Default)
Batched general matrix-matrix multiply.
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 trsm(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, T alpha, Side side, Uplo uplo, Transpose transA, Diag diag)
Batched triangular solve with multiple right-hand sides, in place.
Event her2k(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, float_t< T > beta, Uplo uplo, Transpose transA)
Batched Hermitian rank-2k update.
Event trmm(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, Side side, Uplo uplo, Transpose transA, Diag diag)
Batched triangular matrix-matrix multiply, out of place.
Event symm(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, const MatrixView< T, MatrixFormat::Dense > &C, T alpha, T beta, Side side, Uplo uplo)
Batched symmetric matrix-matrix multiply.
Event syev(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &descrA, Span< typename base_type< T >::type > eigenvalues, JobType jobtype, Uplo uplo, Span< std::byte > workspace, Span< int32_t > info)
Eigenvalues, and optionally eigenvectors, of a batch of symmetric/Hermitian matrices (LAPACK ?...
constexpr std::string_view to_string(MatrixFormat v)
Spelling of v as in source.
Definition enums.hh:84
Backend
Library family an entry point dispatches to, used as a template argument.
Definition enums.hh:111
@ F64
64-bit float accumulation.
Definition enums.hh:508
@ F32
32-bit float accumulation.
Definition enums.hh:507
Event potrf(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &descrA, Uplo uplo, Span< std::byte > workspace, Span< int32_t > info)
Batched Cholesky factorization of Hermitian positive-definite matrices.
Event getrs(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Transpose transA, Span< int64_t > pivots, Span< std::byte > work_space)
Batched solve of using the LU factors from getrf().
Event getrf(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< int64_t > pivots, Span< std::byte > work_space, Span< int32_t > info)
Batched LU factorization with partial pivoting.
Event posv(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Uplo uplo, Span< std::byte > work_space, Span< int32_t > info)
Batched solve of for Hermitian positive-definite A.
Event gesv(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &B, Span< int64_t > pivots, Span< std::byte > work_space, Span< int32_t > info)
Batched solve of by LU with partial pivoting.
Event getri(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &C, Span< int64_t > pivots, Span< std::byte > work_space, Span< int32_t > info)
Batched inverse from the LU factors produced by getrf().
Event orgqr(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< T > tau, Span< std::byte > workspace)
Batched formation of the first n columns of Q from geqrf() output.
Event geqrf(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< T > tau, Span< std::byte > work_space)
Batched Householder QR factorization .
Event ormqr(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, const MatrixView< T, MatrixFormat::Dense > &C, Side side, Transpose trans, Span< T > tau, Span< std::byte > workspace, int32_t block_size_hint=0)
Batched multiplication by the orthogonal/unitary Q from geqrf().
Event spmm(Queue &ctx, const MatrixView< T, MFormat > &A, const MatrixView< T, MatrixFormat::Dense > &descrB, const MatrixView< T, MatrixFormat::Dense > &descrC, T alpha, T beta, Transpose transA, Transpose transB, Span< std::byte > workspace)
Batched sparse-times-dense matrix multiply.
Event gesvd(Queue &ctx, const MatrixView< T, MatrixFormat::Dense > &A, Span< typename base_type< T >::type > singular_values, const MatrixView< T, MatrixFormat::Dense > &U, const MatrixView< T, MatrixFormat::Dense > &Vh, SvdVectors jobu, SvdVectors jobvh, Span< std::byte > workspace, Span< int32_t > info)
Singular value decomposition of a batch of matrices (LAPACK ?gesvd).
constexpr std::string_view op_name(Op o)
Definition no_route.hh:47
constexpr ScalarKind scalar_kind_of
Definition no_route.hh:31