Skip to content

Commit

Permalink
[UnitCL] Fix C11Atomics_73_*, C11Atomics_74_*, C11Atomics_75_*
Browse files Browse the repository at this point in the history
These tests test atomic_compare_exchange_weak_explicit which is allowed
to fail for no clear reason. The test tries to account for this by
detecting output differences, using that to set a weak_exchange_failed
boolean, and using that weak_exchange_failed boolean to detect where the
result of atomic_compare_exchange_weak_explicit does not match
expectations. That is, in output_reference, it does:

          if (value == expected_values[success_index]) {
            weak_exchange_failed = true;
            return true;
          }

Then, bool_output_reference is:

        [success_index, weak_exchange_failed](size_t index) {
          return index == success_index && !weak_exchange_failed;
        };

The problem here is that bool_output_reference is constructed capturing
weak_exchange_failed by value, so it will never pick up the updated
value even if it was detected that the weak exchange had failed. To fix
this, capture it by reference instead.
  • Loading branch information
hvdijk committed Sep 13, 2024
1 parent e07ca5e commit b1f90dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/cl/test/UnitCL/source/C11Atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ class WeakGlobalSingle : public C11AtomicTestBase {
return desired_values[index];
};
kts::Reference1D<cl_int> bool_output_reference =
[success_index, weak_exchange_failed](size_t index) {
[success_index, &weak_exchange_failed](size_t index) {
return index == success_index && !weak_exchange_failed;
};

Expand Down

0 comments on commit b1f90dc

Please sign in to comment.