coverage.hh
Go to the documentation of this file.
1#pragma once
2
3/// @file
4/// @brief What this build links and what a run reached, as CSV in BATCHLAS_COVERAGE_OUT.pid; the
5/// columns are a contract with scripts/, tools/tune and benchviz. @ingroup api_selection
6// evidence: docs/perf/dispatch.md#dispatch-the-coverage-instrument
7
8#include <batchlas/export.hh>
10
11#include <cstdint>
12#include <string>
13
14namespace batchlas::coverage { /** @addtogroup api_selection */ /** @{ */
15
16struct Shape { // the row key: different triangles or operands are different rows
20 int64_t m = 0, n = 0, k = 0; // square ops set all three
21 int64_t batch = 1;
27
28 int64_t max_dim() const { return m > n ? (m > k ? m : k) : (n > k ? n : k); }
29
30 uint32_t shape_class() const { // power-of-two buckets on max(m,n,k) and batch
31 auto log2b = [](int64_t v) -> uint32_t {
32 uint32_t r = 0;
33 while (v > 1) { v >>= 1; ++r; }
34 return r;
35 };
36 return (log2b(max_dim()) << 8) | log2b(batch);
37 }
38};
39
40/// A `reached` row: origin "native"/"vendor" and the choice spelling. native_route_supported
41/// is 1, 0, or -1 when the call site cannot tell.
42BATCHLAS_API void record_choice(Op op, ScalarKind scalar, Backend backend, const Shape& shape,
43 const char* origin, const char* spelling, bool native_route_existed,
44 int native_route_supported);
45
46BATCHLAS_API void record_miss( // a call that found nothing to run; always recorded
47 Op op, ScalarKind scalar, Backend backend, const char* library);
48
49BATCHLAS_API std::string static_table(); // the `linked` rows: what this build contains
50
51/// Set once from $BATCHLAS_COVERAGE_OUT; tests toggle it across the DSO boundary (a runtime bool in one TU).
52BATCHLAS_API extern bool g_dynamic_enabled;
53
54inline bool dynamic_enabled() { return g_dynamic_enabled; }
55
56/** @} */ } // namespace batchlas::coverage
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
Backend
Library family an entry point dispatches to, used as a template argument.
Definition enums.hh:111
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
@ NoTrans
op(A) = A.
Definition enums.hh:172
@ NonUnit
The stored diagonal is used.
Definition enums.hh:304
@ AUTO
A request, not a backend: the Queue resolves it from its device on first query.
Definition enums.hh:112
@ Lower
The lower triangle (i >= j).
Definition enums.hh:289
@ Left
The special operand is on the left.
Definition enums.hh:320
void record_miss(Op op, ScalarKind scalar, Backend backend, const char *library)
std::string static_table()
void record_choice(Op op, ScalarKind scalar, Backend backend, const Shape &shape, const char *origin, const char *spelling, bool native_route_existed, int native_route_supported)
A reached row: origin "native"/"vendor" and the choice spelling.
bool dynamic_enabled()
Definition coverage.hh:54
bool g_dynamic_enabled
Set once from $BATCHLAS_COVERAGE_OUT; tests toggle it across the DSO boundary (a runtime bool in one ...
uint32_t shape_class() const
Definition coverage.hh:30
int64_t max_dim() const
Definition coverage.hh:28