Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
dispatch_error_presentation.hpp
Go to the documentation of this file.
1#pragma once
2
12
13#include <fmt/core.h>
14#include <string>
15#include <utility>
16#include <vector>
17
18namespace uni20::linalg
19{
20
21namespace detail
22{
23inline std::string_view unavailable_backend_heading(KernelDispatchFailure failure) noexcept
24{
25 switch (failure)
26 {
28 return "No available backend accepts these argument types";
30 return "No available backend accepted this runtime instance";
31 }
32 return "No available backend performed the operation";
33}
34
35inline std::string_view backend_runtime_result_name(KernelBackendAttempt const& attempt) noexcept
36{
37 if (attempt.runtime_result) return kernel_attempt_name(*attempt.runtime_result);
38 if (attempt.type_acceptance == KernelTypeAcceptance::no) return "not eligible";
39 return "not attempted";
40}
41
42inline void append_backend_attempts(presentation::report_builder& report, std::string title,
43 std::vector<KernelBackendAttempt> const& attempts)
44{
45 auto& table = report.table(std::move(title));
49
50 for (auto const& attempt : attempts)
51 {
52 table.row(attempt.backend, kernel_type_acceptance_name(attempt.type_acceptance),
53 backend_runtime_result_name(attempt));
54 }
55}
56} // namespace detail
57
60{
62 if (auto const selected = diagnostic.selected_backend())
63 {
65 fmt::format("Kernel dispatch for '{}' selected '{}'", diagnostic.operation, *selected));
66 }
67 else
68 {
70 fmt::format("Kernel dispatch for '{}' did not select a backend", diagnostic.operation));
71 }
72
73 detail::append_backend_attempts(report, "Ordered backend candidates", diagnostic.backend_attempts);
74 return report;
75}
76
79{
82 fmt::format("Kernel dispatch failed for '{}'", error.operation()));
83
84 detail::append_backend_attempts(report, std::string(detail::unavailable_backend_heading(error.failure())),
85 error.backend_attempts());
86 return report;
87}
88
89} // namespace uni20::linalg
void row(std::vector< formatted_cell > cells, std::source_location where=std::source_location::current())
Emit preformatted cells without discarding their numeric alignment semantics.
Definition display.cpp:448
streaming_table & column(std::string heading, column_width width_spec=width::share(), presentation::table_alignment alignment=presentation::table_alignment::right, column_format format={})
Exception carrying structured information about a failed backend walk.
Definition dispatch_error.hpp:93
Builder for simple terminal reports with headings, status lines, fields, and tables.
Definition presentation.hpp:602
report_builder & status(semantic_glyph glyph, std::string label)
Add a semantic status line such as ✓ converged.
Definition presentation.cpp:1453
report_table & table(std::string title)
Add a titled table and return it for population.
Definition presentation.cpp:1465
Opt-in structured diagnostics for kernel-dispatch walks.
Structured kernel-dispatch failure data.
streaming_table table(std::string title, stream destination)
Create a schema-first streaming display table.
Definition display.cpp:800
Definition linalg/async.hpp:28
presentation::report_builder diagnostic_report(dispatch_diagnostics::event const &diagnostic)
Build a presentation report for one opt-in kernel-dispatch diagnostic event.
Definition dispatch_error_presentation.hpp:59
KernelDispatchFailure
Classify why an ordered kernel-dispatch walk failed.
Definition dispatch_error.hpp:44
constexpr std::string_view kernel_attempt_name(KernelAttempt attempt) noexcept
Return a stable human-readable kernel-attempt result name.
Definition kernel_attempt.hpp:43
Structured result of one ordered kernel-dispatch walk.
Definition dispatch_diagnostics.hpp:24
std::optional< std::string_view > selected_backend() const noexcept
Return the selected backend name, if the dispatch succeeded.
Definition dispatch_diagnostics.hpp:39
std::string operation
Definition dispatch_diagnostics.hpp:25
std::vector< KernelBackendAttempt > backend_attempts
Definition dispatch_diagnostics.hpp:26