docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
gpu_map_utils.h
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_map>
4#include <vector>
5
13
14namespace sdfg {
15
16// Forward declarations for explicit template instantiation
17namespace cuda {
20} // namespace cuda
21namespace rocm {
24} // namespace rocm
25
26namespace gpu {
27
36
45template<typename ScheduleT>
48);
49
58template<typename ScheduleT>
61);
62
70template<typename ScheduleT>
72
81template<typename ScheduleT>
84);
85
90
91// Warp/wavefront size of the target, mirroring the offload dispatchers'
92// get_warp_size() (cuda::CUDA_WARP_SIZE / rocm::ROCM_WARP_SIZE).
93template<typename GPUType>
94int64_t gpu_warp_size();
95
96template<>
98template<>
100
101// Runtime variant dispatching on an offload schedule's target (defaults to the
102// CUDA warp size for any non-ROCm schedule).
104
118template<typename ScheduleT>
119std::vector<structured_control_flow::Map*>
121
156);
157
162
164 bool unsafe = false;
165 std::vector<FoldBarrier> barriers;
166};
167
170);
171
173
175
176// Coarse GPU cooperation level of a target axis.
177bool is_grid_level(TargetLevel target_level);
178bool is_block_level(TargetLevel target_level);
179bool is_warp_level(TargetLevel target_level);
180
181// Induction variables of every offloaded loop (Map or Reduce) at @p target_level
182// in @p node's subtree (including @p node itself).
185);
186
187// Per-level launch schedule for @p node's subtree: for each occupied target level,
188// the offloaded schedule with the largest thread count (parallel_size * lanes), so a
189// single launch dimension covers every sibling at that level.
192 analysis::AnalysisManager& analysis_manager,
193 std::unordered_map<TargetLevel, structured_control_flow::ScheduleType>& output
194);
195
196// Per-level launch map for @p node's subtree: for each occupied target level, the
197// offloaded loop with the largest parallel_size (matching get_nested_schedule_types).
198// Exposes the loop node so callers can read its num_iterations for the launch size.
201 analysis::AnalysisManager& analysis_manager,
202 std::unordered_map<TargetLevel, structured_control_flow::StructuredLoop*>& output
203);
204
206
207// Throws unless every lanes > 1 offload loop in @p node's subtree is an X_BLOCK Map with
208// lanes == the warp size of its ARCH (or @p warp_size without one) and no nested WARP loop.
210 structured_control_flow::StructuredLoop& node, analysis::AnalysisManager& analysis_manager, int64_t warp_size
211);
212
215);
216
217// Counts the depth of the perfectly nested loop chain starting at `loop`.
218// A loop is perfectly nested when its body sequence has exactly one child and
219// that child is another map or reduce node.
221
222// Extern template declarations to prevent implicit instantiation
227
232
233extern template bool is_outermost_gpu_map<
235extern template bool is_outermost_gpu_map<
237
242
243extern template std::vector<structured_control_flow::Map*> get_gpu_maps<
245extern template std::vector<structured_control_flow::Map*> get_gpu_maps<
247
248} // namespace gpu
249} // namespace sdfg
Definition analysis.h:53
CUDA schedule type inheriting shared GPU functionality Provides CUDA-specific value() and default blo...
Definition cuda.h:43
CUDA schedule type inheriting shared GPU functionality Provides CUDA-specific value() and default blo...
Definition cuda.h:56
ROCM schedule type inheriting shared GPU functionality Provides ROCM-specific value() and default blo...
Definition rocm.h:43
ROCM schedule type inheriting shared GPU functionality Provides ROCM-specific value() and default blo...
Definition rocm.h:56
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Represents a parallel map loop with configurable scheduling.
Definition map.h:47
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
A sequential container of control flow nodes.
Definition sequence.h:52
Base class for structured loop constructs.
Definition structured_loop.h:244
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
std::set< Symbol, SymEngine::RCPBasicKeyLess > SymbolSet
Ordered set of symbols.
Definition symbolic.h:95
Definition cuda_library_node_rewriter_pass.h:11
Definition cuda_arch.h:11
TargetLevel
Definition gpu_offload_schedule_type.h:13
structured_control_flow::StructuredLoop * find_x_block_owning_warp_level(structured_control_flow::StructuredLoop &node, analysis::AnalysisManager &analysis_manager)
bool nested_parallelization_is_unsafe(structured_control_flow::StructuredLoop &loop, analysis::AnalysisManager &analysis_manager)
Whether parallelizing loop to a new GPU grid dimension would race on a shared container.
void get_nested_schedule_types(structured_control_flow::StructuredLoop &node, analysis::AnalysisManager &analysis_manager, std::unordered_map< TargetLevel, structured_control_flow::ScheduleType > &output)
int64_t gpu_warp_size()
symbolic::Expression find_nested_gpu_iterations(structured_control_flow::Map &node, analysis::AnalysisManager &analysis_manager, GPUDimension dimension)
Find the number of iterations for nested GPU maps in a given dimension.
bool is_grid_level(TargetLevel target_level)
symbolic::SymbolSet get_gpu_indvars(structured_control_flow::Map &node, analysis::AnalysisManager &analysis_manager, GPUDimension dimension)
Get all induction variables for GPU maps in a given dimension.
void validate_wave_maps(structured_control_flow::StructuredLoop &node, analysis::AnalysisManager &analysis_manager, int64_t warp_size)
symbolic::Expression find_nested_gpu_blocksize(structured_control_flow::Map &node, analysis::AnalysisManager &analysis_manager, GPUDimension dimension)
GPU map utility functions shared between CUDA and ROCm.
bool is_warp_level(TargetLevel target_level)
int64_t gpu_warp_size< sdfg::cuda::ScheduleType_CUDA_Offload >()
bool is_outermost_gpu_map(structured_control_flow::Map &node, analysis::AnalysisManager &analysis_manager)
Check if a map is the outermost GPU map in the loop tree.
bool is_block_level(TargetLevel target_level)
NestedFoldPlan analyze_nested_fold(structured_control_flow::StructuredLoop &loop, TargetLevel target_level, analysis::AnalysisManager &analysis_manager)
size_t perfectly_nested_depth(structured_control_flow::StructuredLoop *loop)
symbolic::Expression get_target_level_idx(TargetLevel target_level)
GPUDimension
Shared GPU dimension enum for CUDA/ROCm targets Represents the X, Y, Z dimensions used for GPU kernel...
Definition gpu_types.h:10
symbolic::SymbolSet target_level_indvars(structured_control_flow::StructuredLoop &node, analysis::AnalysisManager &analysis_manager, TargetLevel target_level)
symbolic::Expression get_target_level_dim(TargetLevel target_level, int warp_size)
bool is_gpu_schedule(const structured_control_flow::ScheduleType &schedule)
Check if a schedule type is a GPU schedule (CUDA or ROCM).
bool nested_warp_dim(structured_control_flow::StructuredLoop &loop, analysis::AnalysisManager &analysis_manager)
std::vector< structured_control_flow::Map * > get_gpu_maps(structured_control_flow::Map &node, analysis::AnalysisManager &analysis_manager, GPUDimension dimension)
Get all GPU Map nodes in a given dimension (in tree traversal order).
void get_nested_level_maps(structured_control_flow::StructuredLoop &node, analysis::AnalysisManager &analysis_manager, std::unordered_map< TargetLevel, structured_control_flow::StructuredLoop * > &output)
int64_t gpu_warp_size< sdfg::rocm::ScheduleType_ROCM_Offload >()
Definition rocm_library_node_rewriter_pass.h:9
Definition analysis.h:7
Definition gpu_map_utils.h:158
structured_control_flow::Sequence * sequence
Definition gpu_map_utils.h:159
structured_control_flow::ControlFlowNode * before
Definition gpu_map_utils.h:160
Definition gpu_map_utils.h:163
bool unsafe
Definition gpu_map_utils.h:164
std::vector< FoldBarrier > barriers
Definition gpu_map_utils.h:165
Symbolic system for integer-based symbol analysis.