Skip to main content

ptx_parser/type/instruction/
membar.rs

1//! Original PTX specification:
2//!
3//! // Thread fence:
4//! fence{.sem}.scope;
5//! // Thread fence (uni-directional):
6//! fence.acquire.sync_restrict::shared::cluster.cluster;
7//! fence.release.sync_restrict::shared::cta.cluster;
8//! // Operation fence (uni-directional):
9//! fence.op_restrict.release.cluster;
10//! // Proxy fence (bi-directional):
11//! fence.proxy.proxykind;
12//! // Proxy fence (uni-directional):
13//! fence.proxy.to_proxykind::from_proxykind.release.scope;
14//! fence.proxy.to_proxykind::from_proxykind.acquire.scope  [addr], size;
15//! fence.proxy.async::generic.acquire.sync_restrict::shared::cluster.cluster;
16//! fence.proxy.async::generic.release.sync_restrict::shared::cta.cluster;
17//! // Old style membar:
18//! membar.level;
19//! membar.proxy.proxykind;
20//! .sem       = { .sc, .acq_rel, .acquire, .release };
21//! .scope     = { .cta, .cluster, .gpu, .sys };
22//! .level     = { .cta, .gl, .sys };
23//! .proxykind = { .alias, .async, .async.global, .async.shared::cta, .async.shared::cluster};
24//! .op_restrict = { .mbarrier_init };
25//! .to_proxykind::from_proxykind = {.tensormap::generic};
26
27#![allow(unused)]
28use crate::r#type::common::*;
29
30pub mod section_0 {
31    use crate::Spanned;
32    use crate::parser::Span;
33    use crate::r#type::common::*;
34
35    use serde::Serialize;
36
37    #[derive(Debug, Clone, PartialEq, Serialize)]
38    pub enum Sem {
39        AcqRel,  // .acq_rel
40        Acquire, // .acquire
41        Release, // .release
42        Sc,      // .sc
43    }
44
45    #[derive(Debug, Clone, PartialEq, Serialize)]
46    pub enum Scope {
47        Cluster, // .cluster
48        Cta,     // .cta
49        Gpu,     // .gpu
50        Sys,     // .sys
51    }
52
53    #[derive(Debug, Clone, PartialEq, Serialize)]
54    pub enum OpRestrict {
55        MbarrierInit, // .mbarrier_init
56    }
57
58    #[derive(Debug, Clone, PartialEq, Serialize)]
59    pub enum Proxykind {
60        AsyncSharedCluster, // .async.shared::cluster
61        AsyncSharedCta,     // .async.shared::cta
62        AsyncGlobal,        // .async.global
63        Alias,              // .alias
64        Async,              // .async
65    }
66
67    #[derive(Debug, Clone, PartialEq, Serialize)]
68    pub enum ToProxykindFromProxykind {
69        TensormapGeneric, // .tensormap::generic
70    }
71
72    #[derive(Debug, Clone, PartialEq, Serialize)]
73    pub enum Level {
74        Cta, // .cta
75        Sys, // .sys
76        Gl,  // .gl
77    }
78
79    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
80    pub struct FenceSemScope {
81        pub sem: Option<Sem>, // {.sem}
82        pub scope: Scope,     // .scope
83        pub span: Span,
84    }
85
86    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
87    pub struct FenceAcquireSyncRestrictSharedClusterCluster {
88        pub acquire: (),                      // .acquire
89        pub sync_restrict_shared_cluster: (), // .sync_restrict::shared::cluster
90        pub cluster: (),                      // .cluster
91        pub span: Span,
92    }
93
94    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
95    pub struct FenceReleaseSyncRestrictSharedCtaCluster {
96        pub release: (),                  // .release
97        pub sync_restrict_shared_cta: (), // .sync_restrict::shared::cta
98        pub cluster: (),                  // .cluster
99        pub span: Span,
100    }
101
102    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
103    pub struct FenceOpRestrictReleaseCluster {
104        pub op_restrict: OpRestrict, // .op_restrict
105        pub release: (),             // .release
106        pub cluster: (),             // .cluster
107        pub span: Span,
108    }
109
110    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
111    pub struct FenceProxyProxykind {
112        pub proxy: (),            // .proxy
113        pub proxykind: Proxykind, // .proxykind
114        pub span: Span,
115    }
116
117    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
118    pub struct FenceProxyToProxykindFromProxykindReleaseScope {
119        pub proxy: (),                                             // .proxy
120        pub to_proxykind_from_proxykind: ToProxykindFromProxykind, // .to_proxykind::from_proxykind
121        pub release: (),                                           // .release
122        pub scope: Scope,                                          // .scope
123        pub span: Span,
124    }
125
126    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
127    pub struct FenceProxyToProxykindFromProxykindAcquireScope {
128        pub proxy: (),                                             // .proxy
129        pub to_proxykind_from_proxykind: ToProxykindFromProxykind, // .to_proxykind::from_proxykind
130        pub acquire: (),                                           // .acquire
131        pub scope: Scope,                                          // .scope
132        pub addr: AddressOperand,                                  // [addr]
133        pub size: GeneralOperand,                                  // size
134        pub span: Span,
135    }
136
137    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
138    pub struct FenceProxyAsyncGenericAcquireSyncRestrictSharedClusterCluster {
139        pub proxy: (),                        // .proxy
140        pub async_generic: (),                // .async::generic
141        pub acquire: (),                      // .acquire
142        pub sync_restrict_shared_cluster: (), // .sync_restrict::shared::cluster
143        pub cluster: (),                      // .cluster
144        pub span: Span,
145    }
146
147    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
148    pub struct FenceProxyAsyncGenericReleaseSyncRestrictSharedCtaCluster {
149        pub proxy: (),                    // .proxy
150        pub async_generic: (),            // .async::generic
151        pub release: (),                  // .release
152        pub sync_restrict_shared_cta: (), // .sync_restrict::shared::cta
153        pub cluster: (),                  // .cluster
154        pub span: Span,
155    }
156
157    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
158    pub struct MembarLevel {
159        pub level: Level, // .level
160        pub span: Span,
161    }
162
163    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
164    pub struct MembarProxyProxykind {
165        pub proxy: (),            // .proxy
166        pub proxykind: Proxykind, // .proxykind
167        pub span: Span,
168    }
169}
170
171// Re-export types with section suffixes to avoid naming conflicts
172// e.g., Type0 for section_0::Type, Type1 for section_1::Type
173pub use section_0::FenceAcquireSyncRestrictSharedClusterCluster;
174pub use section_0::FenceOpRestrictReleaseCluster;
175pub use section_0::FenceProxyAsyncGenericAcquireSyncRestrictSharedClusterCluster;
176pub use section_0::FenceProxyAsyncGenericReleaseSyncRestrictSharedCtaCluster;
177pub use section_0::FenceProxyProxykind;
178pub use section_0::FenceProxyToProxykindFromProxykindAcquireScope;
179pub use section_0::FenceProxyToProxykindFromProxykindReleaseScope;
180pub use section_0::FenceReleaseSyncRestrictSharedCtaCluster;
181pub use section_0::FenceSemScope;
182pub use section_0::Level as Level0;
183pub use section_0::MembarLevel;
184pub use section_0::MembarProxyProxykind;
185pub use section_0::OpRestrict as OpRestrict0;
186pub use section_0::Proxykind as Proxykind0;
187pub use section_0::Scope as Scope0;
188pub use section_0::Sem as Sem0;
189pub use section_0::ToProxykindFromProxykind as ToProxykindFromProxykind0;