Skip to main content

ptx_parser/unparser/instruction/
cp_async_bulk_prefetch_tensor.rs

1//! Original PTX specification:
2//!
3//! // global -> shared::cluster:
4//! cp.async.bulk.prefetch.tensor.dim.L2.src{.load_mode}{.level::cache_hint} [tensorMap, tensorCoords] {, im2colInfo } {, cache-policy};
5//! .src =                { .global };
6//! .dim =                { .1d, .2d, .3d, .4d, .5d };
7//! .load_mode =          { .tile, .tile::gather4, .im2col, .im2col::w, .im2col::w::128 };
8//! .level::cache_hint =  { .L2::cache_hint };
9
10#![allow(unused)]
11
12use crate::lexer::PtxToken;
13use crate::unparser::{PtxUnparser, common::*};
14
15pub mod section_0 {
16    use super::*;
17    use crate::r#type::instruction::cp_async_bulk_prefetch_tensor::section_0::*;
18
19    impl PtxUnparser for CpAsyncBulkPrefetchTensorDimL2SrcLoadModeLevelCacheHint {
20        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
21            self.unparse_tokens_mode(tokens, false);
22        }
23        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
24            push_opcode(tokens, "cp");
25            push_directive(tokens, "async");
26            push_directive(tokens, "bulk");
27            push_directive(tokens, "prefetch");
28            push_directive(tokens, "tensor");
29            match &self.dim {
30                Dim::_1d => {
31                    push_directive(tokens, "1d");
32                }
33                Dim::_2d => {
34                    push_directive(tokens, "2d");
35                }
36                Dim::_3d => {
37                    push_directive(tokens, "3d");
38                }
39                Dim::_4d => {
40                    push_directive(tokens, "4d");
41                }
42                Dim::_5d => {
43                    push_directive(tokens, "5d");
44                }
45            }
46            push_directive(tokens, "L2");
47            match &self.src {
48                Src::Global => {
49                    push_directive(tokens, "global");
50                }
51            }
52            if let Some(load_mode_0) = self.load_mode.as_ref() {
53                match load_mode_0 {
54                    LoadMode::Im2colW128 => {
55                        push_directive(tokens, "im2col::w::128");
56                    }
57                    LoadMode::TileGather4 => {
58                        push_directive(tokens, "tile::gather4");
59                    }
60                    LoadMode::Im2colW => {
61                        push_directive(tokens, "im2col::w");
62                    }
63                    LoadMode::Im2col => {
64                        push_directive(tokens, "im2col");
65                    }
66                    LoadMode::Tile => {
67                        push_directive(tokens, "tile");
68                    }
69                }
70            }
71            if let Some(level_cache_hint_1) = self.level_cache_hint.as_ref() {
72                match level_cache_hint_1 {
73                    LevelCacheHint::L2CacheHint => {
74                        push_directive(tokens, "L2::cache_hint");
75                    }
76                }
77            }
78            if spaced {
79                tokens.push(PtxToken::Space);
80            }
81            self.tensormap.unparse_tokens_mode(tokens, spaced);
82            if self.im2colinfo.is_some() {
83                tokens.push(PtxToken::Comma);
84            }
85            if let Some(opt_2) = self.im2colinfo.as_ref() {
86                if spaced {
87                    tokens.push(PtxToken::Space);
88                }
89                opt_2.unparse_tokens_mode(tokens, spaced);
90            }
91            if self.cache_policy.is_some() {
92                tokens.push(PtxToken::Comma);
93            }
94            if let Some(opt_3) = self.cache_policy.as_ref() {
95                if spaced {
96                    tokens.push(PtxToken::Space);
97                }
98                opt_3.unparse_tokens_mode(tokens, spaced);
99            }
100            tokens.push(PtxToken::Semicolon);
101            if spaced {
102                tokens.push(PtxToken::Newline);
103            }
104        }
105    }
106}