@@ -43,11 +43,13 @@ enum class SyncScope {
4343 SystemScope,
4444 DeviceScope,
4545 WorkgroupScope,
46+ ClusterScope,
4647 WavefrontScope,
4748 SingleScope,
4849 HIPSingleThread,
4950 HIPWavefront,
5051 HIPWorkgroup,
52+ HIPCluster,
5153 HIPAgent,
5254 HIPSystem,
5355 OpenCLWorkGroup,
@@ -65,6 +67,8 @@ inline llvm::StringRef getAsString(SyncScope S) {
6567 return " device_scope" ;
6668 case SyncScope::WorkgroupScope:
6769 return " workgroup_scope" ;
70+ case SyncScope::ClusterScope:
71+ return " cluster_scope" ;
6872 case SyncScope::WavefrontScope:
6973 return " wavefront_scope" ;
7074 case SyncScope::SingleScope:
@@ -75,6 +79,8 @@ inline llvm::StringRef getAsString(SyncScope S) {
7579 return " hip_wavefront" ;
7680 case SyncScope::HIPWorkgroup:
7781 return " hip_workgroup" ;
82+ case SyncScope::HIPCluster:
83+ return " hip_cluster" ;
7884 case SyncScope::HIPAgent:
7985 return " hip_agent" ;
8086 case SyncScope::HIPSystem:
@@ -174,13 +180,18 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
174180 // / The enum values match the pre-defined macros
175181 // / __HIP_MEMORY_SCOPE_*, which are used to define memory_scope_*
176182 // / enums in hip-c.h.
183+ // / These may be present in pch files or bitcode so preserve existing values
184+ // / when adding a new ID.
177185 enum ID {
178186 SingleThread = 1 ,
179187 Wavefront = 2 ,
180188 Workgroup = 3 ,
181189 Agent = 4 ,
182190 System = 5 ,
183- Last = System
191+ Cluster = 6 ,
192+ End,
193+ Last = End - 1 ,
194+ Count = Last
184195 };
185196
186197 AtomicScopeHIPModel () {}
@@ -193,10 +204,14 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
193204 return SyncScope::HIPWavefront;
194205 case Workgroup:
195206 return SyncScope::HIPWorkgroup;
207+ case Cluster:
208+ return SyncScope::HIPCluster;
196209 case Agent:
197210 return SyncScope::HIPAgent;
198211 case System:
199212 return SyncScope::HIPSystem;
213+ case End:
214+ break ;
200215 }
201216 llvm_unreachable (" Invalid language sync scope value" );
202217 }
@@ -207,11 +222,12 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
207222 }
208223
209224 ArrayRef<unsigned > getRuntimeValues () const override {
210- static_assert (Last == System, " Does not include all sync scopes" );
211225 static const unsigned Scopes[] = {
212226 static_cast <unsigned >(SingleThread), static_cast <unsigned >(Wavefront),
213- static_cast <unsigned >(Workgroup), static_cast <unsigned >(Agent),
214- static_cast <unsigned >(System)};
227+ static_cast <unsigned >(Workgroup), static_cast <unsigned >(Cluster),
228+ static_cast <unsigned >(System), static_cast <unsigned >(Agent)};
229+ static_assert (sizeof (Scopes) / sizeof (Scopes[0 ]) == Count,
230+ " Does not include all sync scopes" );
215231 return llvm::ArrayRef (Scopes);
216232 }
217233
@@ -223,14 +239,18 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
223239// / Defines the generic atomic scope model.
224240class AtomicScopeGenericModel : public AtomicScopeModel {
225241public:
226- // / The enum values match predefined built-in macros __ATOMIC_SCOPE_*.
242+ // / The enum values match predefined built-in macros __MEMORY_SCOPE_*.
243+ // / These may be present in pch files or bitcode so preserve existing values
244+ // / when adding a new ID.
227245 enum ID {
228246 System = 0 ,
229247 Device = 1 ,
230248 Workgroup = 2 ,
231249 Wavefront = 3 ,
232250 Single = 4 ,
233- Last = Single
251+ Cluster = 5 ,
252+ Count,
253+ Last = Count - 1
234254 };
235255
236256 AtomicScopeGenericModel () = default ;
@@ -243,10 +263,14 @@ class AtomicScopeGenericModel : public AtomicScopeModel {
243263 return SyncScope::SystemScope;
244264 case Workgroup:
245265 return SyncScope::WorkgroupScope;
266+ case Cluster:
267+ return SyncScope::ClusterScope;
246268 case Wavefront:
247269 return SyncScope::WavefrontScope;
248270 case Single:
249271 return SyncScope::SingleScope;
272+ case Count:
273+ break ;
250274 }
251275 llvm_unreachable (" Invalid language sync scope value" );
252276 }
@@ -256,11 +280,12 @@ class AtomicScopeGenericModel : public AtomicScopeModel {
256280 }
257281
258282 ArrayRef<unsigned > getRuntimeValues () const override {
259- static_assert (Last == Single, " Does not include all sync scopes" );
260283 static const unsigned Scopes[] = {
261- static_cast <unsigned >(Device), static_cast <unsigned >(System),
262- static_cast <unsigned >(Workgroup), static_cast <unsigned >(Wavefront),
263- static_cast <unsigned >(Single)};
284+ static_cast <unsigned >(System), static_cast <unsigned >(Device),
285+ static_cast <unsigned >(Workgroup), static_cast <unsigned >(Cluster),
286+ static_cast <unsigned >(Wavefront), static_cast <unsigned >(Single)};
287+ static_assert (sizeof (Scopes) / sizeof (Scopes[0 ]) == Count,
288+ " Does not include all sync scopes" );
264289 return llvm::ArrayRef (Scopes);
265290 }
266291
0 commit comments