File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -434,6 +434,12 @@ class coalesced_group : public thread_group {
434434 template <class T > __CG_QUALIFIER__ T shfl (T var, int srcRank) const {
435435 static_assert (is_valid_type<T>::value, " Neither an integer or float type." );
436436
437+ // Singleton coalesced group (chipStar SPIR-V fallback when the active-
438+ // lane mask is unavailable): the only valid source rank is 0 and the
439+ // result is the caller's own value.
440+ if (size () == 1 )
441+ return var;
442+
437443 srcRank = srcRank % static_cast <int >(size ());
438444
439445 int lane = (size () == __AMDGCN_WAVEFRONT_SIZE) ? srcRank
@@ -508,7 +514,12 @@ class coalesced_group : public thread_group {
508514 */
509515
510516__CG_QUALIFIER__ coalesced_group coalesced_threads () {
511- return cooperative_groups::coalesced_group (__builtin_amdgcn_read_exec ());
517+ // chipStar's SPIR-V backend has no way to query the active-lane mask
518+ // (the AMDGCN exec register), so we conservatively model each thread
519+ // as its own coalesced group of size 1. This keeps semantics correct
520+ // for common patterns such as warp-aggregated atomics (atomicAggInc)
521+ // at the cost of the warp-level optimisation.
522+ return cooperative_groups::coalesced_group (static_cast <lane_mask>(1 ));
512523}
513524
514525/* *
You can’t perform that action at this time.
0 commit comments