docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
loop_carried_dependency_analysis.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
11#include "sdfg/analysis/users.h"
15#include "sdfg/symbolic/maps.h"
16
17namespace sdfg {
18namespace parallelization {
19
25
36
51
71
72private:
73 struct LoopResult {
74 // False for loops that cannot be analyzed (non-monotonic, no boundary information).
75 bool available = false;
76 std::unordered_map<std::string, LoopCarriedDependencyInfo> dependencies;
77 std::vector<LoopCarriedDependencyPair> pairs;
78 // Recognized reductions: loop-carried read-write dependencies realized by a single
79 // associative/commutative combine on a loop-invariant accumulator location.
80 std::vector<structured_control_flow::ReductionInfo> reductions;
81 };
82
83 analysis::AnalysisManager* analysis_manager_ = nullptr;
84
85 std::unordered_map<const structured_control_flow::StructuredLoop*, LoopResult> results_;
86
87 // Detailed data dependency analyses, keyed by the outermost loop of a nest. Constructed
88 // manually: the manager-cached DDA runs in a cheaper, conservative mode.
89 std::unordered_map<const structured_control_flow::StructuredLoop*, std::unique_ptr<analysis::DataDependencyAnalysis>>
90 nest_ddas_;
91
92 // Branch-condition-aware assumptions (the manager-cached AA skips IfElse refinement, which
93 // the ISL formulation needs to prove halo-style patterns non-loop-carried).
94 std::unique_ptr<analysis::AssumptionsAnalysis> detailed_assumptions_;
95
96 const LoopResult& result(structured_control_flow::StructuredLoop& loop);
97 void compute(structured_control_flow::StructuredLoop& loop, LoopResult& result);
98 void detect_reductions(structured_control_flow::StructuredLoop& loop, LoopResult& result);
100 analysis::AssumptionsAnalysis& detailed_assumptions();
101
102public:
104
105 std::string name() const override {
106 return "LoopCarriedDependencyAnalysis";
107 }
108
110 void run(analysis::AnalysisManager& analysis_manager) override;
111
116
123 const std::unordered_map<std::string, LoopCarriedDependencyInfo>&
125
129 const std::vector<LoopCarriedDependencyPair>& pairs(structured_control_flow::StructuredLoop& loop);
130
138 std::vector<const LoopCarriedDependencyPair*> pairs_between(
142 );
143
148
153
159
169 const std::vector<structured_control_flow::ReductionInfo>& reductions(structured_control_flow::StructuredLoop& loop);
170
175
185};
186
187} // namespace parallelization
188} // namespace sdfg
Definition structured_sdfg.h:30
Definition analysis.h:53
Definition analysis.h:12
Definition assumptions_analysis.h:15
Computes the read-after-write relation between users.
Definition data_dependency_analysis.h:27
bool has_reductions(structured_control_flow::StructuredLoop &loop)
True if the loop carries at least one recognized reduction.
bool available(structured_control_flow::StructuredLoop &loop)
Whether the loop can be analyzed (monotonic, with boundary information).
bool is_reduction_only(structured_control_flow::StructuredLoop &loop)
True if every loop-carried hazard (RAW or undefined) of the loop is a recognized reduction,...
void run(analysis::AnalysisManager &analysis_manager) override
Only records the analysis manager; results are computed on demand per loop.
bool has_loop_carried(structured_control_flow::StructuredLoop &loop)
True if any loop-carried dependency exists for the loop.
const std::vector< LoopCarriedDependencyPair > & pairs(structured_control_flow::StructuredLoop &loop)
Per-pair list of loop-carried dependencies for a loop.
const std::vector< structured_control_flow::ReductionInfo > & reductions(structured_control_flow::StructuredLoop &loop)
Recognized reductions carried by the loop.
bool has_loop_carried_raw(structured_control_flow::StructuredLoop &loop)
True if any loop-carried RAW dependency exists for the loop.
bool has_loop_carried_hazard(structured_control_flow::StructuredLoop &loop)
True if RAW or undefined loop-carried dependency exists.
std::vector< const LoopCarriedDependencyPair * > pairs_between(structured_control_flow::StructuredLoop &loop, const structured_control_flow::ControlFlowNode &subtree_a, const structured_control_flow::ControlFlowNode &subtree_b)
Filter pairs(loop) to those whose writer lies in subtree_a and reader lies in subtree_b (or vice vers...
std::string name() const override
Definition loop_carried_dependency_analysis.h:105
const std::unordered_map< std::string, LoopCarriedDependencyInfo > & dependencies(structured_control_flow::StructuredLoop &loop)
Per-container summary of loop-carried dependencies for a loop.
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Base class for structured loop constructs.
Definition structured_loop.h:244
Definition user.h:28
Analysis of symbol evolution through maps.
Definition loop_carried_dependency_analysis.h:18
LoopCarriedDependency
Definition loop_carried_dependency_analysis.h:20
@ LOOP_CARRIED_DEPENDENCY_WRITE_WRITE
Definition loop_carried_dependency_analysis.h:22
@ LOOP_CARRIED_DEPENDENCY_UNDEFINED
Definition loop_carried_dependency_analysis.h:23
@ LOOP_CARRIED_DEPENDENCY_READ_WRITE
Definition loop_carried_dependency_analysis.h:21
Definition analysis.h:7
Extended loop-carried dependency information including distance vectors.
Definition loop_carried_dependency_analysis.h:32
symbolic::maps::DependenceDeltas deltas
Definition loop_carried_dependency_analysis.h:34
LoopCarriedDependency type
Definition loop_carried_dependency_analysis.h:33
Per-pair loop-carried dependency record.
Definition loop_carried_dependency_analysis.h:45
LoopCarriedDependency type
Definition loop_carried_dependency_analysis.h:48
analysis::User * writer
Definition loop_carried_dependency_analysis.h:46
symbolic::maps::DependenceDeltas deltas
Definition loop_carried_dependency_analysis.h:49
analysis::User * reader
Definition loop_carried_dependency_analysis.h:47
Represents the set of dependence distance vectors between two access patterns.
Definition maps.h:40