diff --git a/test_conformance/c11_atomics/common.h b/test_conformance/c11_atomics/common.h index 64e59b54..3cab98ce 100644 --- a/test_conformance/c11_atomics/common.h +++ b/test_conformance/c11_atomics/common.h @@ -883,7 +883,14 @@ CBasicTest::ProgramHeader(cl_uint maxNumDestItems) header += std::string("__global volatile ") + aTypeName + " destMemory[" + ss.str() + "] = {\n"; ss.str(""); - ss << _startValue; + + if (CBasicTest::DataType()._type + != TYPE_ATOMIC_HALF) + ss << _startValue; + else + ss << static_cast( + cl_half_to_float(static_cast(_startValue))); + for (cl_uint i = 0; i < maxNumDestItems; i++) { if (aTypeName == "atomic_flag") diff --git a/test_conformance/c11_atomics/test_atomics.cpp b/test_conformance/c11_atomics/test_atomics.cpp index 7c86ae7f..a08a0daf 100644 --- a/test_conformance/c11_atomics/test_atomics.cpp +++ b/test_conformance/c11_atomics/test_atomics.cpp @@ -545,11 +545,36 @@ public: HostDataType>::MemoryOrderScopeStr; using CBasicTestMemOrderScope::Iterations; using CBasicTestMemOrderScope::IterationsStr; + using CBasicTestMemOrderScope::LocalMemory; CBasicTestExchange(TExplicitAtomicType dataType, bool useSVM) : CBasicTestMemOrderScope(dataType, useSVM) { - StartValue(123456); + if constexpr (std::is_same_v) + StartValue(cl_half_from_float(static_cast(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) + { + 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() { @@ -591,17 +616,35 @@ public: /* Any repeated value is treated as an error */ std::vector tidFound(threadCount); bool startValueFound = false; - cl_uint i; + cl_uint startVal = StartValue(); - for (i = 0; i <= threadCount; i++) + if constexpr (std::is_same_v) + startVal = static_cast( + cl_half_to_float(static_cast(StartValue()))); + + for (cl_uint i = 0; i <= threadCount; i++) { - cl_uint value; + cl_uint value = 0; if (i == threadCount) - value = (cl_uint)finalValues[0]; // additional value from atomic + { + if constexpr (!std::is_same_v) + value = + (cl_uint)finalValues[0]; // additional value from atomic // variable (last written) + else + value = + cl_half_to_float(static_cast(finalValues[0])); + } else - value = (cl_uint)refValues[i]; - if (value == (cl_uint)StartValue()) + { + if constexpr (!std::is_same_v) + value = (cl_uint)refValues[i]; + else + value = + cl_half_to_float(static_cast(refValues[i])); + } + + if (value == startVal) { // Special initial value if (startValueFound) @@ -666,6 +709,13 @@ static int test_atomic_exchange_generic(cl_device_id deviceID, TYPE_ATOMIC_DOUBLE, useSVM); EXECUTE_TEST(error, test_double.Execute(deviceID, context, queue, num_elements)); + if (gFloatAtomicsSupported) + { + CBasicTestExchange 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) { CBasicTestExchange