Added support for cl_ext_float_atomics in c11_atomics store test along with atomic_half type (#2293)

Related to #2142, according to the work plan extended `CBasicTestStore`
with support for `atomic_half`.

Optimization remark: in tests related to `CBasicTestStore` kernel source
code is mostly composed with arguments following similar pattern:

`__kernel void test_atomic_kernel(uint threadCount, uint numDestItems,
__global int *finalDest, __global int *oldValues, volatile __local
atomic_int *destMemory)`

`oldValues` buffer is initialized with a host pointer, after kernel
execution it is read back to the host pointer but it is unused in
neither of the kernels I verified.
This commit is contained in:
Marcin Hajder
2025-05-27 17:51:36 +02:00
committed by GitHub
parent 110799bb67
commit dec5644112
5 changed files with 134 additions and 54 deletions

View File

@@ -22,6 +22,8 @@
#include "host_atomics.h"
#include "CL/cl_half.h"
#include <vector>
#include <sstream>
@@ -38,6 +40,7 @@ enum TExplicitAtomicType
TYPE_ATOMIC_UINT,
TYPE_ATOMIC_LONG,
TYPE_ATOMIC_ULONG,
TYPE_ATOMIC_HALF,
TYPE_ATOMIC_FLOAT,
TYPE_ATOMIC_DOUBLE,
TYPE_ATOMIC_INTPTR_T,
@@ -71,6 +74,9 @@ extern int
gMaxDeviceThreads; // maximum number of threads executed on OCL device
extern cl_device_atomic_capabilities gAtomicMemCap,
gAtomicFenceCap; // atomic memory and fence capabilities for this device
extern cl_half_rounding_mode gHalfRoundingMode;
extern bool gFloatAtomicsSupported;
extern cl_device_fp_atomic_capabilities_ext gHalfAtomicCaps;
extern const char *
get_memory_order_type_name(TExplicitMemoryOrderType orderType);
@@ -240,13 +246,13 @@ public:
int error = 0;
if (_maxDeviceThreads > 0 && !UseSVM())
{
LocalMemory(true);
SetLocalMemory(true);
EXECUTE_TEST(
error, ExecuteForEachDeclarationType(deviceID, context, queue));
}
if (_maxDeviceThreads + MaxHostThreads() > 0)
{
LocalMemory(false);
SetLocalMemory(false);
EXECUTE_TEST(
error, ExecuteForEachDeclarationType(deviceID, context, queue));
}
@@ -401,7 +407,7 @@ public:
bool UseSVM() { return _useSVM; }
void StartValue(HostDataType startValue) { _startValue = startValue; }
HostDataType StartValue() { return _startValue; }
void LocalMemory(bool local) { _localMemory = local; }
void SetLocalMemory(bool local) { _localMemory = local; }
bool LocalMemory() { return _localMemory; }
void DeclaredInProgram(bool declaredInProgram)
{
@@ -781,6 +787,8 @@ CBasicTest<HostAtomicType, HostDataType>::PragmaHeader(cl_device_id deviceID)
}
if (_dataType == TYPE_ATOMIC_DOUBLE)
pragma += "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n";
if (_dataType == TYPE_ATOMIC_HALF)
pragma += "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
return pragma;
}