ptx_parser/parser/instruction/
cp_reduce_async_bulk_tensor.rs1#![allow(unused)]
13
14use crate::parser::{
15 PtxParseError, PtxParser, PtxTokenStream, Span,
16 util::{
17 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
18 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
19 },
20};
21use crate::r#type::common::*;
22use crate::{alt, ok, seq_n};
23
24pub mod section_0 {
25 use super::*;
26 use crate::r#type::instruction::cp_reduce_async_bulk_tensor::section_0::*;
27
28 impl PtxParser for CompletionMechanism {
33 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
34 alt!(map(string_p(".bulk_group"), |_, _span| {
35 CompletionMechanism::BulkGroup
36 }))
37 }
38 }
39
40 impl PtxParser for Dim {
41 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
42 alt!(
43 map(string_p(".1d"), |_, _span| Dim::_1d),
44 map(string_p(".2d"), |_, _span| Dim::_2d),
45 map(string_p(".3d"), |_, _span| Dim::_3d),
46 map(string_p(".4d"), |_, _span| Dim::_4d),
47 map(string_p(".5d"), |_, _span| Dim::_5d)
48 )
49 }
50 }
51
52 impl PtxParser for Dst {
53 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
54 alt!(map(string_p(".global"), |_, _span| Dst::Global))
55 }
56 }
57
58 impl PtxParser for LoadMode {
59 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
60 alt!(
61 map(string_p(".im2col_no_offs"), |_, _span| {
62 LoadMode::Im2colNoOffs
63 }),
64 map(string_p(".tile"), |_, _span| LoadMode::Tile)
65 )
66 }
67 }
68
69 impl PtxParser for Redop {
70 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
71 alt!(
72 map(string_p(".add"), |_, _span| Redop::Add),
73 map(string_p(".min"), |_, _span| Redop::Min),
74 map(string_p(".max"), |_, _span| Redop::Max),
75 map(string_p(".inc"), |_, _span| Redop::Inc),
76 map(string_p(".dec"), |_, _span| Redop::Dec),
77 map(string_p(".and"), |_, _span| Redop::And),
78 map(string_p(".xor"), |_, _span| Redop::Xor),
79 map(string_p(".or"), |_, _span| Redop::Or)
80 )
81 }
82 }
83
84 impl PtxParser for Src {
85 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
86 alt!(map(string_p(".shared::cta"), |_, _span| Src::SharedCta))
87 }
88 }
89
90 impl PtxParser for CpReduceAsyncBulkTensorDimDstSrcRedopLoadModeCompletionMechanismLevelCacheHint {
91 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
92 try_map(
93 seq_n!(
94 string_p("cp"),
95 string_p(".reduce"),
96 string_p(".async"),
97 string_p(".bulk"),
98 string_p(".tensor"),
99 Dim::parse(),
100 Dst::parse(),
101 Src::parse(),
102 Redop::parse(),
103 optional(LoadMode::parse()),
104 CompletionMechanism::parse(),
105 map(optional(string_p(".level::cache_hint")), |value, _| value
106 .is_some()),
107 TexHandler2::parse(),
108 comma_p(),
109 AddressOperand::parse(),
110 map(
111 optional(seq_n!(comma_p(), GeneralOperand::parse())),
112 |value, _| value.map(|(_, operand)| operand)
113 ),
114 semicolon_p()
115 ),
116 |(
117 _,
118 reduce,
119 async_,
120 bulk,
121 tensor,
122 dim,
123 dst,
124 src,
125 redop,
126 load_mode,
127 completion_mechanism,
128 level_cache_hint,
129 tensormap,
130 _,
131 srcmem,
132 cache_policy,
133 _,
134 ),
135 span| {
136 ok!(CpReduceAsyncBulkTensorDimDstSrcRedopLoadModeCompletionMechanismLevelCacheHint {
137 reduce = reduce,
138 async_ = async_,
139 bulk = bulk,
140 tensor = tensor,
141 dim = dim,
142 dst = dst,
143 src = src,
144 redop = redop,
145 load_mode = load_mode,
146 completion_mechanism = completion_mechanism,
147 level_cache_hint = level_cache_hint,
148 tensormap = tensormap,
149 srcmem = srcmem,
150 cache_policy = cache_policy,
151
152 })
153 },
154 )
155 }
156 }
157}