mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-26 00:39:03 +00:00
Added support for cl_ext_float_atomics in CBasicTestFetchAdd with atomic_float (#2345)
Related to #2142, according to the work plan, extending CBasicTestFetchAdd with support for atomic_float.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#define HOST_ATOMICS_H_
|
||||
|
||||
#include "harness/testHarness.h"
|
||||
#include <mutex>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "Windows.h"
|
||||
@@ -94,14 +95,25 @@ template <typename AtomicType, typename CorrespondingType>
|
||||
CorrespondingType host_atomic_fetch_add(volatile AtomicType *a, CorrespondingType c,
|
||||
TExplicitMemoryOrderType order)
|
||||
{
|
||||
if constexpr (std::is_same_v<AtomicType, HOST_ATOMIC_FLOAT>)
|
||||
{
|
||||
static std::mutex mx;
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
CorrespondingType old_value = *a;
|
||||
*a += c;
|
||||
return old_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( _MSC_VER ) || (defined( __INTEL_COMPILER ) && defined(WIN32))
|
||||
return InterlockedExchangeAdd(a, c);
|
||||
return InterlockedExchangeAdd(a, c);
|
||||
#elif defined(__GNUC__)
|
||||
return __sync_fetch_and_add(a, c);
|
||||
return __sync_fetch_and_add(a, c);
|
||||
#else
|
||||
log_info("Host function not implemented: atomic_fetch_add\n");
|
||||
return 0;
|
||||
log_info("Host function not implemented: atomic_fetch_add\n");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <typename AtomicType, typename CorrespondingType>
|
||||
|
||||
Reference in New Issue
Block a user