KhronosGroup / KhronosGroup/OpenCL-CTS

Results of spir/atomics/test_atomic_fn.atomic_cmpxchg_* are not determinstic

Open
#1,092 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
232
Forks
235
Avg merge
8d 7h
Merged PRs (30d)
18

Description

File test_atomic_fn.atomic_cmpxchg_local_uint.cl in test_conformance/spir/atomics.zip contains following piece of code,
```
1 do {
2 oldValue = L[0];
3 newValue = oldValue + 1;
4 oldValue = atomic_cmpxchg(&L[0], oldValue, newValue);
5 } while (oldValue == L[0]);
```
Given 3 work items, there are 2 possible execution paths:

Possible path 1
```
- Init L[0] := 0
- WI 0: executes line 1-3: oldValue := 0
- WI 1: executes line 1-5: L[0] := 1 (store to L[0] succeeds)
- WI 0: executes line 4: oldValue := 1, L[0] isn't changed. (Before executing line 4, oldValue == 0 and L[0] == 1, thus store fails, and oldValue is updated to L[0] = 1)
- WI 2: executes line 1-5: L[0] := 2 (store to L[0] succeeds)
- WI 0: executes line 5: L[0] == 2 and oldValue == 1, thus jump out the loop.

The final value of L[0] is 2.
```

Possible path 2
```
- Init L[0] := 0
- WI 0: executes line 1-5: L[0] := 1
- WI 1: executes line 1-5: L[0] := 2
- WI 2: executes line 1-5: L[0] := 3

The final value of L[0] is 3.
```

So the result of the program isn't deterministic.

The issue affects all cmpxchg tests under spir/atomics.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with test_conformance/spir/atomics.zip, especially test_atomic_fn.atomic_cmpxchg_local_uint.cl, and compare the other cmpxchg tests under spir/atomics. Reproduce the reported executions and inspect how the tests determine their expected final values. Done means the cmpxchg tests produce deterministic results across valid work-item schedules.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.