missing testing for cl_ext_float_atomics
This issue is to track missing tests for the cl_ext_float_atomics extension.
There is some testing for these extensions in the Vulkan CTS.
There are also some tests in the Intel Cassian test framework, see: https://github.com/intel/cassian/commit/239de5d8630bee09c0f3e136d4dab6e508bf80e3
A good first step would be to evaluate what is tested by the other frameworks, see what may be useful for the OpenCL CTS, and write up a brief test plan.
Below is the proposition for a work plan on cl_ext_float_atomics and a few questions, I will appreciate discussions and your answers, thanks!
- Adaptation of
c11_atomicstest suite in order to add support forcl_ext_float_atomicsby including new generic cases for data typesfp16/fp32/fp64in classes:
- [x] CBasicTestStore with atomic_half
- [x] CBasicTestLoad with atomic_half
- [x] CBasicTestExchange with atomic_half
- [x] CBasicTestFetchAdd with atomic_float
- [x] CBasicTestFetchAdd with atomic_double
- [x] CBasicTestFetchAdd with atomic_half
- [x] CBasicTestFetchSub with atomic_float
- [x] CBasicTestFetchSub with atomic_double
- [x] CBasicTestFetchSub with atomic_half
- [x] CBasicTestFetchMin with atomic_float
- [x] CBasicTestFetchMin with atomic_double
- [x] CBasicTestFetchMin with atomic_half
- [x] CBasicTestFetchMax with atomic_float
- [x] CBasicTestFetchMax with atomic_double
- [x] CBasicTestFetchMax with atomic_half
- Extending c11_atomics with special values tests for:
- [ ] CBasicTestFetchAdd with atomic_float
- [ ] CBasicTestFetchAdd with atomic_double
- [ ] CBasicTestFetchAdd with atomic_half
- [ ] CBasicTestFetchSub with atomic_float
- [ ] CBasicTestFetchSub with atomic_double
- [ ] CBasicTestFetchSub with atomic_half
- [ ] CBasicTestFetchMin with atomic_float
- [ ] CBasicTestFetchMin with atomic_double
- [ ] CBasicTestFetchMin with atomic_half
- [ ] CBasicTestFetchMax with atomic_float
- [ ] CBasicTestFetchMax with atomic_double
- [ ] CBasicTestFetchMax with atomic_half
- Implementation of new tests for
spirv_newtest suite including bothCrossWorkGroupandWorkgroupstorage classes, supportingfp16/fp32/fp64is not necessary. It is a matter of--compilation-mode spir-vrun options and the specificcl_offline_compilerto test SPIRV +cl_ext_float_atomicsextension along withc11_atomicstest.
IMHO, one of the trickiest parts of testing float atomics will be numerical stability because floating-point addition is not associative. Have you given any thought how to handle this issue? Have you evaluated how other testing frameworks solve this problem?
Are we able to test any NaN (and infinity?) behavior, or are we expecting our inputs and results to be non-NaN (and non-infinity)?
I agree with @bashbaug. Unless the order of the atomic operations is explicitly controlled, the test will have to assume they can happen in any possible order and account for that.
An option for one test is to use only the values where the order doesn't matter and each operation is guaranteed to be exact, e.g. small integers while avoiding overflow.
Have you given any thought how to handle this issue? Have you evaluated how other testing frameworks solve this problem?
Thanks, I went through vk-gl-cts modifications related to VK_EXT_shader_atomic_float extension, issue 2371. I may be wrong but it seems like related changes were applied to general atomic test (vktAtomicOperationTests.cpp), it looks pretty generic and hard to read but it looks like comparing of float results narrow down to this function:
template <typename T>
bool sloppyFPCompare(T x, T y)
{
return fabs(deToDouble(x) - deToDouble(y)) < 0.00001;
}
Does hardcoded epsilon be an acceptable solution for OpenCL-CTS atomic floats tests?
Edit: I just created PR for atomic_fetch_add case. The idea is to estimate largest possible summation error based on worse/best case scenarios. If that's not acceptable approach I will appreciate your tips and hints. Thanks