docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
tile.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <vector>
6
8#include "sdfg/tiles/layout.h"
9
10namespace sdfg {
11namespace analysis {
12class AnalysisManager;
13}
14namespace tiles {
15
16class LocalityPlan; // produced by Tile::placement, see locality.h
17
27
32enum class Level { Device, Group, Subgroup };
33
36enum class Space { Global, Shared, Register };
37
39enum class Role { Private, Cooperative };
40
43 Level level_ = Level::Device;
44 Space space_ = Space::Global;
45 bool has_scratchpad_ = false;
46 unsigned spatial_axis_ = 0;
47 symbolic::Integer parallel_size_ = symbolic::integer(0);
48 bool needs_sync_ = false;
50
51public:
52 AxisSchedule() = default;
56 bool has_scratchpad,
57 unsigned spatial_axis = 0,
59 bool needs_sync = false,
61 );
62
65 static std::optional<AxisSchedule> classify(const structured_control_flow::ScheduleType& sched);
66
71 static std::optional<Level> classify_level(const structured_control_flow::ScheduleType& sched);
72
78
79 bool has_scratchpad() const {
80 return has_scratchpad_;
81 }
82 Level level() const {
83 return level_;
84 }
85 Space space() const {
86 return space_;
87 }
88 unsigned spatial_axis() const {
89 return spatial_axis_;
90 }
92 return parallel_size_;
93 }
94 bool needs_sync() const {
95 return needs_sync_;
96 }
97 const symbolic::Integer& lanes() const {
98 return lanes_;
99 }
100};
101
104class TileAxis {
105 symbolic::Symbol indvar_;
106 Role role_ = Role::Private;
107 AxisSchedule schedule_;
110
111public:
112 TileAxis() = default;
115 Role role,
119 );
120
127 static std::vector<TileAxis> enclosing(
129 const symbolic::MultiExpression& bases,
130 const symbolic::Expression& offset = symbolic::integer(0)
131 );
132
133 const symbolic::Symbol& indvar() const {
134 return indvar_;
135 }
136 Role role() const {
137 return role_;
138 }
139 const AxisSchedule& schedule() const {
140 return schedule_;
141 }
142 const symbolic::Expression& init() const {
143 return init_;
144 }
145 const symbolic::Integer& stride() const {
146 return stride_;
147 }
148 bool cooperative() const {
149 return role_ == Role::Cooperative;
150 }
151};
152
156class Tile {
157 std::string container_;
159 std::vector<TileAxis> axes_;
160 bool reads_ = false;
161 bool writes_ = false;
162
163public:
164 Tile() = default;
165 Tile(std::string container, Layout source, std::vector<TileAxis> axes, bool reads, bool writes);
166
167 const std::string& container() const {
168 return container_;
169 }
170 const Layout& source() const {
171 return source_;
172 }
173 const std::vector<TileAxis>& axes() const {
174 return axes_;
175 }
176 bool reads() const {
177 return reads_;
178 }
179 bool writes() const {
180 return writes_;
181 }
182
183 bool cooperative() const;
184 std::vector<TileAxis> cooperative_axes() const;
185 std::vector<TileAxis> private_axes() const;
186
190
194};
195
196} // namespace tiles
197} // namespace sdfg
Definition analysis.h:53
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
Base class for structured loop constructs.
Definition structured_loop.h:244
Target-neutral cooperation facts derived from one loop's schedule.
Definition tile.h:42
unsigned spatial_axis() const
Definition tile.h:88
static bool drives_cooperative_copy(const structured_control_flow::ScheduleType &sched)
True when sched is a group-level schedule whose parallel threads can drive a cooperative shared-memor...
Level level() const
Definition tile.h:82
bool has_scratchpad() const
Definition tile.h:79
static std::optional< Level > classify_level(const structured_control_flow::ScheduleType &sched)
The cooperation Level a target assigns to sched, or std::nullopt when no registered target treats it ...
const symbolic::Integer & parallel_size() const
Definition tile.h:91
AxisSchedule(Level level, Space space, bool has_scratchpad, unsigned spatial_axis=0, symbolic::Integer parallel_size=symbolic::integer(0), bool needs_sync=false, symbolic::Integer lanes=symbolic::integer(1))
Space space() const
Definition tile.h:85
const symbolic::Integer & lanes() const
Definition tile.h:97
static std::optional< AxisSchedule > classify(const structured_control_flow::ScheduleType &sched)
Classify a loop's schedule, or std::nullopt for a sequential loop (which does not shape storage).
bool needs_sync() const
Definition tile.h:94
How a tile relates to its enclosing parallel loop nest, and the storage space that relationship deman...
Definition locality.h:24
const symbolic::Symbol & indvar() const
Definition tile.h:133
Role role() const
Definition tile.h:136
const AxisSchedule & schedule() const
Definition tile.h:139
bool cooperative() const
Definition tile.h:148
const symbolic::Expression & init() const
Definition tile.h:142
static std::vector< TileAxis > enclosing(structured_control_flow::StructuredLoop &loop, const symbolic::MultiExpression &bases, const symbolic::Expression &offset=symbolic::integer(0))
The enclosing parallel axes of a tile with the given bases (min index per dim) and linearized offset:...
TileAxis(symbolic::Symbol indvar, Role role, AxisSchedule schedule, symbolic::Expression init=symbolic::integer(0), symbolic::Integer stride=symbolic::integer(1))
const symbolic::Integer & stride() const
Definition tile.h:145
Tile(std::string container, Layout source, std::vector< TileAxis > axes, bool reads, bool writes)
const std::string & container() const
Definition tile.h:167
LocalityPlan placement(structured_control_flow::StructuredLoop &loop, analysis::AnalysisManager &analysis_manager) const
The tile's placement in the enclosing parallel nest at loop — its axes plus loop-context flags,...
const Layout & source() const
Definition tile.h:170
bool reads() const
Definition tile.h:176
const std::vector< TileAxis > & axes() const
Definition tile.h:173
std::vector< TileAxis > private_axes() const
Space required_space() const
The memory space the tile must live in: the coarsest cooperative axis's space (Global > Shared > Regi...
bool writes() const
Definition tile.h:179
bool cooperative() const
std::vector< TileAxis > cooperative_axes() const
Integer integer(int64_t value)
Creates an integer constant.
std::vector< Expression > MultiExpression
Vector of symbolic expressions for multi-dimensional operations.
Definition symbolic.h:89
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 analysis.h:8
Definition gpu_tile_target.h:13
Space
Memory that backs cooperation at a level: Device/CPU -> Global (atomics/heap), Group -> Shared,...
Definition tile.h:36
@ Register
Definition tile.h:36
@ Global
Definition tile.h:36
@ Shared
Definition tile.h:36
math::tensor::TensorLayout Layout
The tiles geometry type is math::tensor::TensorLayout — the single source of truth for a (shape,...
Definition layout.h:11
Role
Whether the tile is per-iteration-private or shared across a parallel axis.
Definition tile.h:39
@ Private
Definition tile.h:39
@ Cooperative
Definition tile.h:39
Level
Cooperation scope of a parallel axis, coarsest to finest — target-neutral tiers (OpenCL/SYCL vocabula...
Definition tile.h:32
@ Group
Definition tile.h:32
@ Subgroup
Definition tile.h:32
@ Device
Definition tile.h:32
Definition analysis.h:7