docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
rocm_mma_bare_dispatcher.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace sdfg::gpu::rocm {
6
8
15public:
16 void emit_fill(codegen::CodegenOutput& out, const std::string& acc_frag, types::PrimitiveType fill_type) const override;
17
20 const std::string& frag_d,
21 const std::string& frag_a,
22 const std::string& frag_b,
23 const std::string& frag_c
24 ) const override;
25
28 const std::string& frag,
29 const std::string& base,
30 const GpuMmaFromMemoryLayout& layout,
31 MmaFragmentType frag_type,
32 types::PrimitiveType element_type,
33 MmaFragmentLayout fragment_layout
34 ) const override;
35
38 const std::string& frag,
39 const std::string& base,
40 const GpuMmaFromMemoryLayout& layout,
41 MmaFragmentType frag_type,
42 types::PrimitiveType element_type
43 ) const override;
44
47 const std::string& main_frag,
48 const std::vector<std::string>& additional_frags,
49 const EltwiseCompute& compute
50 ) const override;
51
52 std::string fragment_element(const std::string& frag, const std::string& idx) const override {
53 return frag + "[" + idx + "]";
54 }
55
56 std::string fragment_element_count(const std::string& frag) const override {
57 return "static_cast<int>(sizeof(" + frag + ") / sizeof(" + frag + "[0]))";
58 }
59
61 std::optional<std::pair<std::string, std::string>> fragment_element_coords(
62 MmaFragmentType frag_type, const MmaBlockSize& block_size, const std::string& idx, std::string& condition
63 ) const override {
64 const std::string lane = "(threadIdx.x % 64)";
65 const std::string lo = "(" + lane + " % 32)";
66 const std::string kq = "(4 * (" + lane + " / 32) + " + idx + ")";
67 condition.clear();
68 switch (frag_type) {
70 return std::make_pair(lo, kq);
72 return std::make_pair(kq, lo);
73 default:
74 return std::make_pair("(8 * (" + idx + " / 4) + 4 * (" + lane + " / 32) + " + idx + " % 4)", lo);
75 }
76 }
77
78private:
80 void emit_fragment_transfer(
82 bool load,
83 MmaFragmentType type,
84 const GpuMmaFromMemoryLayout& layout,
85 types::PrimitiveType element_type,
86 const std::string& frag,
87 const std::string& base
88 ) const;
89};
90
91} // namespace sdfg::gpu::rocm
Hardware-dependent emit primitives for the composable MMA library nodes.
Definition gpu_mma_dispatcher.h:23
std::function< void( codegen::CodegenOutput &out, const std::string &main_frag_elem, const std::string &idx, const std::vector< std::string > &other_frag_elems)> EltwiseCompute
Per-element callback used by emit_eltwise: writes one output element from its inputs.
Definition gpu_mma_dispatcher.h:26
Raw v_mfma_f32_32x32x8f16 emit strategy (see RocmMfma32Support).
Definition rocm_mma_bare_dispatcher.h:14
std::string fragment_element_count(const std::string &frag) const override
Number of elements of this lane's share of frag (needed for clipped transfers).
Definition rocm_mma_bare_dispatcher.h:56
std::optional< std::pair< std::string, std::string > > fragment_element_coords(MmaFragmentType frag_type, const MmaBlockSize &block_size, const std::string &idx, std::string &condition) const override
The raw MFMA register layouts documented above.
Definition rocm_mma_bare_dispatcher.h:61
void emit_mma(codegen::CodegenOutput &out, const std::string &frag_d, const std::string &frag_a, const std::string &frag_b, const std::string &frag_c) const override
frag_d = frag_a * frag_b + frag_c (single MMA step; all operands are fragments).
void emit_fragment_store(codegen::CodegenOutput &out, const std::string &frag, const std::string &base, const GpuMmaFromMemoryLayout &layout, MmaFragmentType frag_type, types::PrimitiveType element_type) const override
Store the fragment behind frag to memory (base + layout).
void emit_eltwise(codegen::CodegenOutput &out, const std::string &main_frag, const std::vector< std::string > &additional_frags, const EltwiseCompute &compute) const override
Element-wise loop over main_frag, invoking compute for each element.
void emit_fragment_load(codegen::CodegenOutput &out, const std::string &frag, const std::string &base, const GpuMmaFromMemoryLayout &layout, MmaFragmentType frag_type, types::PrimitiveType element_type, MmaFragmentLayout fragment_layout) const override
Load a tile from memory (base + layout) into the fragment behind frag.
std::string fragment_element(const std::string &frag, const std::string &idx) const override
Expression for element idx of this lane's share of frag (needed for clipped transfers).
Definition rocm_mma_bare_dispatcher.h:52
void emit_fill(codegen::CodegenOutput &out, const std::string &acc_frag, types::PrimitiveType fill_type) const override
Zero-initialize the accumulator fragment behind acc_frag.
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
Definition rocm_arch.h:11
data_flow::ImplementationType ImplementationType_ROCM_MMA_BARE("ROCM_MMA_BARE")
MmaFragmentLayout
Definition gpu_mma_fragment.h:78
MmaFragmentType
Definition gpu_mma_fragment.h:14
@ A
Definition gpu_mma_fragment.h:14
@ B
Definition gpu_mma_fragment.h:14
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Definition block_dispatcher.h:108
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:16