Skip to main content

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            self.unparse_tokens_mode(tokens, false);
39        }
40        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
41            push_opcode(tokens, "wmma");
42            push_directive(tokens, "store");
43            push_directive(tokens, "d");
44            push_directive(tokens, "sync");
45            push_directive(tokens, "aligned");
46            match &self.layout {
47                Layout::Row => {
48                    push_directive(tokens, "row");
49                }
50                Layout::Col => {
51                    push_directive(tokens, "col");
52                }
53            }
54            match &self.shape {
55                Shape::M16n16k16 => {
56                    push_directive(tokens, "m16n16k16");
57                }
58                Shape::M8n32k16 => {
59                    push_directive(tokens, "m8n32k16");
60                }
61                Shape::M32n8k16 => {
62                    push_directive(tokens, "m32n8k16");
63                }
64            }
65            if let Some(ss_0) = self.ss.as_ref() {
66                match ss_0 {
67                    Ss::SharedCta => {
68                        push_directive(tokens, "shared::cta");
69                    }
70                    Ss::Global => {
71                        push_directive(tokens, "global");
72                    }
73                    Ss::Shared => {
74                        push_directive(tokens, "shared");
75                    }
76                }
77            }
78            match &self.type_ {
79                Type::F16 => {
80                    push_directive(tokens, "f16");
81                }
82                Type::F32 => {
83                    push_directive(tokens, "f32");
84                }
85                Type::S32 => {
86                    push_directive(tokens, "s32");
87                }
88            }
89            if spaced {
90                tokens.push(PtxToken::Space);
91            }
92            self.p.unparse_tokens_mode(tokens, spaced);
93            tokens.push(PtxToken::Comma);
94            if spaced {
95                tokens.push(PtxToken::Space);
96            }
97            self.r.unparse_tokens_mode(tokens, spaced);
98            if self.stride.is_some() {
99                tokens.push(PtxToken::Comma);
100            }
101            if let Some(opt_1) = self.stride.as_ref() {
102                if spaced {
103                    tokens.push(PtxToken::Space);
104                }
105                opt_1.unparse_tokens_mode(tokens, spaced);
106            }
107            tokens.push(PtxToken::Semicolon);
108            if spaced {
109                tokens.push(PtxToken::Newline);
110            }
111        }
112    }
113}
114
115pub mod section_1 {
116    use super::*;
117    use crate::r#type::instruction::wmma_store::section_1::*;
118
119    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType1 {
120        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
121            self.unparse_tokens_mode(tokens, false);
122        }
123        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
124            push_opcode(tokens, "wmma");
125            push_directive(tokens, "store");
126            push_directive(tokens, "d");
127            push_directive(tokens, "sync");
128            push_directive(tokens, "aligned");
129            match &self.layout {
130                Layout::Row => {
131                    push_directive(tokens, "row");
132                }
133                Layout::Col => {
134                    push_directive(tokens, "col");
135                }
136            }
137            match &self.shape {
138                Shape::M8n8k128 => {
139                    push_directive(tokens, "m8n8k128");
140                }
141                Shape::M8n8k32 => {
142                    push_directive(tokens, "m8n8k32");
143                }
144            }
145            if let Some(ss_2) = self.ss.as_ref() {
146                match ss_2 {
147                    Ss::SharedCta => {
148                        push_directive(tokens, "shared::cta");
149                    }
150                    Ss::Global => {
151                        push_directive(tokens, "global");
152                    }
153                    Ss::Shared => {
154                        push_directive(tokens, "shared");
155                    }
156                }
157            }
158            match &self.type_ {
159                Type::S32 => {
160                    push_directive(tokens, "s32");
161                }
162            }
163            if spaced {
164                tokens.push(PtxToken::Space);
165            }
166            self.p.unparse_tokens_mode(tokens, spaced);
167            tokens.push(PtxToken::Comma);
168            if spaced {
169                tokens.push(PtxToken::Space);
170            }
171            self.r.unparse_tokens_mode(tokens, spaced);
172            if self.stride.is_some() {
173                tokens.push(PtxToken::Comma);
174            }
175            if let Some(opt_3) = self.stride.as_ref() {
176                if spaced {
177                    tokens.push(PtxToken::Space);
178                }
179                opt_3.unparse_tokens_mode(tokens, spaced);
180            }
181            tokens.push(PtxToken::Semicolon);
182            if spaced {
183                tokens.push(PtxToken::Newline);
184            }
185        }
186    }
187}
188
189pub mod section_2 {
190    use super::*;
191    use crate::r#type::instruction::wmma_store::section_2::*;
192
193    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType2 {
194        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
195            self.unparse_tokens_mode(tokens, false);
196        }
197        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
198            push_opcode(tokens, "wmma");
199            push_directive(tokens, "store");
200            push_directive(tokens, "d");
201            push_directive(tokens, "sync");
202            push_directive(tokens, "aligned");
203            match &self.layout {
204                Layout::Row => {
205                    push_directive(tokens, "row");
206                }
207                Layout::Col => {
208                    push_directive(tokens, "col");
209                }
210            }
211            match &self.shape {
212                Shape::M16n16k8 => {
213                    push_directive(tokens, "m16n16k8");
214                }
215            }
216            if let Some(ss_4) = self.ss.as_ref() {
217                match ss_4 {
218                    Ss::SharedCta => {
219                        push_directive(tokens, "shared::cta");
220                    }
221                    Ss::Global => {
222                        push_directive(tokens, "global");
223                    }
224                    Ss::Shared => {
225                        push_directive(tokens, "shared");
226                    }
227                }
228            }
229            match &self.type_ {
230                Type::F32 => {
231                    push_directive(tokens, "f32");
232                }
233            }
234            if spaced {
235                tokens.push(PtxToken::Space);
236            }
237            self.p.unparse_tokens_mode(tokens, spaced);
238            tokens.push(PtxToken::Comma);
239            if spaced {
240                tokens.push(PtxToken::Space);
241            }
242            self.r.unparse_tokens_mode(tokens, spaced);
243            if self.stride.is_some() {
244                tokens.push(PtxToken::Comma);
245            }
246            if let Some(opt_5) = self.stride.as_ref() {
247                if spaced {
248                    tokens.push(PtxToken::Space);
249                }
250                opt_5.unparse_tokens_mode(tokens, spaced);
251            }
252            tokens.push(PtxToken::Semicolon);
253            if spaced {
254                tokens.push(PtxToken::Newline);
255            }
256        }
257    }
258}
259
260pub mod section_3 {
261    use super::*;
262    use crate::r#type::instruction::wmma_store::section_3::*;
263
264    impl PtxUnparser for WmmaStoreDSyncAlignedLayoutShapeSsType3 {
265        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
266            self.unparse_tokens_mode(tokens, false);
267        }
268        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
269            push_opcode(tokens, "wmma");
270            push_directive(tokens, "store");
271            push_directive(tokens, "d");
272            push_directive(tokens, "sync");
273            push_directive(tokens, "aligned");
274            match &self.layout {
275                Layout::Row => {
276                    push_directive(tokens, "row");
277                }
278                Layout::Col => {
279                    push_directive(tokens, "col");
280                }
281            }
282            match &self.shape {
283                Shape::M8n8k4 => {
284                    push_directive(tokens, "m8n8k4");
285                }
286            }
287            if let Some(ss_6) = self.ss.as_ref() {
288                match ss_6 {
289                    Ss::SharedCta => {
290                        push_directive(tokens, "shared::cta");
291                    }
292                    Ss::Global => {
293                        push_directive(tokens, "global");
294                    }
295                    Ss::Shared => {
296                        push_directive(tokens, "shared");
297                    }
298                }
299            }
300            match &self.type_ {
301                Type::F64 => {
302                    push_directive(tokens, "f64");
303                }
304            }
305            if spaced {
306                tokens.push(PtxToken::Space);
307            }
308            self.p.unparse_tokens_mode(tokens, spaced);
309            tokens.push(PtxToken::Comma);
310            if spaced {
311                tokens.push(PtxToken::Space);
312            }
313            self.r.unparse_tokens_mode(tokens, spaced);
314            if self.stride.is_some() {
315                tokens.push(PtxToken::Comma);
316            }
317            if let Some(opt_7) = self.stride.as_ref() {
318                if spaced {
319                    tokens.push(PtxToken::Space);
320                }
321                opt_7.unparse_tokens_mode(tokens, spaced);
322            }
323            tokens.push(PtxToken::Semicolon);
324            if spaced {
325                tokens.push(PtxToken::Newline);
326            }
327        }
328    }
329}