mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Copyright (c) 2024 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
@@ -14,8 +14,11 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "harness/testHarness.h"
|
||||
#include "harness/deviceInfo.h"
|
||||
#include "harness/kernelHelpers.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "CL/cl_half.h"
|
||||
|
||||
bool gHost = false; // flag for testing native host threads (test verification)
|
||||
bool gOldAPI = false; // flag for testing with old API (OpenCL 1.2) - test verification
|
||||
@@ -28,6 +31,9 @@ int gInternalIterations = 10000; // internal test iterations for atomic operatio
|
||||
int gMaxDeviceThreads = 1024; // maximum number of threads executed on OCL device
|
||||
cl_device_atomic_capabilities gAtomicMemCap,
|
||||
gAtomicFenceCap; // atomic memory and fence capabilities for this device
|
||||
cl_half_rounding_mode gHalfRoundingMode = CL_HALF_RTE;
|
||||
bool gFloatAtomicsSupported = false;
|
||||
cl_device_fp_atomic_capabilities_ext gHalfAtomicCaps = 0;
|
||||
|
||||
test_status InitCL(cl_device_id device) {
|
||||
auto version = get_device_cl_version(device);
|
||||
@@ -123,6 +129,34 @@ test_status InitCL(cl_device_id device) {
|
||||
| CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES;
|
||||
}
|
||||
|
||||
if (is_extension_available(device, "cl_ext_float_atomics"))
|
||||
{
|
||||
gFloatAtomicsSupported = true;
|
||||
if (is_extension_available(device, "cl_khr_fp16"))
|
||||
{
|
||||
cl_int error = clGetDeviceInfo(
|
||||
device, CL_DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT,
|
||||
sizeof(gHalfAtomicCaps), &gHalfAtomicCaps, nullptr);
|
||||
test_error_ret(error, "clGetDeviceInfo failed!", TEST_FAIL);
|
||||
|
||||
const cl_device_fp_config fpConfigHalf =
|
||||
get_default_rounding_mode(device, CL_DEVICE_HALF_FP_CONFIG);
|
||||
if ((fpConfigHalf & CL_FP_ROUND_TO_NEAREST) != 0)
|
||||
{
|
||||
gHalfRoundingMode = CL_HALF_RTE;
|
||||
}
|
||||
else if ((fpConfigHalf & CL_FP_ROUND_TO_ZERO) != 0)
|
||||
{
|
||||
gHalfRoundingMode = CL_HALF_RTZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("Error while acquiring half rounding mode\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user