docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
gpu_mma_einsum_transform.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace sdfg::gpu {
9
11 const GpuArch* arch_;
12 const BlockCounts* wave_tile_hint_ = nullptr;
13 const MmaBlockSize* block_size_hint_ = nullptr;
14 int k_block_multiple_ = 1;
15
16public:
18 const GpuArch* arch,
19 const MmaBlockSize* block_size_hint = nullptr,
20 const BlockCounts* wave_tile_hint = nullptr,
21 int k_block_multiple = 1
22 );
23
30
31 bool analyze(const einsum::EinsumCluster& cluster, EinsumMmaAnalysis& result) const;
32
34 replace(einsum::EinsumReplacementContext& context, const einsum::EinsumCluster& cluster) const override;
35
36 bool can_be_applied(const einsum::EinsumCluster& cluster) const override;
37
38protected:
40
42 std::optional<GpuMmaTiling> select_tiling(EinsumMmaAnalysis& analysis) const;
43};
44
46 bool matched_ = false;
47 StructuredLoop& outermost_mma_loop_;
48 const gpu::GpuArch* arch_;
49
50 std::optional<MmaBlockSize> block_size_hint_;
51 std::optional<BlockCounts> wave_tiling_hint_;
54 int k_block_multiple_ = 1;
55
56protected:
60 builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager, bool verify_only
61 );
62
63public:
65 StructuredLoop& outermoost_mma_loop,
66 const gpu::GpuArch* arch = nullptr,
67 const MmaBlockSize* block_size_hint = nullptr,
68 const BlockCounts* wave_tiling_hint = nullptr,
69 int k_block_multiple = 1
70 );
71
77 StructuredLoop& outermoost_mma_loop,
78 const gpu::GpuArch* arch,
79 std::optional<MmaBlockSize> block_size_hint,
80 std::optional<BlockCounts> wave_tile_hint,
81 int k_block_multiple = 1
82 );
83
84 std::string name() const override {
85 return "GpuMmaEinsumTransform";
86 }
87
91
92 void to_json(nlohmann::json& j) const override;
93
95
96 bool matched() const {
97 return matched_;
98 }
99};
100
101} // namespace sdfg::gpu
Definition analysis.h:53
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
Proof-of-concept replacer that turns a matmul-shaped EinsumCluster into a MatMulNode.
Definition einsum2matmul.h:25
Non-destructive counterpart of an EinsumNode.
Definition einsum_detection.h:150
ExpandContext for replacing an EinsumCluster with a new implementation.
Definition einsum_replacer.h:32
Definition gpu_arch.h:14
bool can_be_applied(const einsum::EinsumCluster &cluster) const override
Checks whether this replacer could be applied to the given cluster.
einsum::ReplaceOutcome replace(einsum::EinsumReplacementContext &context, const einsum::EinsumCluster &cluster) const override
GpuMmaEinsumReplacer(const GpuArch *arch, const MmaBlockSize *block_size_hint=nullptr, const BlockCounts *wave_tile_hint=nullptr, int k_block_multiple=1)
bool analyze(const einsum::EinsumCluster &cluster, EinsumMmaAnalysis &result) const
std::optional< GpuMmaTiling > select_tiling(EinsumMmaAnalysis &analysis) const
The MMA tiling for analysis: exact if the extents divide, else (if the target supports it) ragged.
bool matches_possible_mma_pattern(EinsumMmaAnalysis &analysis) const
bool matched() const
Definition gpu_mma_einsum_transform.h:96
GpuMmaEinsumTransform(StructuredLoop &outermoost_mma_loop, const gpu::GpuArch *arch, std::optional< MmaBlockSize > block_size_hint, std::optional< BlockCounts > wave_tile_hint, int k_block_multiple=1)
Owning overload: takes the hints by value and stores them internally, so the caller does not have to ...
bool can_be_applied(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Check if this transformation can be safely applied.
void to_json(nlohmann::json &j) const override
Serialize this transformation to JSON.
bool try_apply(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Attempt to apply the transformation if possible.
GpuMmaEinsumTransform(StructuredLoop &outermoost_mma_loop, const gpu::GpuArch *arch=nullptr, const MmaBlockSize *block_size_hint=nullptr, const BlockCounts *wave_tiling_hint=nullptr, int k_block_multiple=1)
static GpuMmaEinsumTransform from_json(builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)
std::string name() const override
Get the name of this transformation.
Definition gpu_mma_einsum_transform.h:84
void apply(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
Apply this transformation to the SDFG.
bool run_internal(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager, bool verify_only)
the einsum parts modify the SDFG in place, so WILL ALWAYS CHANGE IT.
Base class for structured loop constructs.
Definition structured_loop.h:244
Base class for all SDFG transformations.
Definition transformation.h:25
Definition analysis.h:8
Definition function_builder.h:10
passes::LibNodeExpander::ExpandOutcome ReplaceOutcome
Definition einsum_replacer.h:18
Definition cuda_arch.h:11
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Results of the applicability analysis that are reused by the replacement step.
Definition einsum2matmul.h:51
Grouping of MMA blocks.
Definition gpu_mma_fragment.h:35
Definition gpu_mma_einsum_transform.h:24
types::PrimitiveType acc_type
Definition gpu_mma_einsum_transform.h:25
bool ragged
Some extent is not a constant multiple of the MMA block: the tiling covers the padded extents and the...
Definition gpu_mma_einsum_transform.h:28
Definition gpu_mma_fragment.h:16