mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-26 08:49:02 +00:00
Added support for cl_ext_float_atomics in CBasicTestFetchMin/Max with atomic_float (#2353)
Related to #2142, according to the work plan, extending `CBasicTestFetchMin`/`CBasicTestFetchMax` with support for atomic_float.
This commit is contained in:
@@ -172,19 +172,34 @@ bool host_atomic_compare_exchange(volatile AtomicType *a, CorrespondingType *exp
|
||||
TExplicitMemoryOrderType order_success,
|
||||
TExplicitMemoryOrderType order_failure)
|
||||
{
|
||||
CorrespondingType tmp;
|
||||
#if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32))
|
||||
tmp = InterlockedCompareExchange(a, desired, *expected);
|
||||
CorrespondingType tmp;
|
||||
if constexpr (std::is_same_v<AtomicType, HOST_ATOMIC_FLOAT>)
|
||||
{
|
||||
static std::mutex mtx;
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
tmp = *reinterpret_cast<volatile float *>(a);
|
||||
if (tmp == *expected)
|
||||
{
|
||||
*reinterpret_cast<volatile float *>(a) = desired;
|
||||
return true;
|
||||
}
|
||||
*expected = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
|
||||
|
||||
tmp = InterlockedCompareExchange(a, desired, *expected);
|
||||
#elif defined(__GNUC__)
|
||||
tmp = __sync_val_compare_and_swap(a, *expected, desired);
|
||||
tmp = __sync_val_compare_and_swap(a, *expected, desired);
|
||||
#else
|
||||
log_info("Host function not implemented: atomic_compare_exchange\n");
|
||||
tmp = 0;
|
||||
log_info("Host function not implemented: atomic_compare_exchange\n");
|
||||
tmp = 0;
|
||||
#endif
|
||||
if(tmp == *expected)
|
||||
return true;
|
||||
*expected = tmp;
|
||||
return false;
|
||||
if (tmp == *expected) return true;
|
||||
*expected = tmp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename AtomicType, typename CorrespondingType>
|
||||
|
||||
Reference in New Issue
Block a user