KhronosGroup / KhronosGroup/OpenCL-CTS
host float atomic add and sub incompatible with SVM atomics
- Dominant language
- C++
- Stars
- 232
- Forks
- 235
- Avg merge
- 8d 7h
- Merged PRs (30d)
- 18
Description
Related to #2142
The current implementation of the floating-point host atomic add is implemented with a mutex:
https://github.com/KhronosGroup/OpenCL-CTS/blob/80e08b23212466649a21cee7bee25657163663c4/test_conformance/c11_atomics/host_atomics.h#L286-L296
The floating-point host atomic sub is implemented similarly.
The mutex enforces atomicity from the host, but because the SVM atomics on the device have no notion of the mutex, it doesn't enforce atomicity on the device. This means that the SVM atomics tests can fail unpredictably, specifically `svm_atomic_fetch_add` and `svm_atomic_fetch_sub` for the floating-point types.
To fix this issue, we should implement the host atomic add and sub with a cmpxchg loop, similar to the implementation of the host atomic min and max.
Although, it looks like the floating-point host atomic compare exchange is implemented with a mutex, also. This means that it will have the same problem, as will any atomic built on top of it.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in test_conformance/c11_atomics/host_atomics.h around lines 286-296 and compare the floating-point host add and sub implementations with host atomic min and max. Check the svm_atomic_fetch_add and svm_atomic_fetch_sub tests, then address the related floating-point compare-exchange behavior identified in the issue. Done means the SVM atomic tests no longer fail unpredictably when host and device operations overlap.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100