docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
gpu_tile_target.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <utility>
6
11
12namespace sdfg {
13namespace tiles {
14
24class GPUTileTarget : public TileTarget {
25 unsigned lane_width_;
26 std::string offload_value_;
27 data_flow::ImplementationType implementation_type_;
28 size_t min_async_bytes_;
29
30 static unsigned spatial_axis_of(gpu::TargetLevel tl) {
31 switch (tl) {
34 return 1;
37 return 2;
38 default:
39 return 0;
40 }
41 }
42
43public:
45 unsigned lane_width,
46 std::string offload_value,
48 size_t min_async_bytes = 4
49 )
50 : lane_width_(lane_width), offload_value_(std::move(offload_value)),
51 implementation_type_(std::move(implementation_type)), min_async_bytes_(min_async_bytes) {
52 }
53
54 std::optional<AxisSchedule> classify(const structured_control_flow::ScheduleType& sched) const override {
55 if (sched.value() == offload_value_) {
60 return AxisSchedule(
61 level,
62 space(level),
64 spatial_axis_of(tl),
68 );
69 }
70 // Legacy fused block-thread schedule.
71 return AxisSchedule(
73 );
74 }
75
77 Space space(Level level) const override {
78 switch (level) {
79 case Level::Device:
80 return Space::Global; // device-wide cooperation (GPU grid): only global memory
81 case Level::Group:
82 return Space::Shared;
83 case Level::Subgroup:
84 return Space::Register;
85 }
86 return Space::Register;
87 }
88
90 // Only the offload schedule carries a separable block-thread copy Map; the
91 // legacy fused schedule cannot host cooperative shared-memory staging.
92 return sched.value() == offload_value_;
93 }
94
96 switch (space) {
97 case Space::Shared:
99 case Space::Global:
101 case Space::Register:
103 }
105 }
106
107 unsigned lane_width() const override {
108 return lane_width_;
109 }
110
112 std::optional<tiles::BankModel> bank_model(tiles::Space space) const override {
114 return tiles::BankModel{32, 4};
115 }
116 return std::nullopt;
117 }
118
120 return implementation_type_;
121 }
122
123 size_t min_async_bytes() const override {
124 return min_async_bytes_;
125 }
126};
127
128} // namespace tiles
129} // namespace sdfg
static symbolic::Integer lanes(const structured_control_flow::ScheduleType &schedule)
Lanes that jointly execute each iteration (1 = one thread per iteration; the warp size = one wave per...
Definition gpu_offload_schedule_type.h:170
static void parallel_size(structured_control_flow::ScheduleType &schedule, const symbolic::Integer parallel_size)
Set the parallel size for a schedule.
Definition gpu_offload_schedule_type.h:150
static bool nested_sync(const structured_control_flow::ScheduleType &schedule)
Check if nested synchronization is enabled.
Definition gpu_offload_schedule_type.h:203
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
const std::string & value() const
Get the schedule type identifier.
Definition structured_loop.h:45
Target-neutral cooperation facts derived from one loop's schedule.
Definition tile.h:42
data_flow::ImplementationType implementation_type() const override
The implementation selector this target stamps onto its tile codegen library nodes (cp....
Definition gpu_tile_target.h:119
size_t min_async_bytes() const override
The narrowest per-lane async (CpAsync) transfer in bytes; narrower copies stay synchronous.
Definition gpu_tile_target.h:123
bool supports_cooperative_staging(const structured_control_flow::ScheduleType &sched) const override
Whether sched can host a block-cooperative shared-memory staging copy driven by its own parallel thre...
Definition gpu_tile_target.h:89
GPUTileTarget(unsigned lane_width, std::string offload_value, data_flow::ImplementationType implementation_type, size_t min_async_bytes=4)
Definition gpu_tile_target.h:44
Space space(Level level) const override
The GPU scratchpad hierarchy: Device->Global, Group->Shared, Subgroup->Register.
Definition gpu_tile_target.h:77
unsigned lane_width() const override
The SIMD lane / subgroup width, used only to keep a subgroup's cooperative stores bank-conflict-free ...
Definition gpu_tile_target.h:107
std::optional< AxisSchedule > classify(const structured_control_flow::ScheduleType &sched) const override
Classify one loop's sched into target-neutral cooperation facts (AxisSchedule: level,...
Definition gpu_tile_target.h:54
types::StorageType storage_type(Space space) const override
The concrete buffer that realizes an abstract cooperation Space on this target: e....
Definition gpu_tile_target.h:95
std::optional< tiles::BankModel > bank_model(tiles::Space space) const override
Shared memory (NVIDIA and CDNA LDS): 32 banks of 4 bytes.
Definition gpu_tile_target.h:112
Definition tile_target.h:39
bool has_scratchpad() const
Whether this target exposes any on-chip cooperative tier below global memory (a scratchpad hierarchy)...
Definition tile_target.h:61
Represents the storage location and management characteristics of data.
Definition type.h:64
static StorageType CPU_Stack()
Creates a CPU stack storage type.
Definition type.h:270
static StorageType NV_Shared()
Creates an NVIDIA shared memory storage type.
Definition type.h:308
static StorageType NV_Global()
Creates an NVIDIA global memory storage type.
Definition type.h:303
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
TargetLevel
Definition gpu_offload_schedule_type.h:13
@ Z_BLOCK
Definition gpu_offload_schedule_type.h:19
@ Y_BLOCK
Definition gpu_offload_schedule_type.h:18
@ Y_GRID
Definition gpu_offload_schedule_type.h:15
@ Z_GRID
Definition gpu_offload_schedule_type.h:16
TargetLevel gpu_target_level(const structured_control_flow::ScheduleType &schedule)
Get the GPU target level from any GPU schedule type.
Definition gpu_offload_schedule_type.h:282
bool is_grid_level(TargetLevel target_level)
symbolic::Integer gpu_block_size(const structured_control_flow::ScheduleType &schedule)
Get the block size from any GPU schedule type Returns default values if not explicitly set:
Definition gpu_schedule_type.h:129
bool is_block_level(TargetLevel target_level)
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
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
A banked on-chip memory: banks banks of bank_bytes each, every bank serving one word per cycle.
Definition bank_conflicts.h:16
The complete target-specific contract of the tile algebra.