ptx_parser/unparser/instruction/red.rs
1//! Original PTX specification:
2//!
3//! // Reduction operation with scalar type:
4//! red.op{.space}{.sem}{.scope}{.level::cache_hint}.type [a], b{, cache-policy};
5//! red.add{.space}{.sem}{.scope}.noftz{.level::cache_hint}.f16 [a], b{, cache-policy};
6//! red.add{.space}{.sem}{.scope}.noftz{.level::cache_hint}.f16x2 [a], b{, cache-policy};
7//! red.add{.space}{.sem}{.scope}.noftz{.level::cache_hint}.bf16 [a], b{, cache-policy};
8//! red.add{.space}{.sem}{.scope}.noftz{.level::cache_hint}.bf16x2 [a], b{, cache-policy};
9//! .space = { .global, .shared, .shared::cta, .shared::cluster};
10//! .sem = {.relaxed, .release};
11//! .scope = {.cta, .cluster, .gpu, .sys};
12//! .op = { .and, .or, .xor, .add, .inc, .dec, .min, .max };
13//! .level::cache_hint = { .L2::cache_hint };
14//! .type = { .b32, .b64, .u32, .u64, .s32, .s64, .f32, .f64 };
15//! ------------------------------------------------------------------
16//! // Reduction operation with vector type:
17//! red.add{.space}{.sem}{.scope}{.level::cache_hint}.vec_32_bit.f32 [a], b{, cache-policy};
18//! red.op{.space}{.sem}{.scope}.noftz{.level::cache_hint}. vec_16_bit.half_word_type [a], b{, cache-policy};
19//! red.op{.space}{.sem}{.scope}.noftz{.level::cache_hint}.vec_32_bit.packed_type [a], b {, cache-policy};
20//! .sem = { .relaxed, .release };
21//! .scope = { .cta, .cluster, .gpu, .sys };
22//! .op = { .add, .min, .max };
23//! .half_word_type = { .f16, .bf16 };
24//! .packed_type = { .f16x2,.bf16x2 };
25//! .vec_16_bit = { .v2, .v4, .v8 };
26//! .vec_32_bit = { .v2, .v4 };
27//! .level::cache_hint = { .L2::cache_hint };
28
29#![allow(unused)]
30
31use crate::lexer::PtxToken;
32use crate::unparser::{PtxUnparser, common::*};
33
34pub mod section_0 {
35 use super::*;
36 use crate::r#type::instruction::red::section_0::*;
37
38 impl PtxUnparser for RedOpSpaceSemScopeLevelCacheHintType {
39 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
40 push_opcode(tokens, "red");
41 match &self.op {
42 Op::And => {
43 push_directive(tokens, "and");
44 }
45 Op::Xor => {
46 push_directive(tokens, "xor");
47 }
48 Op::Add => {
49 push_directive(tokens, "add");
50 }
51 Op::Inc => {
52 push_directive(tokens, "inc");
53 }
54 Op::Dec => {
55 push_directive(tokens, "dec");
56 }
57 Op::Min => {
58 push_directive(tokens, "min");
59 }
60 Op::Max => {
61 push_directive(tokens, "max");
62 }
63 Op::Or => {
64 push_directive(tokens, "or");
65 }
66 }
67 if let Some(space_0) = self.space.as_ref() {
68 match space_0 {
69 Space::SharedCluster => {
70 push_directive(tokens, "shared::cluster");
71 }
72 Space::SharedCta => {
73 push_directive(tokens, "shared::cta");
74 }
75 Space::Global => {
76 push_directive(tokens, "global");
77 }
78 Space::Shared => {
79 push_directive(tokens, "shared");
80 }
81 }
82 }
83 if let Some(sem_1) = self.sem.as_ref() {
84 match sem_1 {
85 Sem::Relaxed => {
86 push_directive(tokens, "relaxed");
87 }
88 Sem::Release => {
89 push_directive(tokens, "release");
90 }
91 }
92 }
93 if let Some(scope_2) = self.scope.as_ref() {
94 match scope_2 {
95 Scope::Cluster => {
96 push_directive(tokens, "cluster");
97 }
98 Scope::Cta => {
99 push_directive(tokens, "cta");
100 }
101 Scope::Gpu => {
102 push_directive(tokens, "gpu");
103 }
104 Scope::Sys => {
105 push_directive(tokens, "sys");
106 }
107 }
108 }
109 if let Some(level_cache_hint_3) = self.level_cache_hint.as_ref() {
110 match level_cache_hint_3 {
111 LevelCacheHint::L2CacheHint => {
112 push_directive(tokens, "L2::cache_hint");
113 }
114 }
115 }
116 match &self.type_ {
117 Type::B32 => {
118 push_directive(tokens, "b32");
119 }
120 Type::B64 => {
121 push_directive(tokens, "b64");
122 }
123 Type::U32 => {
124 push_directive(tokens, "u32");
125 }
126 Type::U64 => {
127 push_directive(tokens, "u64");
128 }
129 Type::S32 => {
130 push_directive(tokens, "s32");
131 }
132 Type::S64 => {
133 push_directive(tokens, "s64");
134 }
135 Type::F32 => {
136 push_directive(tokens, "f32");
137 }
138 Type::F64 => {
139 push_directive(tokens, "f64");
140 }
141 }
142 self.a.unparse_tokens(tokens);
143 tokens.push(PtxToken::Comma);
144 self.b.unparse_tokens(tokens);
145 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
146 if let Some(opt_4) = self.cache_policy.as_ref() {
147 opt_4.unparse_tokens(tokens);
148 }
149 tokens.push(PtxToken::Semicolon);
150 }
151 }
152
153 impl PtxUnparser for RedAddSpaceSemScopeNoftzLevelCacheHintF16 {
154 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
155 push_opcode(tokens, "red");
156 push_directive(tokens, "add");
157 if let Some(space_5) = self.space.as_ref() {
158 match space_5 {
159 Space::SharedCluster => {
160 push_directive(tokens, "shared::cluster");
161 }
162 Space::SharedCta => {
163 push_directive(tokens, "shared::cta");
164 }
165 Space::Global => {
166 push_directive(tokens, "global");
167 }
168 Space::Shared => {
169 push_directive(tokens, "shared");
170 }
171 }
172 }
173 if let Some(sem_6) = self.sem.as_ref() {
174 match sem_6 {
175 Sem::Relaxed => {
176 push_directive(tokens, "relaxed");
177 }
178 Sem::Release => {
179 push_directive(tokens, "release");
180 }
181 }
182 }
183 if let Some(scope_7) = self.scope.as_ref() {
184 match scope_7 {
185 Scope::Cluster => {
186 push_directive(tokens, "cluster");
187 }
188 Scope::Cta => {
189 push_directive(tokens, "cta");
190 }
191 Scope::Gpu => {
192 push_directive(tokens, "gpu");
193 }
194 Scope::Sys => {
195 push_directive(tokens, "sys");
196 }
197 }
198 }
199 push_directive(tokens, "noftz");
200 if let Some(level_cache_hint_8) = self.level_cache_hint.as_ref() {
201 match level_cache_hint_8 {
202 LevelCacheHint::L2CacheHint => {
203 push_directive(tokens, "L2::cache_hint");
204 }
205 }
206 }
207 push_directive(tokens, "f16");
208 self.a.unparse_tokens(tokens);
209 tokens.push(PtxToken::Comma);
210 self.b.unparse_tokens(tokens);
211 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
212 if let Some(opt_9) = self.cache_policy.as_ref() {
213 opt_9.unparse_tokens(tokens);
214 }
215 tokens.push(PtxToken::Semicolon);
216 }
217 }
218
219 impl PtxUnparser for RedAddSpaceSemScopeNoftzLevelCacheHintF16x2 {
220 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
221 push_opcode(tokens, "red");
222 push_directive(tokens, "add");
223 if let Some(space_10) = self.space.as_ref() {
224 match space_10 {
225 Space::SharedCluster => {
226 push_directive(tokens, "shared::cluster");
227 }
228 Space::SharedCta => {
229 push_directive(tokens, "shared::cta");
230 }
231 Space::Global => {
232 push_directive(tokens, "global");
233 }
234 Space::Shared => {
235 push_directive(tokens, "shared");
236 }
237 }
238 }
239 if let Some(sem_11) = self.sem.as_ref() {
240 match sem_11 {
241 Sem::Relaxed => {
242 push_directive(tokens, "relaxed");
243 }
244 Sem::Release => {
245 push_directive(tokens, "release");
246 }
247 }
248 }
249 if let Some(scope_12) = self.scope.as_ref() {
250 match scope_12 {
251 Scope::Cluster => {
252 push_directive(tokens, "cluster");
253 }
254 Scope::Cta => {
255 push_directive(tokens, "cta");
256 }
257 Scope::Gpu => {
258 push_directive(tokens, "gpu");
259 }
260 Scope::Sys => {
261 push_directive(tokens, "sys");
262 }
263 }
264 }
265 push_directive(tokens, "noftz");
266 if let Some(level_cache_hint_13) = self.level_cache_hint.as_ref() {
267 match level_cache_hint_13 {
268 LevelCacheHint::L2CacheHint => {
269 push_directive(tokens, "L2::cache_hint");
270 }
271 }
272 }
273 push_directive(tokens, "f16x2");
274 self.a.unparse_tokens(tokens);
275 tokens.push(PtxToken::Comma);
276 self.b.unparse_tokens(tokens);
277 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
278 if let Some(opt_14) = self.cache_policy.as_ref() {
279 opt_14.unparse_tokens(tokens);
280 }
281 tokens.push(PtxToken::Semicolon);
282 }
283 }
284
285 impl PtxUnparser for RedAddSpaceSemScopeNoftzLevelCacheHintBf16 {
286 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
287 push_opcode(tokens, "red");
288 push_directive(tokens, "add");
289 if let Some(space_15) = self.space.as_ref() {
290 match space_15 {
291 Space::SharedCluster => {
292 push_directive(tokens, "shared::cluster");
293 }
294 Space::SharedCta => {
295 push_directive(tokens, "shared::cta");
296 }
297 Space::Global => {
298 push_directive(tokens, "global");
299 }
300 Space::Shared => {
301 push_directive(tokens, "shared");
302 }
303 }
304 }
305 if let Some(sem_16) = self.sem.as_ref() {
306 match sem_16 {
307 Sem::Relaxed => {
308 push_directive(tokens, "relaxed");
309 }
310 Sem::Release => {
311 push_directive(tokens, "release");
312 }
313 }
314 }
315 if let Some(scope_17) = self.scope.as_ref() {
316 match scope_17 {
317 Scope::Cluster => {
318 push_directive(tokens, "cluster");
319 }
320 Scope::Cta => {
321 push_directive(tokens, "cta");
322 }
323 Scope::Gpu => {
324 push_directive(tokens, "gpu");
325 }
326 Scope::Sys => {
327 push_directive(tokens, "sys");
328 }
329 }
330 }
331 push_directive(tokens, "noftz");
332 if let Some(level_cache_hint_18) = self.level_cache_hint.as_ref() {
333 match level_cache_hint_18 {
334 LevelCacheHint::L2CacheHint => {
335 push_directive(tokens, "L2::cache_hint");
336 }
337 }
338 }
339 push_directive(tokens, "bf16");
340 self.a.unparse_tokens(tokens);
341 tokens.push(PtxToken::Comma);
342 self.b.unparse_tokens(tokens);
343 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
344 if let Some(opt_19) = self.cache_policy.as_ref() {
345 opt_19.unparse_tokens(tokens);
346 }
347 tokens.push(PtxToken::Semicolon);
348 }
349 }
350
351 impl PtxUnparser for RedAddSpaceSemScopeNoftzLevelCacheHintBf16x2 {
352 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
353 push_opcode(tokens, "red");
354 push_directive(tokens, "add");
355 if let Some(space_20) = self.space.as_ref() {
356 match space_20 {
357 Space::SharedCluster => {
358 push_directive(tokens, "shared::cluster");
359 }
360 Space::SharedCta => {
361 push_directive(tokens, "shared::cta");
362 }
363 Space::Global => {
364 push_directive(tokens, "global");
365 }
366 Space::Shared => {
367 push_directive(tokens, "shared");
368 }
369 }
370 }
371 if let Some(sem_21) = self.sem.as_ref() {
372 match sem_21 {
373 Sem::Relaxed => {
374 push_directive(tokens, "relaxed");
375 }
376 Sem::Release => {
377 push_directive(tokens, "release");
378 }
379 }
380 }
381 if let Some(scope_22) = self.scope.as_ref() {
382 match scope_22 {
383 Scope::Cluster => {
384 push_directive(tokens, "cluster");
385 }
386 Scope::Cta => {
387 push_directive(tokens, "cta");
388 }
389 Scope::Gpu => {
390 push_directive(tokens, "gpu");
391 }
392 Scope::Sys => {
393 push_directive(tokens, "sys");
394 }
395 }
396 }
397 push_directive(tokens, "noftz");
398 if let Some(level_cache_hint_23) = self.level_cache_hint.as_ref() {
399 match level_cache_hint_23 {
400 LevelCacheHint::L2CacheHint => {
401 push_directive(tokens, "L2::cache_hint");
402 }
403 }
404 }
405 push_directive(tokens, "bf16x2");
406 self.a.unparse_tokens(tokens);
407 tokens.push(PtxToken::Comma);
408 self.b.unparse_tokens(tokens);
409 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
410 if let Some(opt_24) = self.cache_policy.as_ref() {
411 opt_24.unparse_tokens(tokens);
412 }
413 tokens.push(PtxToken::Semicolon);
414 }
415 }
416
417}
418
419pub mod section_1 {
420 use super::*;
421 use crate::r#type::instruction::red::section_1::*;
422
423 impl PtxUnparser for RedAddSpaceSemScopeLevelCacheHintVec32BitF32 {
424 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
425 push_opcode(tokens, "red");
426 push_directive(tokens, "add");
427 if let Some(space_25) = self.space.as_ref() {
428 match space_25 {
429 Space::SharedCluster => {
430 push_directive(tokens, "shared::cluster");
431 }
432 Space::SharedCta => {
433 push_directive(tokens, "shared::cta");
434 }
435 Space::Global => {
436 push_directive(tokens, "global");
437 }
438 Space::Shared => {
439 push_directive(tokens, "shared");
440 }
441 }
442 }
443 if let Some(sem_26) = self.sem.as_ref() {
444 match sem_26 {
445 Sem::Relaxed => {
446 push_directive(tokens, "relaxed");
447 }
448 Sem::Release => {
449 push_directive(tokens, "release");
450 }
451 }
452 }
453 if let Some(scope_27) = self.scope.as_ref() {
454 match scope_27 {
455 Scope::Cluster => {
456 push_directive(tokens, "cluster");
457 }
458 Scope::Cta => {
459 push_directive(tokens, "cta");
460 }
461 Scope::Gpu => {
462 push_directive(tokens, "gpu");
463 }
464 Scope::Sys => {
465 push_directive(tokens, "sys");
466 }
467 }
468 }
469 if let Some(level_cache_hint_28) = self.level_cache_hint.as_ref() {
470 match level_cache_hint_28 {
471 LevelCacheHint::L2CacheHint => {
472 push_directive(tokens, "L2::cache_hint");
473 }
474 }
475 }
476 match &self.vec_32_bit {
477 Vec32Bit::V2 => {
478 push_directive(tokens, "v2");
479 }
480 Vec32Bit::V4 => {
481 push_directive(tokens, "v4");
482 }
483 }
484 push_directive(tokens, "f32");
485 self.a.unparse_tokens(tokens);
486 tokens.push(PtxToken::Comma);
487 self.b.unparse_tokens(tokens);
488 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
489 if let Some(opt_29) = self.cache_policy.as_ref() {
490 opt_29.unparse_tokens(tokens);
491 }
492 tokens.push(PtxToken::Semicolon);
493 }
494 }
495
496 impl PtxUnparser for RedOpSpaceSemScopeNoftzLevelCacheHintVec16BitHalfWordType {
497 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
498 push_opcode(tokens, "red");
499 match &self.op {
500 Op::Add => {
501 push_directive(tokens, "add");
502 }
503 Op::Min => {
504 push_directive(tokens, "min");
505 }
506 Op::Max => {
507 push_directive(tokens, "max");
508 }
509 }
510 if let Some(space_30) = self.space.as_ref() {
511 match space_30 {
512 Space::SharedCluster => {
513 push_directive(tokens, "shared::cluster");
514 }
515 Space::SharedCta => {
516 push_directive(tokens, "shared::cta");
517 }
518 Space::Global => {
519 push_directive(tokens, "global");
520 }
521 Space::Shared => {
522 push_directive(tokens, "shared");
523 }
524 }
525 }
526 if let Some(sem_31) = self.sem.as_ref() {
527 match sem_31 {
528 Sem::Relaxed => {
529 push_directive(tokens, "relaxed");
530 }
531 Sem::Release => {
532 push_directive(tokens, "release");
533 }
534 }
535 }
536 if let Some(scope_32) = self.scope.as_ref() {
537 match scope_32 {
538 Scope::Cluster => {
539 push_directive(tokens, "cluster");
540 }
541 Scope::Cta => {
542 push_directive(tokens, "cta");
543 }
544 Scope::Gpu => {
545 push_directive(tokens, "gpu");
546 }
547 Scope::Sys => {
548 push_directive(tokens, "sys");
549 }
550 }
551 }
552 push_directive(tokens, "noftz");
553 if let Some(level_cache_hint_33) = self.level_cache_hint.as_ref() {
554 match level_cache_hint_33 {
555 LevelCacheHint::L2CacheHint => {
556 push_directive(tokens, "L2::cache_hint");
557 }
558 }
559 }
560 match &self.vec_16_bit {
561 Vec16Bit::V2 => {
562 push_directive(tokens, "v2");
563 }
564 Vec16Bit::V4 => {
565 push_directive(tokens, "v4");
566 }
567 Vec16Bit::V8 => {
568 push_directive(tokens, "v8");
569 }
570 }
571 match &self.half_word_type {
572 HalfWordType::Bf16 => {
573 push_directive(tokens, "bf16");
574 }
575 HalfWordType::F16 => {
576 push_directive(tokens, "f16");
577 }
578 }
579 self.a.unparse_tokens(tokens);
580 tokens.push(PtxToken::Comma);
581 self.b.unparse_tokens(tokens);
582 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
583 if let Some(opt_34) = self.cache_policy.as_ref() {
584 opt_34.unparse_tokens(tokens);
585 }
586 tokens.push(PtxToken::Semicolon);
587 }
588 }
589
590 impl PtxUnparser for RedOpSpaceSemScopeNoftzLevelCacheHintVec32BitPackedType {
591 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
592 push_opcode(tokens, "red");
593 match &self.op {
594 Op::Add => {
595 push_directive(tokens, "add");
596 }
597 Op::Min => {
598 push_directive(tokens, "min");
599 }
600 Op::Max => {
601 push_directive(tokens, "max");
602 }
603 }
604 if let Some(space_35) = self.space.as_ref() {
605 match space_35 {
606 Space::SharedCluster => {
607 push_directive(tokens, "shared::cluster");
608 }
609 Space::SharedCta => {
610 push_directive(tokens, "shared::cta");
611 }
612 Space::Global => {
613 push_directive(tokens, "global");
614 }
615 Space::Shared => {
616 push_directive(tokens, "shared");
617 }
618 }
619 }
620 if let Some(sem_36) = self.sem.as_ref() {
621 match sem_36 {
622 Sem::Relaxed => {
623 push_directive(tokens, "relaxed");
624 }
625 Sem::Release => {
626 push_directive(tokens, "release");
627 }
628 }
629 }
630 if let Some(scope_37) = self.scope.as_ref() {
631 match scope_37 {
632 Scope::Cluster => {
633 push_directive(tokens, "cluster");
634 }
635 Scope::Cta => {
636 push_directive(tokens, "cta");
637 }
638 Scope::Gpu => {
639 push_directive(tokens, "gpu");
640 }
641 Scope::Sys => {
642 push_directive(tokens, "sys");
643 }
644 }
645 }
646 push_directive(tokens, "noftz");
647 if let Some(level_cache_hint_38) = self.level_cache_hint.as_ref() {
648 match level_cache_hint_38 {
649 LevelCacheHint::L2CacheHint => {
650 push_directive(tokens, "L2::cache_hint");
651 }
652 }
653 }
654 match &self.vec_32_bit {
655 Vec32Bit::V2 => {
656 push_directive(tokens, "v2");
657 }
658 Vec32Bit::V4 => {
659 push_directive(tokens, "v4");
660 }
661 }
662 match &self.packed_type {
663 PackedType::Bf16x2 => {
664 push_directive(tokens, "bf16x2");
665 }
666 PackedType::F16x2 => {
667 push_directive(tokens, "f16x2");
668 }
669 }
670 self.a.unparse_tokens(tokens);
671 tokens.push(PtxToken::Comma);
672 self.b.unparse_tokens(tokens);
673 if self.cache_policy.is_some() { tokens.push(PtxToken::Comma); }
674 if let Some(opt_39) = self.cache_policy.as_ref() {
675 opt_39.unparse_tokens(tokens);
676 }
677 tokens.push(PtxToken::Semicolon);
678 }
679 }
680
681}
682