Change Behaviour of C11 Atomic Tests for OpenCL-3.0 (#944)

* Change setup code in `KernelCode()` to use `_explicit` builtin
variants that are common to both OpenCL-2.X and OpenCL-3.0.

* Only test optional supported builtin variants (`_explicit` signature
 memory_order/scope) for OpenCL-3.0.

* Disable program scope global variable and generic address space tests
for a OpenCL-3.0 driver which does not optionally support these
features.
This commit is contained in:
Jack Frankland
2020-09-22 18:08:32 +02:00
committed by GitHub
parent f7a0936879
commit 9178524d02
5 changed files with 179 additions and 48 deletions

View File

@@ -206,3 +206,77 @@ template<> cl_long AtomicTypeExtendedInfo<cl_long>::MaxValue() {return CL_LONG_M
template<> cl_ulong AtomicTypeExtendedInfo<cl_ulong>::MaxValue() {return CL_ULONG_MAX;}
template<> cl_float AtomicTypeExtendedInfo<cl_float>::MaxValue() {return CL_FLT_MAX;}
template<> cl_double AtomicTypeExtendedInfo<cl_double>::MaxValue() {return CL_DBL_MAX;}
cl_int getSupportedMemoryOrdersAndScopes(
cl_device_id device, std::vector<TExplicitMemoryOrderType> &memoryOrders,
std::vector<TExplicitMemoryScopeType> &memoryScopes)
{
// The CL_DEVICE_ATOMIC_MEMORY_CAPABILITES is missing before 3.0, but since
// all orderings and scopes are required for 2.X devices and this test is
// skipped before 2.0 we can safely return all orderings and scopes if the
// device is 2.X. Query device for the supported orders.
if (get_device_cl_version(device) < Version{ 3, 0 })
{
memoryOrders.push_back(MEMORY_ORDER_EMPTY);
memoryOrders.push_back(MEMORY_ORDER_RELAXED);
memoryOrders.push_back(MEMORY_ORDER_ACQUIRE);
memoryOrders.push_back(MEMORY_ORDER_RELEASE);
memoryOrders.push_back(MEMORY_ORDER_ACQ_REL);
memoryOrders.push_back(MEMORY_ORDER_SEQ_CST);
memoryScopes.push_back(MEMORY_SCOPE_EMPTY);
memoryScopes.push_back(MEMORY_SCOPE_WORK_GROUP);
memoryScopes.push_back(MEMORY_SCOPE_DEVICE);
memoryScopes.push_back(MEMORY_SCOPE_ALL_SVM_DEVICES);
return CL_SUCCESS;
}
// For a 3.0 device we can query the supported orderings and scopes
// directly.
cl_device_atomic_capabilities atomic_capabilities{};
test_error(
clGetDeviceInfo(device, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES,
sizeof(atomic_capabilities), &atomic_capabilities,
nullptr),
"clGetDeviceInfo failed for CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES\n");
// Provided we succeeded, we can start filling the vectors.
if (atomic_capabilities & CL_DEVICE_ATOMIC_ORDER_RELAXED)
{
memoryOrders.push_back(MEMORY_ORDER_RELAXED);
}
if (atomic_capabilities & CL_DEVICE_ATOMIC_ORDER_ACQ_REL)
{
memoryOrders.push_back(MEMORY_ORDER_ACQUIRE);
memoryOrders.push_back(MEMORY_ORDER_RELEASE);
memoryOrders.push_back(MEMORY_ORDER_ACQ_REL);
}
if (atomic_capabilities & CL_DEVICE_ATOMIC_ORDER_SEQ_CST)
{
// The functions not ending in explicit have the same semantics as the
// corresponding explicit function with memory_order_seq_cst for the
// memory_order argument.
memoryOrders.push_back(MEMORY_ORDER_EMPTY);
memoryOrders.push_back(MEMORY_ORDER_SEQ_CST);
}
if (atomic_capabilities & CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP)
{
memoryScopes.push_back(MEMORY_SCOPE_WORK_GROUP);
}
if (atomic_capabilities & CL_DEVICE_ATOMIC_SCOPE_DEVICE)
{
// The functions that do not have memory_scope argument have the same
// semantics as the corresponding functions with the memory_scope
// argument set to memory_scope_device.
memoryScopes.push_back(MEMORY_SCOPE_EMPTY);
memoryScopes.push_back(MEMORY_SCOPE_DEVICE);
}
if (atomic_capabilities & CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES)
{
memoryScopes.push_back(MEMORY_SCOPE_ALL_SVM_DEVICES);
}
return CL_SUCCESS;
}