Added support for cl_ext_float_atomics in CBasicTestFetchMinSpecialFloats with atomic_float (#2391)

Related to #2142, according to the work plan, extending
CBasicTestFetchMinSpecialFloats with support for atomic_float.
This commit is contained in:
Marcin Hajder
2026-03-10 16:41:40 +01:00
committed by GitHub
parent a56e8ee92b
commit 6506421614
3 changed files with 310 additions and 28 deletions

View File

@@ -22,6 +22,7 @@
#include "host_atomics.h"
#include <algorithm>
#include <iomanip>
#include <limits>
#include <sstream>
@@ -96,6 +97,37 @@ extern cl_int getSupportedMemoryOrdersAndScopes(
cl_device_id device, std::vector<TExplicitMemoryOrderType> &memoryOrders,
std::vector<TExplicitMemoryScopeType> &memoryScopes);
union FloatIntUnion {
float f;
uint32_t i;
};
template <typename HostDataType> bool is_qnan(const HostDataType &value)
{
if constexpr (std::is_same_v<HostDataType, float>)
{
FloatIntUnion u;
u.f = value;
if ((u.i & 0x7F800000) != 0x7F800000) return false;
return (u.i & 0x00400000) != 0;
}
else
return std::isnan(value);
}
template <typename HostDataType> bool is_snan(const HostDataType &value)
{
if constexpr (std::is_same_v<HostDataType, float>)
{
FloatIntUnion u;
u.f = value;
if ((u.i & 0x7F800000) != 0x7F800000) return false;
return (u.i & 0x00400000) == 0;
}
else
return std::isnan(value);
}
class AtomicTypeInfo {
public:
TExplicitAtomicType _type;
@@ -187,6 +219,7 @@ public:
virtual bool
IsTestNotAsExpected(const HostDataType &expected,
const std::vector<HostAtomicType> &testValues,
const std::vector<HostDataType> &startRefValues,
cl_uint whichDestValue)
{
return expected
@@ -928,7 +961,7 @@ CBasicTest<HostAtomicType, HostDataType>::ProgramHeader(cl_uint maxNumDestItems)
if constexpr (
std::is_same_v<
HostDataType,
HOST_ATOMIC_DOUBLE> || std::is_same_v<HostDataType, HOST_ATOMIC_FLOAT>)
HOST_DOUBLE> || std::is_same_v<HostDataType, HOST_FLOAT>)
{
if (std::isinf(_startValue))
ss << (_startValue < 0 ? "-" : "") << "INFINITY";
@@ -1505,7 +1538,7 @@ int CBasicTest<HostAtomicType, HostDataType>::ExecuteSingleTest(
startRefValues.size() ? &startRefValues[0] : 0, i))
break; // no expected value function provided
if (IsTestNotAsExpected(expected, destItems, i))
if (IsTestNotAsExpected(expected, destItems, startRefValues, i))
{
std::stringstream logLine;
logLine << "ERROR: Result " << i