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 CBasicTestFetchAdd with atomic_half (#2350)
Related to https://github.com/KhronosGroup/OpenCL-CTS/issues/2142, according to the work plan, extending CBasicTestFetchAdd with support for atomic_half. I wasn't able to test that PR completely due to missing `CL_DEVICE_LOCAL_FP_ATOMIC_ADD_EXT`/`CL_DEVICE_GLOBAL_FP_ATOMIC_ADD_EXT` capabilities for atomic_half. I appreciate reviewers' attention, thanks.
This commit is contained in:
@@ -99,7 +99,16 @@ template <typename AtomicType, typename CorrespondingType>
|
||||
CorrespondingType host_atomic_fetch_add(volatile AtomicType *a, CorrespondingType c,
|
||||
TExplicitMemoryOrderType order)
|
||||
{
|
||||
if constexpr (
|
||||
if constexpr (std::is_same_v<AtomicType, HOST_ATOMIC_HALF>)
|
||||
{
|
||||
static std::mutex mx;
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
CorrespondingType old_value = *a;
|
||||
*a = cl_half_from_float((cl_half_to_float(*a) + cl_half_to_float(c)),
|
||||
gHalfRoundingMode);
|
||||
return old_value;
|
||||
}
|
||||
else if constexpr (
|
||||
std::is_same_v<
|
||||
AtomicType,
|
||||
HOST_ATOMIC_FLOAT> || std::is_same_v<AtomicType, HOST_ATOMIC_DOUBLE>)
|
||||
@@ -112,7 +121,7 @@ CorrespondingType host_atomic_fetch_add(volatile AtomicType *a, CorrespondingTyp
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32))
|
||||
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
|
||||
return InterlockedExchangeAdd(a, c);
|
||||
#elif defined(__GNUC__)
|
||||
return __sync_fetch_and_add(a, c);
|
||||
|
||||
Reference in New Issue
Block a user