docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
reduction_buffer_analysis.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <vector>
6
11
12namespace sdfg {
13namespace tiles {
14
21
27
37
48 std::string diagnostic;
50 std::optional<gpu::ReductionLayout> layout;
53 std::optional<types::PrimitiveType> primitive;
55 std::optional<int64_t> element_bytes;
57 std::optional<int64_t> private_bytes;
59 std::optional<int64_t> shared_bytes;
61 std::optional<size_t> shared_owner;
65 std::string private_buffer;
66 std::string shared_buffer;
68 bool materialized = false;
70 bool multi_output = false;
71};
72
80
90 analysis::AnalysisManager* analysis_manager_ = nullptr;
91
93 ReductionBufferInfo compute(structured_control_flow::Reduce& reduction, const std::string& container) const;
94
95protected:
97 void run(analysis::AnalysisManager& analysis_manager) override;
98
99public:
102
104 std::string name() const override;
105
107 ReductionBufferInfo buffer(structured_control_flow::Reduce& reduction, const std::string& container) const;
108
111 ReductionBufferInfo require(structured_control_flow::Reduce& reduction, const std::string& container) const;
112
119 const std::string& container,
120 ReductionBufferInfo footprint,
121 const ReductionScheduleProposal& proposal
122 ) const;
123
127 const std::string& container,
128 ReductionBufferInfo footprint,
129 const transformations::LoopSwap& proposal
130 ) const;
131
136 const std::string& container,
137 ReductionBufferInfo footprint,
138 const std::vector<ReductionLoopDomain>& inner_domains
139 ) const;
140
144
150 ) const;
152 std::vector<structured_control_flow::Reduce*> affected_reductions(structured_control_flow::StructuredLoop& loop) const;
153
157
159 bool is_partial_buffer(const std::string& container) const;
160};
161
162} // namespace tiles
163} // namespace sdfg
Definition structured_sdfg.h:30
Definition analysis.h:53
Definition analysis.h:12
Represents a loop with an associative/commutative reduction carried dependency.
Definition reduce.h:106
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
Base class for structured loop constructs.
Definition structured_loop.h:244
ReductionBufferInfo estimate_schedule(structured_control_flow::Reduce &reduction, const std::string &container, ReductionBufferInfo footprint, const ReductionScheduleProposal &proposal) const
Reprice a caller-owned exact footprint under a read-only schedule override.
ReductionKernelInfo kernel(const structured_control_flow::StructuredLoop &root) const
Sum shared allocation contributions at or below root, charging each owner once.
std::string name() const override
ReductionBufferInfo estimate_interchange(structured_control_flow::Reduce &reduction, const std::string &container, ReductionBufferInfo footprint, const transformations::LoopSwap &proposal) const
Recompute geometry and allocation ownership from proposed symbolic interchange headers.
bool supports_schedule(structured_control_flow::StructuredLoop &loop, const structured_control_flow::ScheduleType &schedule) const
Check exactness and materialized-buffer compatibility for a proposed schedule, including sibling redu...
void run(analysis::AnalysisManager &analysis_manager) override
Bind the manager and options for dependency queries.
ReductionBufferInfo buffer(structured_control_flow::Reduce &reduction, const std::string &container) const
Infer an independent result, including bounded or unsupported results.
bool supports_interchange(const transformations::LoopSwap &proposal) const
Check interchange analytically without constructing a proposal graph.
std::vector< structured_control_flow::Reduce * > affected_reductions(structured_control_flow::StructuredLoop &loop) const
Return GPU reductions at, above, or below loop in the current graph.
ReductionBufferInfo estimate_geometry(structured_control_flow::Reduce &reduction, const std::string &container, ReductionBufferInfo footprint, const std::vector< ReductionLoopDomain > &inner_domains) const
Recompute an exact footprint from deepest-first domains without changing allocation topology.
ReductionBufferInfo require(structured_control_flow::Reduce &reduction, const std::string &container) const
Require an exact footprint, throwing InvalidSDFGException otherwise.
bool is_partial_buffer(const std::string &container) const
Whether a GPU reduction schedule references container as a private or shared partial.
ReductionBufferAnalysis(StructuredSDFG &sdfg)
Bind the subject graph; AnalysisManager initializes dependencies through run().
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::RCP< const SymEngine::Symbol > Symbol
Reference-counted pointer to a SymEngine Symbol.
Definition symbolic.h:71
SymEngine::RCP< const SymEngine::Integer > Integer
Reference-counted pointer to a SymEngine Integer constant.
Definition symbolic.h:77
Definition gpu_tile_target.h:13
ReductionBufferStatus
How precisely the analysis can describe a reduction's storage requirements.
Definition reduction_buffer_analysis.h:16
@ Exact
Exact layout and allocation costs, suitable for materialization.
Definition reduction_buffer_analysis.h:17
@ Unsupported
No supported footprint; consult the diagnostic.
Definition reduction_buffer_analysis.h:19
@ ConservativeBound
Allocation upper bounds only; not a materializable layout.
Definition reduction_buffer_analysis.h:18
Definition analysis.h:7
One accumulator's logical footprint and allocation contribution.
Definition reduction_buffer_analysis.h:45
std::optional< int64_t > shared_bytes
Per-block shared allocation contributed by this reduction.
Definition reduction_buffer_analysis.h:59
bool materialized
The reduction retains an original index and its packed buffers were validated.
Definition reduction_buffer_analysis.h:68
std::optional< int64_t > element_bytes
Scalar element width in bytes, rounded up from the primitive bit width.
Definition reduction_buffer_analysis.h:55
std::string diagnostic
Explanation for a non-exact result.
Definition reduction_buffer_analysis.h:48
std::string private_buffer
Schedule references to materialized partials; empty before placement.
Definition reduction_buffer_analysis.h:65
std::optional< gpu::ReductionLayout > layout
Original-address to compact-slot mapping, present only for exact results.
Definition reduction_buffer_analysis.h:50
symbolic::Expression accumulator_index
Original body index, retained after accesses are redirected to partials.
Definition reduction_buffer_analysis.h:52
std::optional< int64_t > private_bytes
Per-thread private allocation, or zero when no private partial is needed.
Definition reduction_buffer_analysis.h:57
std::string shared_buffer
Definition reduction_buffer_analysis.h:66
std::optional< types::PrimitiveType > primitive
Definition reduction_buffer_analysis.h:53
ReductionBufferStatus status
Definition reduction_buffer_analysis.h:46
std::optional< size_t > shared_owner
Element ID of the shared allocation's owner, including for nested users.
Definition reduction_buffer_analysis.h:61
symbolic::Expression linear_thread_index
Flattened block-thread coordinate for a shared owner; null otherwise.
Definition reduction_buffer_analysis.h:63
bool multi_output
The original index has inner-loop output axes, including unit-count axes.
Definition reduction_buffer_analysis.h:70
Aggregate reduction-owned shared storage; excludes unrelated staging buffers.
Definition reduction_buffer_analysis.h:74
ReductionBufferStatus status
Definition reduction_buffer_analysis.h:75
std::optional< int64_t > shared_bytes
Exact bytes or an upper bound, according to status; absent if unsupported.
Definition reduction_buffer_analysis.h:77
std::string diagnostic
Definition reduction_buffer_analysis.h:78
One projected affine loop domain; geometry queries consume domains deepest first.
Definition reduction_buffer_analysis.h:29
symbolic::Expression count
Definition reduction_buffer_analysis.h:32
static ReductionLoopDomain from_header(const symbolic::Symbol &indvar, const transformations::LoopHeader &header)
symbolic::Integer stride
Definition reduction_buffer_analysis.h:33
symbolic::Expression init
Definition reduction_buffer_analysis.h:31
symbolic::Symbol indvar
Definition reduction_buffer_analysis.h:30
A schedule-only change; loop domains, access expressions, and nesting stay fixed.
Definition reduction_buffer_analysis.h:23
structured_control_flow::StructuredLoop & loop
Definition reduction_buffer_analysis.h:24
const structured_control_flow::ScheduleType & schedule
Definition reduction_buffer_analysis.h:25
Bounds and step of a loop, keeping its induction variable.
Definition loop_header.h:10
Two directly nested loops and their headers after swapping them.
Definition loop_header.h:17