diff --git a/test_conformance/c11_atomics/host_atomics.h b/test_conformance/c11_atomics/host_atomics.h index 017bf25a..e5b1d328 100644 --- a/test_conformance/c11_atomics/host_atomics.h +++ b/test_conformance/c11_atomics/host_atomics.h @@ -164,7 +164,10 @@ CorrespondingType host_atomic_load(volatile AtomicType *a, TExplicitMemoryOrderType order) { #if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32)) - return InterlockedExchangeAdd(a, 0); + if (sizeof(CorrespondingType) == 2) + auto prev = InterlockedOr16(reinterpret_cast(a), 0); + else + return InterlockedExchangeAdd(reinterpret_cast(a), 0); #elif defined(__GNUC__) return __sync_add_and_fetch(a, 0); #else diff --git a/test_conformance/c11_atomics/test_atomics.cpp b/test_conformance/c11_atomics/test_atomics.cpp index 649d8aa4..7c86ae7f 100644 --- a/test_conformance/c11_atomics/test_atomics.cpp +++ b/test_conformance/c11_atomics/test_atomics.cpp @@ -328,6 +328,7 @@ public: HostDataType>::MemoryOrderScopeStr; using CBasicTestMemOrderScope::MemoryScopeStr; using CBasicTest::CheckCapabilities; + using CBasicTestMemOrderScope::LocalMemory; CBasicTestLoad(TExplicitAtomicType dataType, bool useSVM) : CBasicTestMemOrderScope(dataType, useSVM) @@ -349,6 +350,21 @@ public: == TEST_SKIPPED_ITSELF) return 0; // skip test - not applicable + if (CBasicTestMemOrderScope::DataType() + ._type + == TYPE_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); @@ -382,7 +398,13 @@ public: HostDataType *startRefValues, cl_uint whichDestValue) { - expected = (HostDataType)whichDestValue; + if (CBasicTestMemOrderScope::DataType() + ._type + != TYPE_ATOMIC_HALF) + expected = (HostDataType)whichDestValue; + else + expected = cl_half_from_float(static_cast(whichDestValue), + gHalfRoundingMode); return true; } virtual bool VerifyRefs(bool &correct, cl_uint threadCount, @@ -392,11 +414,25 @@ public: correct = true; for (cl_uint i = 0; i < threadCount; i++) { - if (refValues[i] != (HostDataType)i) + if constexpr (std::is_same::value) { - log_error("Invalid value for thread %u\n", (cl_uint)i); - correct = false; - return true; + HostDataType test = cl_half_from_float(static_cast(i), + gHalfRoundingMode); + if (refValues[i] != test) + { + log_error("Invalid value for thread %u\n", (cl_uint)i); + correct = false; + return true; + } + } + else + { + if (refValues[i] != (HostDataType)i) + { + log_error("Invalid value for thread %u\n", (cl_uint)i); + correct = false; + return true; + } } } return true; @@ -431,6 +467,15 @@ static int test_atomic_load_generic(cl_device_id deviceID, cl_context context, TYPE_ATOMIC_DOUBLE, useSVM); EXECUTE_TEST(error, test_double.Execute(deviceID, context, queue, num_elements)); + + if (gFloatAtomicsSupported) + { + CBasicTestLoad 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) { CBasicTestLoad test_intptr_t(