mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Added support for cl_ext_float_atomics in c11_atomics exchange test along with atomic_half type (#2337)
Related to #2142, according to the work plan, extending CBasicTestExchange with support for atomic_half.
This commit is contained in:
@@ -883,7 +883,14 @@ CBasicTest<HostAtomicType, HostDataType>::ProgramHeader(cl_uint maxNumDestItems)
|
|||||||
header += std::string("__global volatile ") + aTypeName + " destMemory["
|
header += std::string("__global volatile ") + aTypeName + " destMemory["
|
||||||
+ ss.str() + "] = {\n";
|
+ ss.str() + "] = {\n";
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << _startValue;
|
|
||||||
|
if (CBasicTest<HostAtomicType, HostDataType>::DataType()._type
|
||||||
|
!= TYPE_ATOMIC_HALF)
|
||||||
|
ss << _startValue;
|
||||||
|
else
|
||||||
|
ss << static_cast<HostDataType>(
|
||||||
|
cl_half_to_float(static_cast<cl_half>(_startValue)));
|
||||||
|
|
||||||
for (cl_uint i = 0; i < maxNumDestItems; i++)
|
for (cl_uint i = 0; i < maxNumDestItems; i++)
|
||||||
{
|
{
|
||||||
if (aTypeName == "atomic_flag")
|
if (aTypeName == "atomic_flag")
|
||||||
|
|||||||
@@ -545,11 +545,36 @@ public:
|
|||||||
HostDataType>::MemoryOrderScopeStr;
|
HostDataType>::MemoryOrderScopeStr;
|
||||||
using CBasicTestMemOrderScope<HostAtomicType, HostDataType>::Iterations;
|
using CBasicTestMemOrderScope<HostAtomicType, HostDataType>::Iterations;
|
||||||
using CBasicTestMemOrderScope<HostAtomicType, HostDataType>::IterationsStr;
|
using CBasicTestMemOrderScope<HostAtomicType, HostDataType>::IterationsStr;
|
||||||
|
using CBasicTestMemOrderScope<HostAtomicType, HostDataType>::LocalMemory;
|
||||||
CBasicTestExchange(TExplicitAtomicType dataType, bool useSVM)
|
CBasicTestExchange(TExplicitAtomicType dataType, bool useSVM)
|
||||||
: CBasicTestMemOrderScope<HostAtomicType, HostDataType>(dataType,
|
: CBasicTestMemOrderScope<HostAtomicType, HostDataType>(dataType,
|
||||||
useSVM)
|
useSVM)
|
||||||
{
|
{
|
||||||
StartValue(123456);
|
if constexpr (std::is_same_v<HostDataType, HOST_ATOMIC_HALF>)
|
||||||
|
StartValue(cl_half_from_float(static_cast<float>(1234),
|
||||||
|
gHalfRoundingMode));
|
||||||
|
else
|
||||||
|
StartValue(123456);
|
||||||
|
}
|
||||||
|
virtual int ExecuteSingleTest(cl_device_id deviceID, cl_context context,
|
||||||
|
cl_command_queue queue)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<HostDataType, HOST_ATOMIC_HALF>)
|
||||||
|
{
|
||||||
|
if (LocalMemory()
|
||||||
|
&& (gHalfAtomicCaps & CL_DEVICE_LOCAL_FP_ATOMIC_LOAD_STORE_EXT)
|
||||||
|
== 0)
|
||||||
|
return 0; // skip test - not applicable
|
||||||
|
|
||||||
|
if (!LocalMemory()
|
||||||
|
&& (gHalfAtomicCaps & CL_DEVICE_GLOBAL_FP_ATOMIC_LOAD_STORE_EXT)
|
||||||
|
== 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CBasicTestMemOrderScope<
|
||||||
|
HostAtomicType, HostDataType>::ExecuteSingleTest(deviceID, context,
|
||||||
|
queue);
|
||||||
}
|
}
|
||||||
virtual std::string ProgramCore()
|
virtual std::string ProgramCore()
|
||||||
{
|
{
|
||||||
@@ -591,17 +616,35 @@ public:
|
|||||||
/* Any repeated value is treated as an error */
|
/* Any repeated value is treated as an error */
|
||||||
std::vector<bool> tidFound(threadCount);
|
std::vector<bool> tidFound(threadCount);
|
||||||
bool startValueFound = false;
|
bool startValueFound = false;
|
||||||
cl_uint i;
|
cl_uint startVal = StartValue();
|
||||||
|
|
||||||
for (i = 0; i <= threadCount; i++)
|
if constexpr (std::is_same_v<HostDataType, HOST_ATOMIC_HALF>)
|
||||||
|
startVal = static_cast<cl_uint>(
|
||||||
|
cl_half_to_float(static_cast<cl_half>(StartValue())));
|
||||||
|
|
||||||
|
for (cl_uint i = 0; i <= threadCount; i++)
|
||||||
{
|
{
|
||||||
cl_uint value;
|
cl_uint value = 0;
|
||||||
if (i == threadCount)
|
if (i == threadCount)
|
||||||
value = (cl_uint)finalValues[0]; // additional value from atomic
|
{
|
||||||
|
if constexpr (!std::is_same_v<HostDataType, HOST_ATOMIC_HALF>)
|
||||||
|
value =
|
||||||
|
(cl_uint)finalValues[0]; // additional value from atomic
|
||||||
// variable (last written)
|
// variable (last written)
|
||||||
|
else
|
||||||
|
value =
|
||||||
|
cl_half_to_float(static_cast<cl_half>(finalValues[0]));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
value = (cl_uint)refValues[i];
|
{
|
||||||
if (value == (cl_uint)StartValue())
|
if constexpr (!std::is_same_v<HostDataType, HOST_ATOMIC_HALF>)
|
||||||
|
value = (cl_uint)refValues[i];
|
||||||
|
else
|
||||||
|
value =
|
||||||
|
cl_half_to_float(static_cast<cl_half>(refValues[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == startVal)
|
||||||
{
|
{
|
||||||
// Special initial value
|
// Special initial value
|
||||||
if (startValueFound)
|
if (startValueFound)
|
||||||
@@ -666,6 +709,13 @@ static int test_atomic_exchange_generic(cl_device_id deviceID,
|
|||||||
TYPE_ATOMIC_DOUBLE, useSVM);
|
TYPE_ATOMIC_DOUBLE, useSVM);
|
||||||
EXECUTE_TEST(error,
|
EXECUTE_TEST(error,
|
||||||
test_double.Execute(deviceID, context, queue, num_elements));
|
test_double.Execute(deviceID, context, queue, num_elements));
|
||||||
|
if (gFloatAtomicsSupported)
|
||||||
|
{
|
||||||
|
CBasicTestExchange<HOST_ATOMIC_HALF, HOST_HALF> test_half(
|
||||||
|
TYPE_ATOMIC_HALF, useSVM);
|
||||||
|
EXECUTE_TEST(error,
|
||||||
|
test_half.Execute(deviceID, context, queue, num_elements));
|
||||||
|
}
|
||||||
if (AtomicTypeInfo(TYPE_ATOMIC_SIZE_T).Size(deviceID) == 4)
|
if (AtomicTypeInfo(TYPE_ATOMIC_SIZE_T).Size(deviceID) == 4)
|
||||||
{
|
{
|
||||||
CBasicTestExchange<HOST_ATOMIC_INTPTR_T32, HOST_INTPTR_T32>
|
CBasicTestExchange<HOST_ATOMIC_INTPTR_T32, HOST_INTPTR_T32>
|
||||||
|
|||||||
Reference in New Issue
Block a user