33 std::unordered_map<std::string, std::string> properties_;
45 const std::string&
value()
const {
53 const std::unordered_map<std::string, std::string>&
properties()
const {
71 if (properties_.find(key) == properties_.end()) {
72 properties_.insert({key,
value});
75 properties_.at(key) =
value;
83 properties_.erase(key);
89 for (
const auto& entry : rhs.properties_) {
90 properties_.insert(entry);
92 category_ = rhs.category_;
122 schedule.
set_property(
"unroll", full ?
"full" :
"none");
127 auto it = schedule.
properties().find(
"unroll");
128 return it != schedule.
properties().end() && it->second ==
"full";
141 schedule.
set_property(
"fusion", no_fusion ?
"none" :
"default");
145 auto it = schedule.
properties().find(
"fusion");
146 return it != schedule.
properties().end() && it->second ==
"none";
160 static constexpr const char*
KEY =
"init";
168 return it != schedule.
properties().end() && it->second ==
"zero";
180 static const std::vector<std::string>&
keys() {
187 for (
const auto& key :
keys()) {
197 for (
const auto& key :
keys()) {
207 for (
const auto& key :
keys()) {
Element(size_t element_id, const DebugInfo &debug_info)
size_t element_id() const
const DebugInfo & debug_info() const
virtual ElementType type_id() const =0
Returns the type of the element.
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
ControlFlowNode(size_t element_id, const DebugInfo &debug_info, ControlFlowNode *parent)
Protected constructor for control flow nodes with parent.
Annotations describing a whole loop nest rather than a single loop's execution strategy.
Definition structured_loop.h:178
static void inherit(const ScheduleType &from, ScheduleType &to)
Copy nest annotations present on from onto to, unless to already sets them.
Definition structured_loop.h:196
static void copy(const ScheduleType &from, ScheduleType &to)
Copy all nest annotations present on from onto to (overwriting).
Definition structured_loop.h:186
static const std::vector< std::string > & keys()
Definition structured_loop.h:180
static void strip(ScheduleType &schedule)
Remove all nest annotations from schedule.
Definition structured_loop.h:206
No-fusion annotation carried as a generic property on any ScheduleType.
Definition structured_loop.h:138
static void set(ScheduleType &schedule, bool no_fusion=true)
Definition structured_loop.h:140
static bool is_set(const ScheduleType &schedule)
Definition structured_loop.h:144
Sequential schedule type for Map nodes.
Definition structured_loop.h:101
static const std::string value()
Definition structured_loop.h:103
static ScheduleType create()
Definition structured_loop.h:106
Unroll annotation carried as a generic property on any ScheduleType.
Definition structured_loop.h:118
static void set(ScheduleType &schedule, bool full=true)
Mark (or clear) the schedule for full unrolling.
Definition structured_loop.h:121
static bool is_set(const ScheduleType &schedule)
True if the schedule is marked for full unrolling.
Definition structured_loop.h:126
Zero-initialization annotation carried as a generic property on any ScheduleType.
Definition structured_loop.h:158
static void set(ScheduleType &schedule, bool zero_init=true)
Definition structured_loop.h:162
static constexpr const char * KEY
Definition structured_loop.h:160
static bool is_set(const ScheduleType &schedule)
Definition structured_loop.h:166
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
void operator=(const ScheduleType &rhs)
Definition structured_loop.h:86
const std::unordered_map< std::string, std::string > & properties() const
Get all schedule properties.
Definition structured_loop.h:53
void set_property(const std::string &key, const std::string &value)
Set a schedule property.
Definition structured_loop.h:70
void remove_property(const std::string &key)
Remove a schedule property if present.
Definition structured_loop.h:82
ScheduleTypeCategory category() const
Get the schedule type category.
Definition structured_loop.h:61
ScheduleType(std::string value, ScheduleTypeCategory category)
Definition structured_loop.h:38
const std::string & value() const
Get the schedule type identifier.
Definition structured_loop.h:45
A sequential container of control flow nodes.
Definition sequence.h:52
bool is_loop_normal_form() const
Checks if the loop is in a normal form.
symbolic::Expression compute_num_iterations() const
static bool classof(const Element &element)
LLVM-style RTTI predicate: true if element is a StructuredLoop.
Definition structured_loop.h:288
const symbolic::Expression update() const
Get the update expression for the induction variable.
std::optional< symbolic::Expression > num_iterations_cache_
Definition structured_loop.h:260
symbolic::Expression num_iterations() const
Describes the number of iterations of a loop as a closed-form expression.
void replace(const symbolic::ExpressionMapping &replacements) override
symbolic::Expression init_
Definition structured_loop.h:249
std::optional< symbolic::Expression > canonical_bound_cache_
Definition structured_loop.h:259
symbolic::Expression num_iterations_approx() const
Overapproximated (upper-bound) number of iterations.
symbolic::Condition condition_
Definition structured_loop.h:251
const symbolic::Symbol indvar() const
Get the induction variable (loop counter) symbol.
const ScheduleType & schedule_type() const
Get the scheduling strategy for this Map.
bool is_monotonic() const
Checks if the loop is monotonic (i.e., stride is a positive integer).
virtual ~StructuredLoop()=default
symbolic::Symbol indvar_
Definition structured_loop.h:248
const symbolic::Expression init() const
Get the initialization expression for the induction variable.
static constexpr size_t REQUIRED_ELEMENT_IDS
Definition structured_loop.h:281
StructuredLoop(size_t element_id, const DebugInfo &debug_info, ControlFlowNode *parent, symbolic::Symbol indvar, symbolic::Expression init, symbolic::Expression update, symbolic::Condition condition, const ScheduleType &schedule_type=ScheduleType_Sequential::create())
symbolic::Expression update_
Definition structured_loop.h:250
symbolic::Integer compute_stride() const
static constexpr ElementType TypeGroup
Bitmask of all concrete ElementTypes that are StructuredLoops.
Definition structured_loop.h:285
symbolic::Expression canonical_bound_upper() const
Describes the upper bound of a loop (for positive stride).
const symbolic::Condition condition() const
Get the loop continuation condition.
void validate(const Function &function) const override
Validates the element.
symbolic::Expression canonical_bound() const
Describes the bound of a loop as a closed-form expression.
Sequence & root() const
Access the loop body sequence.
std::unique_ptr< Sequence > root_
Definition structured_loop.h:253
StructuredLoop(const StructuredLoop &node)=delete
StructuredLoop & operator=(const StructuredLoop &)=delete
std::optional< symbolic::Integer > stride_cache_
Definition structured_loop.h:258
void replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace occurrences of an expression in loop parameters and body.
symbolic::Expression canonical_bound_lower() const
Describes the lower bound of a loop (for negative stride).
symbolic::Integer stride() const
Describes the stride of a loop's update as a constant.
bool is_contiguous() const
Checks if the loop has a positive unit stride (i.e., update is indvar + 1).
ScheduleType schedule_type_
Definition structured_loop.h:255
symbolic::Expression compute_canonical_bound() const
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::Boolean > Condition
Reference-counted pointer to a boolean condition expression.
Definition symbolic.h:86
SymEngine::RCP< const SymEngine::Integer > Integer
Reference-counted pointer to a SymEngine Integer constant.
Definition symbolic.h:77
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition function_builder.h:10
Definition language_extension.h:18
ScheduleTypeCategory
Categories of schedule types for Map nodes Defines the high-level classification of scheduling strate...
Definition structured_loop.h:22
@ Parallelizer
Definition structured_loop.h:22
@ None
Definition structured_loop.h:22
@ Vectorizer
Definition structured_loop.h:22
@ Offloader
Definition structured_loop.h:22
constexpr bool is_a(ElementType type, ElementType mask)
Tests whether type is contained in the category mask (efficient, branch-free type check).
Definition element.h:107
ElementType
Definition element.h:72
@ For
Definition element.h:88
@ Map
Definition element.h:89
@ Reduce
Definition element.h:90
Symbolic system for integer-based symbol analysis.