Skip to content

Fix atomics in early-exit and histogram algorithms - #2914

Open
dmitriy-sobolev wants to merge 3 commits into
mainfrom
dev/dmitriy-sobolev/atomic-scope
Open

dmitriy-sobolev wants to merge 3 commits into
mainfrom
dev/dmitriy-sobolev/atomic-scope

Conversation

@dmitriy-sobolev

@dmitriy-sobolev dmitriy-sobolev commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The change affects early-exit and histogram algorithms:

  • Early-exit algorithms. Briefly, each work-group finds a value and then last one stores it. There were no barriers and the the atomic operations solely relied on sycl::memory_order::relaxed, which is a data race. It's fixed by a combo of sycl::memory_order::release and sycl::memory_order::acquire, which established the happens-before relationship.
  • Both algorithms. They used atomics with sycl::memory_scope::work_group and sycl::access::address_space::global_space. It was fine if the atomic accesses were made by a single work-group, but the algorithms do it by different work-groups. They need sycl::memory_scope::device.

The last change creates an issue, but it is less severe than the original one. sycl::memory_scope::device may not be supported by any device. The affected devices are unknown. See https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:memory-scope:

The complete set of memory scopes is not guaranteed to be supported by every device.

And then in https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#api:info-device-atomic-memory-scope-capabilities:

At a minimum, each device must support memory_scope::sub_group and memory_scope::work_group.

The __atomic_ref abstraction was removed to avoid similar issues in the future. It was guarded by _ONEDPL_LIBSYCL_VERSION_LESS_THAN(50500), but there are precedents of removing guards for features requiring even newer implementation, e.g. 60200 in #2534.

Signed-off-by: Sobolev, Dmitriy <dmitriy.sobolev@intel.com>
Signed-off-by: Sobolev, Dmitriy <dmitriy.sobolev@intel.com>
Signed-off-by: Sobolev, Dmitriy <dmitriy.sobolev@intel.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant