docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
gpu_mma_expander.h
Go to the documentation of this file.
1#pragma once
2
4
9
10namespace sdfg::gpu {
11
12class GpuMmaExpander : public passes::CodeLibNodeExpander<math::tensor::MatMulNode> {
13protected:
14 const GpuArch* arch_;
16 const BlockCounts* wave_tile_hint_ = nullptr;
17
18public:
20 const GpuArch* arch, const MmaBlockSize* block_size_hint = nullptr, const BlockCounts* wave_tile_hint = nullptr
21 )
22 : arch_(arch), CodeLibNodeExpander(math::tensor::LibraryNodeType_MatMul), block_size_hint_(block_size_hint),
23 wave_tile_hint_(wave_tile_hint) {
24 }
25
26 virtual ~GpuMmaExpander() = default;
27 const LibNodeExpander* for_lib_node(const data_flow::LibraryNode& node) const override;
28
31 types::PrimitiveType input_type,
32 const data_flow::ImplementationType& impl_type,
33 const DebugInfo& org_debug_info,
35 std::string frag_name,
36 const MmaBlockSize& mma_block_size,
37 MmaFragmentType frag_type,
38 const GpuMmaFromMemoryLayout& from_memory,
39 unsigned input_index,
40 const char* operand_label,
41 Block& block
42 );
43
46 types::PrimitiveType output_type,
47 const data_flow::ImplementationType& impl_type,
48 const DebugInfo& org_debug_info,
50 std::string frag_name,
51 const MmaBlockSize& mma_block_size,
52 MmaFragmentType frag_type,
53 const GpuMmaFromMemoryLayout& to_memory,
54 unsigned input_index,
55 const char* operand_label,
56 Block& block
57 );
58
59 LibNodeExpander::ExpandOutcome handle_expand(
60 LibNodeExpander::ExpandContext& context, structured_control_flow::Block& block, math::tensor::MatMulNode& node
61 ) const override;
62
64 AccessNodeExpand& standalone,
65 const MmaBlockSize& mma_block_size,
66 types::PrimitiveType acc_type,
67 types::PrimitiveType output_type,
68 const data_flow::ImplementationType& impl_type,
69 const DebugInfo& debug_info,
71 const std::string& c_frag_name,
72 const std::string& acc_frag_name,
73 const std::string& store_frag_name,
74 Block& block
75 );
76
78 LibNodeExpander::AccessNodeExpand& standalone,
79 const GpuArch& arch,
80 GpuMmaTiling& mma_tiling,
81 const math::tensor::TensorLayout& layout_a,
82 const math::tensor::TensorLayout& layout_b,
83 const math::tensor::TensorLayout& layout_y,
84 types::PrimitiveType input_type,
85 types::PrimitiveType output_type,
86 bool include_c_add, // Y += A @ B with the loaded Y, rather than overwriting Y = A @ B
87 const DebugInfo& org_debug_info,
88 const std::array<int, 3>& args_order, // indices of inputs in order of {y, a, b}
89 // The layouts carry exact (possibly symbolic) extents not covered exactly by the tiling: clip the
90 // fragments crossing them. The K-block loop is padded to a multiple of k_block_multiple.
91 // The K-block loop is a sequential Reduce{Add} over the accumulator fragments.
92 bool ragged = false,
93 int k_block_multiple = 1
94 );
95
97 LibNodeExpander::AccessNodeExpand& standalone,
98 const GpuArch& arch,
99 GpuMmaTiling& mma_tiling,
100 types::PrimitiveType input_type,
101 const std::string& frag_a,
102 const std::string& frag_b,
103 const std::string& frag_acc,
104 const data_flow::ImplementationType& impl_type,
105 const DebugInfo& org_debug_info,
108 );
109
110protected:
112};
113
114} // namespace sdfg::gpu
Definition element.h:30
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
Base class for all library nodes in the dataflow graph.
Definition library_node.h:106
Definition gpu_arch.h:14
static void create_eltwise_add_block(AccessNodeExpand &standalone, const MmaBlockSize &mma_block_size, types::PrimitiveType acc_type, types::PrimitiveType output_type, const data_flow::ImplementationType &impl_type, const DebugInfo &debug_info, builder::StructuredSDFGBuilder &builder, const std::string &c_frag_name, const std::string &acc_frag_name, const std::string &store_frag_name, Block &block)
GpuMmaExpander(const GpuArch *arch, const MmaBlockSize *block_size_hint=nullptr, const BlockCounts *wave_tile_hint=nullptr)
Definition gpu_mma_expander.h:19
static void create_fragment_load(passes::LibNodeExpander::AccessNodeExpand &standalone, types::PrimitiveType input_type, const data_flow::ImplementationType &impl_type, const DebugInfo &org_debug_info, builder::StructuredSDFGBuilder &builder, std::string frag_name, const MmaBlockSize &mma_block_size, MmaFragmentType frag_type, const GpuMmaFromMemoryLayout &from_memory, unsigned input_index, const char *operand_label, Block &block)
static void create_fragment_store(passes::LibNodeExpander::AccessNodeExpand &standalone, types::PrimitiveType output_type, const data_flow::ImplementationType &impl_type, const DebugInfo &org_debug_info, builder::StructuredSDFGBuilder &builder, std::string frag_name, const MmaBlockSize &mma_block_size, MmaFragmentType frag_type, const GpuMmaFromMemoryLayout &to_memory, unsigned input_index, const char *operand_label, Block &block)
virtual ~GpuMmaExpander()=default
static passes::LibNodeExpander::ExpandOutcome expand_mma_standalone(LibNodeExpander::AccessNodeExpand &standalone, const GpuArch &arch, GpuMmaTiling &mma_tiling, const math::tensor::TensorLayout &layout_a, const math::tensor::TensorLayout &layout_b, const math::tensor::TensorLayout &layout_y, types::PrimitiveType input_type, types::PrimitiveType output_type, bool include_c_add, const DebugInfo &org_debug_info, const std::array< int, 3 > &args_order, bool ragged=false, int k_block_multiple=1)
const GpuArch * arch_
Definition gpu_mma_expander.h:14
virtual bool matches_possible_mma_pattern(const math::tensor::MatMulNode &node) const
static void create_fragment_mma(LibNodeExpander::AccessNodeExpand &standalone, const GpuArch &arch, GpuMmaTiling &mma_tiling, types::PrimitiveType input_type, const std::string &frag_a, const std::string &frag_b, const std::string &frag_acc, const data_flow::ImplementationType &impl_type, const DebugInfo &org_debug_info, builder::StructuredSDFGBuilder &builder, structured_control_flow::Block &block)
const BlockCounts * wave_tile_hint_
Definition gpu_mma_expander.h:16
const LibNodeExpander * for_lib_node(const data_flow::LibraryNode &node) const override
Prefiltering of libnodes.
const MmaBlockSize * block_size_hint_
Definition gpu_mma_expander.h:15
LibNodeExpander::ExpandOutcome handle_expand(LibNodeExpander::ExpandContext &context, structured_control_flow::Block &block, math::tensor::MatMulNode &node) const override
Tensor matrix multiplication following ONNX MatMul operator specification.
Definition matmul_node.h:84
The metadata associated with a addressing a tensor in elements Meant to be used with TensorNodes to d...
Definition tensor_layout.h:20
Definition lib_node_expander.h:191
CodeLibNodeExpander(const data_flow::LibraryNodeCode &code)
Definition lib_node_expander.h:195
Definition lib_node_expander.h:45
A control flow node representing a basic block with dataflow computations.
Definition block.h:42
Tensor matrix multiplication node compatible with ONNX MatMul operator.
Definition function_builder.h:10
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
Definition cuda_arch.h:11
MmaFragmentType
Definition gpu_mma_fragment.h:14
Definition batched_gemm_node.h:12
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Grouping of MMA blocks.
Definition gpu_mma_fragment.h:35
Describes how a single MMA fragment maps to memory relative to a base pointer.
Definition gpu_mma_fragment.h:163
Definition gpu_mma_fragment.h:44
Definition gpu_mma_fragment.h:16
Definition lib_node_expander.h:12
Symbolic system for integer-based symbol analysis.