ptx_parser/unparser/instruction/
wmma_store.rs

1//! Original PTX specification:
2//!
3//! wmma.store.d.sync.aligned.layout.shape{.ss}.type [p], r {, stride};
4//! .layout = {.row, .col};
5//! .shape  = {.m16n16k16, .m8n32k16, .m32n8k16};
6//! .ss     = {.global, .shared, .shared::cta};
7//! .type   = {.f16, .f32, .s32};
8//! ----------------------------------------------------------------
9//! wmma.store.d.sync.aligned.layout.shape{.ss}.type [p], r {, stride};
10//! .layout = {.row, .col};
11//! .shape  = {.m8n8k32, .m8n8k128};
12//! .ss     = {.global, .shared, .shared::cta};
13//! .type   = {.s32};
14//! ----------------------------------------------------------------
15//! wmma.store.d.sync.aligned.layout.shape{.ss}.type [p], r {, stride};
16//! .layout = {.row, .col};
17//! .shape  = {.m16n16k8};
18//! .ss     = {.global, .shared, .shared::cta};
19//! .type   = {.f32};
20//! ----------------------------------------------------------------
21//! wmma.store.d.sync.aligned.layout.shape{.ss}.type [p], r {, stride};
22//! .layout = {.row, .col};
23//! .shape  = {.m8n8k4 };
24//! .ss     = {.global, .shared, .shared::cta};
25//! .type   = {.f64};
26
27#![allow(unused)]
28
29use crate::lexer::PtxToken;
30use crate::unparser::{PtxUnparser, common::*};
31
32pub mod section_0 {
33    use super::*;
34    use crate::r#type::instruction::wmma_store::section_0::*;
35
36    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType {
37        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
38            push_opcode(tokens, "wmma");
39            push_directive(tokens, "store");
40            push_directive(tokens, "d");
41            push_directive(tokens, "sync");
42            push_directive(tokens, "aligned");
43            match &self.layout {
44                Layout::Row => {
45                    push_directive(tokens, "row");
46                }
47                Layout::Col => {
48                    push_directive(tokens, "col");
49                }
50            }
51            match &self.shape {
52                Shape::M16n16k16 => {
53                    push_directive(tokens, "m16n16k16");
54                }
55                Shape::M8n32k16 => {
56                    push_directive(tokens, "m8n32k16");
57                }
58                Shape::M32n8k16 => {
59                    push_directive(tokens, "m32n8k16");
60                }
61            }
62            if let Some(ss_0) = self.ss.as_ref() {
63                match ss_0 {
64                    Ss::SharedCta => {
65                        push_directive(tokens, "shared::cta");
66                    }
67                    Ss::Global => {
68                        push_directive(tokens, "global");
69                    }
70                    Ss::Shared => {
71                        push_directive(tokens, "shared");
72                    }
73                }
74            }
75            match &self.type_ {
76                Type::F16 => {
77                    push_directive(tokens, "f16");
78                }
79                Type::F32 => {
80                    push_directive(tokens, "f32");
81                }
82                Type::S32 => {
83                    push_directive(tokens, "s32");
84                }
85            }
86            self.p.unparse_tokens(tokens);
87            tokens.push(PtxToken::Comma);
88            self.r.unparse_tokens(tokens);
89            if self.stride.is_some() {
90                tokens.push(PtxToken::Comma);
91            }
92            if let Some(opt_1) = self.stride.as_ref() {
93                opt_1.unparse_tokens(tokens);
94            }
95            tokens.push(PtxToken::Semicolon);
96        }
97    }
98}
99
100pub mod section_1 {
101    use super::*;
102    use crate::r#type::instruction::wmma_store::section_1::*;
103
104    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType1 {
105        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
106            push_opcode(tokens, "wmma");
107            push_directive(tokens, "store");
108            push_directive(tokens, "d");
109            push_directive(tokens, "sync");
110            push_directive(tokens, "aligned");
111            match &self.layout {
112                Layout::Row => {
113                    push_directive(tokens, "row");
114                }
115                Layout::Col => {
116                    push_directive(tokens, "col");
117                }
118            }
119            match &self.shape {
120                Shape::M8n8k128 => {
121                    push_directive(tokens, "m8n8k128");
122                }
123                Shape::M8n8k32 => {
124                    push_directive(tokens, "m8n8k32");
125                }
126            }
127            if let Some(ss_2) = self.ss.as_ref() {
128                match ss_2 {
129                    Ss::SharedCta => {
130                        push_directive(tokens, "shared::cta");
131                    }
132                    Ss::Global => {
133                        push_directive(tokens, "global");
134                    }
135                    Ss::Shared => {
136                        push_directive(tokens, "shared");
137                    }
138                }
139            }
140            match &self.type_ {
141                Type::S32 => {
142                    push_directive(tokens, "s32");
143                }
144            }
145            self.p.unparse_tokens(tokens);
146            tokens.push(PtxToken::Comma);
147            self.r.unparse_tokens(tokens);
148            if self.stride.is_some() {
149                tokens.push(PtxToken::Comma);
150            }
151            if let Some(opt_3) = self.stride.as_ref() {
152                opt_3.unparse_tokens(tokens);
153            }
154            tokens.push(PtxToken::Semicolon);
155        }
156    }
157}
158
159pub mod section_2 {
160    use super::*;
161    use crate::r#type::instruction::wmma_store::section_2::*;
162
163    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType2 {
164        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
165            push_opcode(tokens, "wmma");
166            push_directive(tokens, "store");
167            push_directive(tokens, "d");
168            push_directive(tokens, "sync");
169            push_directive(tokens, "aligned");
170            match &self.layout {
171                Layout::Row => {
172                    push_directive(tokens, "row");
173                }
174                Layout::Col => {
175                    push_directive(tokens, "col");
176                }
177            }
178            match &self.shape {
179                Shape::M16n16k8 => {
180                    push_directive(tokens, "m16n16k8");
181                }
182            }
183            if let Some(ss_4) = self.ss.as_ref() {
184                match ss_4 {
185                    Ss::SharedCta => {
186                        push_directive(tokens, "shared::cta");
187                    }
188                    Ss::Global => {
189                        push_directive(tokens, "global");
190                    }
191                    Ss::Shared => {
192                        push_directive(tokens, "shared");
193                    }
194                }
195            }
196            match &self.type_ {
197                Type::F32 => {
198                    push_directive(tokens, "f32");
199                }
200            }
201            self.p.unparse_tokens(tokens);
202            tokens.push(PtxToken::Comma);
203            self.r.unparse_tokens(tokens);
204            if self.stride.is_some() {
205                tokens.push(PtxToken::Comma);
206            }
207            if let Some(opt_5) = self.stride.as_ref() {
208                opt_5.unparse_tokens(tokens);
209            }
210            tokens.push(PtxToken::Semicolon);
211        }
212    }
213}
214
215pub mod section_3 {
216    use super::*;
217    use crate::r#type::instruction::wmma_store::section_3::*;
218
219    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType3 {
220        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
221            push_opcode(tokens, "wmma");
222            push_directive(tokens, "store");
223            push_directive(tokens, "d");
224            push_directive(tokens, "sync");
225            push_directive(tokens, "aligned");
226            match &self.layout {
227                Layout::Row => {
228                    push_directive(tokens, "row");
229                }
230                Layout::Col => {
231                    push_directive(tokens, "col");
232                }
233            }
234            match &self.shape {
235                Shape::M8n8k4 => {
236                    push_directive(tokens, "m8n8k4");
237                }
238            }
239            if let Some(ss_6) = self.ss.as_ref() {
240                match ss_6 {
241                    Ss::SharedCta => {
242                        push_directive(tokens, "shared::cta");
243                    }
244                    Ss::Global => {
245                        push_directive(tokens, "global");
246                    }
247                    Ss::Shared => {
248                        push_directive(tokens, "shared");
249                    }
250                }
251            }
252            match &self.type_ {
253                Type::F64 => {
254                    push_directive(tokens, "f64");
255                }
256            }
257            self.p.unparse_tokens(tokens);
258            tokens.push(PtxToken::Comma);
259            self.r.unparse_tokens(tokens);
260            if self.stride.is_some() {
261                tokens.push(PtxToken::Comma);
262            }
263            if let Some(opt_7) = self.stride.as_ref() {
264                opt_7.unparse_tokens(tokens);
265            }
266            tokens.push(PtxToken::Semicolon);
267        }
268    }
269}