From 9f63decb9c85875c3f285005a508037233f530b9 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Thu, 13 Feb 2025 16:24:51 +0100 Subject: [PATCH 01/36] basic: add missing newline at end of error messages (#2275) Signed-off-by: Sven van Haastregt --- test_conformance/basic/main.cpp | 2 +- test_conformance/basic/test_progvar.cpp | 2 +- test_conformance/basic/test_work_item_functions.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test_conformance/basic/main.cpp b/test_conformance/basic/main.cpp index e89b2747..988bb6f5 100644 --- a/test_conformance/basic/main.cpp +++ b/test_conformance/basic/main.cpp @@ -177,7 +177,7 @@ test_status InitCL(cl_device_id device) } else { - log_error("Error while acquiring half rounding mode"); + log_error("Error while acquiring half rounding mode\n"); return TEST_FAIL; } } diff --git a/test_conformance/basic/test_progvar.cpp b/test_conformance/basic/test_progvar.cpp index 00e1dec1..a18925c3 100644 --- a/test_conformance/basic/test_progvar.cpp +++ b/test_conformance/basic/test_progvar.cpp @@ -1100,7 +1100,7 @@ static int check_global_initialization(cl_context context, cl_program program, test_error_ret(status, "Failed to read buffer from device", status); if (is_init_valid == 0) { - log_error("Unexpected default values were detected"); + log_error("Unexpected default values were detected\n"); return 1; } diff --git a/test_conformance/basic/test_work_item_functions.cpp b/test_conformance/basic/test_work_item_functions.cpp index 6c2b436f..52d789b8 100644 --- a/test_conformance/basic/test_work_item_functions.cpp +++ b/test_conformance/basic/test_work_item_functions.cpp @@ -526,7 +526,7 @@ struct TestWorkItemFnsOutOfRange // Validate if (!Validate(dim)) { - log_error("Validation failed"); + log_error("Validation failed\n"); return TEST_FAIL; } } From 9b247c06be3706ba69f26d2849154c8b16239014 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 18 Feb 2025 09:09:17 -0800 Subject: [PATCH 02/36] fix several compile issues with Visual Studio toolchains (#2219) Fixes several compile issues I am seeing for my version of Visual Studio related to an ambiguous call to `fpclassify`, which is called by `isnan` and other similar functions, specifically for the `cl_half` type: ``` 19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(401,1): error C2668: 'fpclassify': ambiguous call to overloaded function 19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(298,31): message : could be 'int fpclassify(long double) throw()' 19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(293,31): message : or 'int fpclassify(double) throw()' 19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(288,31): message : or 'int fpclassify(float) throw()' 19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(401,1): message : while trying to match the argument list '(_Ty)' ``` Some of these issues seem like differences in compiler behavior, but at least one appears to have identified a legitimate bug. Specifically, this change: * Removes the special-case checks for finite half numbers for commonfns, since this is already handled by `UlpFn`. (test with: `test_commonfns degrees radians`) * Assigns to temporary variables to eliminate the ambiguous function call for relationals. (test with: `test_relationals relational*`) * Properly converts from half to float when checking for NaNs for select. This is the one that seems like a legitimate bug. (test with: `test_select select_half_ushort select_half_short`) * Uses `std::enable_if` to disambiguate a function call for spirv_new. (test with: `test_spirv_new decorate_saturated*`) If it's helpful, my specific Visual Studio version is: ``` Microsoft Visual Studio Professional 2019 Version 16.11.20 VisualStudio.16.Release/16.11.20+32929.386 ``` I also have the Windows Software Development Kit 10.0.19041.685 installed. --- test_conformance/commonfns/test_base.h | 21 ---------- test_conformance/commonfns/test_unary_fn.cpp | 8 ---- .../relationals/test_comparisons_fp.cpp | 5 ++- test_conformance/select/util_select.cpp | 22 ++++++---- test_conformance/spirv_new/test_decorate.cpp | 41 +++++++++++-------- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/test_conformance/commonfns/test_base.h b/test_conformance/commonfns/test_base.h index bcce3ba4..ef394635 100644 --- a/test_conformance/commonfns/test_base.h +++ b/test_conformance/commonfns/test_base.h @@ -182,27 +182,6 @@ template inline half conv_to_half(const T &val) return 0; } -template bool isfinite_fp(const T &v) -{ - if (std::is_same::value) - { - // Extract FP16 exponent and mantissa - uint16_t h_exp = (((half)v) >> (CL_HALF_MANT_DIG - 1)) & 0x1F; - uint16_t h_mant = ((half)v) & 0x3FF; - - // !Inf test - return !(h_exp == 0x1F && h_mant == 0); - } - else - { -#if !defined(_WIN32) - return std::isfinite(v); -#else - return isfinite(v); -#endif - } -} - template float UlpFn(const T &val, const double &r) { if (std::is_same::value) diff --git a/test_conformance/commonfns/test_unary_fn.cpp b/test_conformance/commonfns/test_unary_fn.cpp index 23b665a4..6515adf7 100644 --- a/test_conformance/commonfns/test_unary_fn.cpp +++ b/test_conformance/commonfns/test_unary_fn.cpp @@ -65,10 +65,6 @@ int verify_degrees(const T *const inptr, const T *const outptr, int n) { r = (180.0 / M_PI) * conv_to_dbl(inptr[i]); - if (std::is_same::value) - if (!isfinite_fp(conv_to_half(r)) && !isfinite_fp(outptr[i])) - continue; - error = UlpFn(outptr[i], r); if (fabsf(error) > max_error) @@ -115,10 +111,6 @@ int verify_radians(const T *const inptr, const T *const outptr, int n) { r = (M_PI / 180.0) * conv_to_dbl(inptr[i]); - if (std::is_same::value) - if (!isfinite_fp(conv_to_half(r)) && !isfinite_fp(outptr[i])) - continue; - error = UlpFn(outptr[i], r); if (fabsf(error) > max_error) diff --git a/test_conformance/relationals/test_comparisons_fp.cpp b/test_conformance/relationals/test_comparisons_fp.cpp index 6c4890d7..14b1696f 100644 --- a/test_conformance/relationals/test_comparisons_fp.cpp +++ b/test_conformance/relationals/test_comparisons_fp.cpp @@ -368,8 +368,9 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize, { if (gInfNanSupport == 0) { - if (isnan(inDataA[i * vecSize + j]) - || isnan(inDataB[i * vecSize + j])) + float a = inDataA[i * vecSize + j]; + float b = inDataB[i * vecSize + j]; + if (isnan(a) || isnan(b)) fail = 0; else fail = 1; diff --git a/test_conformance/select/util_select.cpp b/test_conformance/select/util_select.cpp index 078ff64a..a685b7f6 100644 --- a/test_conformance/select/util_select.cpp +++ b/test_conformance/select/util_select.cpp @@ -18,6 +18,7 @@ #include #include #include "test_select.h" +#include "CL/cl_half.h" //----------------------------------------- @@ -830,10 +831,12 @@ size_t check_half(const void *const test, const void *const correct, if (memcmp(t, c, count * sizeof(c[0])) != 0) { - for (i = 0; i < count; i++) /* Allow nans to be binary different */ - if ((t[i] != c[i]) - && !(isnan(((cl_half *)correct)[i]) - && isnan(((cl_half *)test)[i]))) + // Allow nans to be binary different + for (i = 0; i < count; i++) + { + float fcorrect = cl_half_to_float(c[i]); + float ftest = cl_half_to_float(t[i]); + if ((t[i] != c[i]) && !(isnan(fcorrect) && isnan(ftest))) { log_error("\n(check_half) Error for vector size %zu found at " "0x%8.8zx (of 0x%8.8zx): " @@ -841,6 +844,7 @@ size_t check_half(const void *const test, const void *const correct, vector_size, i, count, c[i], t[i]); return i + 1; } + } } return 0; @@ -855,9 +859,12 @@ size_t check_float(const void *const test, const void *const correct, if (memcmp(t, c, count * sizeof(c[0])) != 0) { - for (i = 0; i < count; i++) /* Allow nans to be binary different */ - if ((t[i] != c[i]) - && !(isnan(((float *)correct)[i]) && isnan(((float *)test)[i]))) + // Allow nans to be binary different + for (i = 0; i < count; i++) + { + float fcorrect = ((float *)correct)[i]; + float ftest = ((float *)test)[i]; + if ((t[i] != c[i]) && !(isnan(fcorrect) && isnan(ftest))) { log_error("\n(check_float) Error for vector size %zu found at " "0x%8.8zx (of 0x%8.8zx): " @@ -865,6 +872,7 @@ size_t check_float(const void *const test, const void *const correct, vector_size, i, count, c[i], t[i]); return i + 1; } + } } return 0; diff --git a/test_conformance/spirv_new/test_decorate.cpp b/test_conformance/spirv_new/test_decorate.cpp index b1168fe0..fc9fc522 100644 --- a/test_conformance/spirv_new/test_decorate.cpp +++ b/test_conformance/spirv_new/test_decorate.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -216,29 +217,37 @@ static inline Ti generate_saturated_rhs_input(RandomSeed &seed) } template -static inline To compute_saturated_output(Ti lhs, Ti rhs, - cl_half_rounding_mode half_rounding) +static inline + typename std::enable_if::value, To>::type + compute_saturated_output(Ti lhs, Ti rhs, + cl_half_rounding_mode half_rounding) { constexpr auto loVal = std::numeric_limits::min(); constexpr auto hiVal = std::numeric_limits::max(); - if (std::is_same::value) + cl_float f = cl_half_to_float(lhs) * cl_half_to_float(rhs); + + // Quantize to fp16: + f = cl_half_to_float(cl_half_from_float(f, half_rounding)); + + To val = static_cast(std::min(std::max(f, loVal), hiVal)); + if (isnan(cl_half_to_float(rhs))) { - cl_float f = cl_half_to_float(lhs) * cl_half_to_float(rhs); - - // Quantize to fp16: - f = cl_half_to_float(cl_half_from_float(f, half_rounding)); - - To val = (To)std::min(std::max(f, loVal), hiVal); - if (isnan(cl_half_to_float(rhs))) - { - val = 0; - } - return val; + val = 0; } + return val; +} - Tl ival = (Tl)(lhs * rhs); - To val = (To)std::min(std::max(ival, loVal), hiVal); +template +static inline + typename std::enable_if::value, To>::type + compute_saturated_output(Ti lhs, Ti rhs, cl_half_rounding_mode) +{ + constexpr auto loVal = std::numeric_limits::min(); + constexpr auto hiVal = std::numeric_limits::max(); + + Tl ival = static_cast(lhs * rhs); + To val = static_cast(std::min(std::max(ival, loVal), hiVal)); if (isnan(rhs)) { From 9c5999bc1dcc9818f505be01202efb3a6b6b1665 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 18 Feb 2025 09:10:09 -0800 Subject: [PATCH 03/36] add SPIR-V 1.6 testing for Nontemporal Image Operand (#2249) Adds a basic test for reading from and writing to an image with the optional Nontemporal image operand. --- test_conformance/spirv_new/CMakeLists.txt | 1 + .../spv1.6/image_operand_nontemporal.spvasm32 | 30 +++++++ .../spv1.6/image_operand_nontemporal.spvasm64 | 30 +++++++ test_conformance/spirv_new/test_spirv_16.cpp | 84 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm32 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm64 create mode 100644 test_conformance/spirv_new/test_spirv_16.cpp diff --git a/test_conformance/spirv_new/CMakeLists.txt b/test_conformance/spirv_new/CMakeLists.txt index c635e924..13a258e5 100644 --- a/test_conformance/spirv_new/CMakeLists.txt +++ b/test_conformance/spirv_new/CMakeLists.txt @@ -30,6 +30,7 @@ set(${MODULE_NAME}_SOURCES test_op_vector_times_scalar.cpp test_spirv_14.cpp test_spirv_15.cpp + test_spirv_16.cpp ) set(TEST_HARNESS_SOURCES diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm32 new file mode 100644 index 00000000..c6c8eaac --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm32 @@ -0,0 +1,30 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "read_write_image_nontemporal" + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %read_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly +%write_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly + %sampler_t = OpTypeSampler + %kernel_sig = OpTypeFunction %void %read_image2d_t %write_image2d_t +%sampledimage_t = OpTypeSampledImage %read_image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 + %kernel = OpFunction %void None %kernel_sig + %src = OpFunctionParameter %read_image2d_t + %dst = OpFunctionParameter %write_image2d_t + %entry = OpLabel + %si = OpSampledImage %sampledimage_t %src %sampler + %data = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod|Nontemporal %float_0 + OpImageWrite %dst %coord_0_0 %data Nontemporal + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm64 new file mode 100644 index 00000000..1b9d91aa --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/image_operand_nontemporal.spvasm64 @@ -0,0 +1,30 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "read_write_image_nontemporal" + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %read_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly +%write_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly + %sampler_t = OpTypeSampler + %kernel_sig = OpTypeFunction %void %read_image2d_t %write_image2d_t +%sampledimage_t = OpTypeSampledImage %read_image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 + %kernel = OpFunction %void None %kernel_sig + %src = OpFunctionParameter %read_image2d_t + %dst = OpFunctionParameter %write_image2d_t + %entry = OpLabel + %si = OpSampledImage %sampledimage_t %src %sampler + %data = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod|Nontemporal %float_0 + OpImageWrite %dst %coord_0_0 %data Nontemporal + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/test_spirv_16.cpp b/test_conformance/spirv_new/test_spirv_16.cpp new file mode 100644 index 00000000..169a2cb7 --- /dev/null +++ b/test_conformance/spirv_new/test_spirv_16.cpp @@ -0,0 +1,84 @@ +// +// Copyright (c) 2025 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "testBase.h" +#include "spirvInfo.hpp" +#include "types.hpp" + +#include +#include + +REGISTER_TEST(spirv16_image_operand_nontemporal) +{ + if (!is_spirv_version_supported(device, "SPIR-V_1.6")) + { + log_info("SPIR-V 1.6 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il(prog, device, context, + "spv1.6/image_operand_nontemporal"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = + clCreateKernel(prog, "read_write_image_nontemporal", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + cl_image_format image_format = { + CL_RGBA, + CL_FLOAT, + }; + + std::vector imgData({ 1.0f, 2.0f, -1.0f, 128.0f }); + clMemWrapper src = + clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, + &image_format, 1, 1, 0, imgData.data(), &error); + SPIRV_CHECK_ERROR(error, "Failed to create src image"); + + std::vector h_dst({ 0, 0, 0, 0 }); + clMemWrapper dst = + clCreateImage2D(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, + &image_format, 1, 1, 0, h_dst.data(), &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst image"); + + error |= clSetKernelArg(kernel, 0, sizeof(src), &src); + error |= clSetKernelArg(kernel, 1, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + const size_t origin[] = { 0, 0, 0 }; + const size_t region[] = { 1, 1, 1 }; + error = clEnqueueReadImage(queue, dst, CL_TRUE, origin, region, 0, 0, + h_dst.data(), 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination image"); + + if (h_dst != imgData) + { + log_error("Mismatch! Got: %f, %f, %f, %f, Wanted: %f, %f, %f, %f\n", + h_dst[0], h_dst[1], h_dst[2], h_dst[3], imgData[0], + imgData[1], imgData[2], imgData[3]); + return TEST_FAIL; + } + + return TEST_PASS; +} From ea934a764855ba3179e06593ba2b0dba5facfb2f Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 18 Feb 2025 18:11:32 +0100 Subject: [PATCH 04/36] basic: fix size_t Wformat warnings (#2264) Printing of a `size_t` requires the `%zu` specifier. Signed-off-by: Sven van Haastregt --- test_conformance/basic/test_async_copy2D.cpp | 6 +- test_conformance/basic/test_async_copy3D.cpp | 6 +- .../basic/test_bufferreadwriterect.cpp | 59 ++++++++++--------- test_conformance/basic/test_constant.cpp | 4 +- .../basic/test_global_work_offsets.cpp | 51 ++++++++++------ .../basic/test_imagearraycopy.cpp | 2 +- test_conformance/basic/test_imagedim.cpp | 16 ++--- test_conformance/basic/test_local.cpp | 8 +-- .../basic/test_local_kernel_scope.cpp | 7 ++- .../basic/test_simple_image_pitch.cpp | 15 +++-- test_conformance/basic/test_sizeof.cpp | 20 ++++--- 11 files changed, 113 insertions(+), 81 deletions(-) diff --git a/test_conformance/basic/test_async_copy2D.cpp b/test_conformance/basic/test_async_copy2D.cpp index eab9a35f..0cbfe779 100644 --- a/test_conformance/basic/test_async_copy2D.cpp +++ b/test_conformance/basic/test_async_copy2D.cpp @@ -120,7 +120,7 @@ int test_copy2D(const cl_device_id deviceID, const cl_context context, { int error; - log_info("Testing %d byte element with srcMargin = %d, dstMargin = %d\n", + log_info("Testing %zu byte element with srcMargin = %d, dstMargin = %d\n", elementSize, srcMargin, dstMargin); cl_long max_local_mem_size; @@ -235,8 +235,8 @@ int test_copy2D(const cl_device_id deviceID, const cl_context context, if ((localBufferSize / 4) > max_work_group_size) { - log_info("Skipping due to resource requirements local:%db " - "max_work_group_size:%d\n", + log_info("Skipping due to resource requirements local:%zub " + "max_work_group_size:%zu\n", localBufferSize, max_work_group_size); return 0; } diff --git a/test_conformance/basic/test_async_copy3D.cpp b/test_conformance/basic/test_async_copy3D.cpp index 976141b9..f4641d63 100644 --- a/test_conformance/basic/test_async_copy3D.cpp +++ b/test_conformance/basic/test_async_copy3D.cpp @@ -133,7 +133,7 @@ int test_copy3D(const cl_device_id deviceID, const cl_context context, int error; log_info( - "Testing %d byte element with srcLineMargin = %d, dstLineMargin = %d, " + "Testing %zu byte element with srcLineMargin = %d, dstLineMargin = %d, " "srcPlaneMargin = %d, dstPlaneMargin = %d\n", elementSize, srcLineMargin, dstLineMargin, srcPlaneMargin, dstPlaneMargin); @@ -255,8 +255,8 @@ int test_copy3D(const cl_device_id deviceID, const cl_context context, if ((localBufferSize / 4) > max_work_group_size) { - log_info("Skipping due to resource requirements local:%db " - "max_work_group_size:%d\n", + log_info("Skipping due to resource requirements local:%zub " + "max_work_group_size:%zu\n", localBufferSize, max_work_group_size); return 0; } diff --git a/test_conformance/basic/test_bufferreadwriterect.cpp b/test_conformance/basic/test_bufferreadwriterect.cpp index bd813807..0a12bf79 100644 --- a/test_conformance/basic/test_bufferreadwriterect.cpp +++ b/test_conformance/basic/test_bufferreadwriterect.cpp @@ -72,7 +72,7 @@ static void initialize_image(BufferType* ptr, size_t w, size_t h, size_t d, MTda // This function prints the contents of a buffer to standard error. void print_buffer(BufferType* buf, size_t w, size_t h, size_t d) { - log_error("Size = %lux%lux%lu (%lu total)\n",w,h,d,w*h*d); + log_error("Size = %zux%zux%zu (%zu total)\n", w, h, d, w * h * d); for (unsigned k=0; k!=d;++k) { log_error("Slice: %u\n",k); for (unsigned j=0; j!=h;++j) { @@ -218,7 +218,9 @@ int verify_region(BufferType* device, size_t src, size_t soffset[3], size_t sreg size_t d_idx = (doffset[2]+sz)*dslice + (doffset[1]+sy)*dpitch + doffset[0]+sx; if (device[d_idx] != verify[src][s_idx]) { - log_error("Verify failed on comparsion %lu: coordinate (%lu, %lu, %lu) of region\n",i,sx,sy,sz); + log_error("Verify failed on comparsion %zu: coordinate (%zu, %zu, " + "%zu) of region\n", + i, sx, sy, sz); log_error("0x%02x != 0x%02x\n", device[d_idx], verify[src][s_idx]); #if 0 // Uncomment this section to print buffers. @@ -369,7 +371,7 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que max_mem_alloc_dim = max_mem_alloc_size; } - log_info("Using maximum dimension = %lu.\n", max_mem_alloc_dim); + log_info("Using maximum dimension = %zu.\n", max_mem_alloc_dim); // Create pairs of cl buffers and host buffers on which operations will be mirrored. log_info("Creating %u pairs of random sized host and cl buffers.\n", TotalImages); @@ -392,7 +394,8 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que // Check to see if adequately sized buffers were found. if (tries >= max_tries) { - log_error("Error: Could not find random buffer sized less than %llu bytes in %lu tries.\n", + log_error("Error: Could not find random buffer sized less than " + "%llu bytes in %zu tries.\n", max_mem_alloc_size, max_tries); return -1; } @@ -401,10 +404,11 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que max_size = (size_bytes > max_size) ? size_bytes : max_size; total_bytes += size_bytes; - log_info("Buffer[%u] is (%lu,%lu,%lu) = %lu MB (truncated)\n",i,width[i],height[i],depth[i],(size_bytes)/1048576); + log_info("Buffer[%u] is (%zu,%zu,%zu) = %zu MB (truncated)\n", i, + width[i], height[i], depth[i], (size_bytes) / 1048576); } - log_info( "Total size: %lu MB (truncated)\n", total_bytes/1048576 ); + log_info("Total size: %zu MB (truncated)\n", total_bytes / 1048576); // Allocate a temporary buffer for read and write operations. tmp_buffer_size = max_size; @@ -491,32 +495,32 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que switch (operation) { case 0: - log_info("%lu Copy %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n", - iter, - src, soffset[0], soffset[1], soffset[2], - dst, doffset[0], doffset[1], doffset[2], - sregion[0], sregion[1], sregion[2], - sregion[0]*sregion[1]*sregion[2]); + log_info("%zu Copy %zu offset (%zu,%zu,%zu) -> %zu offset " + "(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n", + iter, src, soffset[0], soffset[1], soffset[2], dst, + doffset[0], doffset[1], doffset[2], sregion[0], + sregion[1], sregion[2], + sregion[0] * sregion[1] * sregion[2]); if ((err = copy_region(src, soffset, sregion, dst, doffset, dregion))) return err; break; case 1: - log_info("%lu Read %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n", - iter, - src, soffset[0], soffset[1], soffset[2], - dst, doffset[0], doffset[1], doffset[2], - sregion[0], sregion[1], sregion[2], - sregion[0]*sregion[1]*sregion[2]); + log_info("%zu Read %zu offset (%zu,%zu,%zu) -> %zu offset " + "(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n", + iter, src, soffset[0], soffset[1], soffset[2], dst, + doffset[0], doffset[1], doffset[2], sregion[0], + sregion[1], sregion[2], + sregion[0] * sregion[1] * sregion[2]); if ((err = read_verify_region(src, soffset, sregion, dst, doffset, dregion))) return err; break; case 2: - log_info("%lu Write %lu offset (%lu,%lu,%lu) -> %lu offset (%lu,%lu,%lu) region (%lux%lux%lu = %lu)\n", - iter, - src, soffset[0], soffset[1], soffset[2], - dst, doffset[0], doffset[1], doffset[2], - sregion[0], sregion[1], sregion[2], - sregion[0]*sregion[1]*sregion[2]); + log_info("%zu Write %zu offset (%zu,%zu,%zu) -> %zu offset " + "(%zu,%zu,%zu) region (%zux%zux%zu = %zu)\n", + iter, src, soffset[0], soffset[1], soffset[2], dst, + doffset[0], doffset[1], doffset[2], sregion[0], + sregion[1], sregion[2], + sregion[0] * sregion[1] * sregion[2]); if ((err = write_region(src, soffset, sregion, dst, doffset, dregion))) return err; break; @@ -526,11 +530,11 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que // Uncomment this section to verify each operation. // If commented out, verification won't occur until the end of the // test, and it will not be possible to determine which operation failed. - log_info("Verify src %lu offset (%u,%u,%u) region (%lux%lux%lu)\n", src, 0, 0, 0, width[src], height[src], depth[src]); + log_info("Verify src %zu offset (%u,%u,%u) region (%zux%zux%zu)\n", src, 0, 0, 0, width[src], height[src], depth[src]); if (err = map_verify_region(src)) return err; - log_info("Verify dst %lu offset (%u,%u,%u) region (%lux%lux%lu)\n", dst, 0, 0, 0, width[dst], height[dst], depth[dst]); + log_info("Verify dst %zu offset (%u,%u,%u) region (%zux%zux%zu)\n", dst, 0, 0, 0, width[dst], height[dst], depth[dst]); if (err = map_verify_region(dst)) return err; @@ -540,7 +544,8 @@ test_bufferreadwriterect(cl_device_id device, cl_context context, cl_command_que } // end main for loop. for (unsigned i=0;i= (cl_int)m ) || ( v < 0 ) ) \ - { \ - log_error( "ERROR: ouputID_%c[%lu]: %d is < 0 or >= %lu\n", c, i, v, m ); \ - return -1; \ +#define CHECK_RANGE(v, m, c) \ + if ((v >= (cl_int)m) || (v < 0)) \ + { \ + log_error("ERROR: ouputID_%c[%zu]: %d is < 0 or >= %zu\n", c, i, v, \ + m); \ + return -1; \ } int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int outputB[], cl_int outputC[] ) @@ -76,13 +77,17 @@ int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int if( counts[ x ][ y ][ z ] < 1 ) { if( missed < 3 ) - log_error( "ERROR: Map value (%ld,%ld,%ld) was missed%s\n", x, y, z, ( missed == 2 ) ? limitMsg : "" ); + log_error( + "ERROR: Map value (%zu,%zu,%zu) was missed%s\n", + x, y, z, (missed == 2) ? limitMsg : ""); missed++; } else if( counts[ x ][ y ][ z ] > 1 ) { if( multiple < 3 ) - log_error( "ERROR: Map value (%ld,%ld,%ld) was returned multiple times%s\n", x, y, z, ( multiple == 2 ) ? limitMsg : "" ); + log_error("ERROR: Map value (%zu,%zu,%zu) was " + "returned multiple times%s\n", + x, y, z, (multiple == 2) ? limitMsg : ""); multiple++; } } @@ -91,7 +96,9 @@ int check_results( size_t threads[], size_t offsets[], cl_int outputA[], cl_int if( counts[ x ][ y ][ z ] > 0 ) { if( errored < 3 ) - log_error( "ERROR: Map value (%ld,%ld,%ld) was erroneously returned%s\n", x, y, z, ( errored == 2 ) ? limitMsg : "" ); + log_error("ERROR: Map value (%zu,%zu,%zu) was " + "erroneously returned%s\n", + x, y, z, (errored == 2) ? limitMsg : ""); errored++; } } @@ -161,9 +168,11 @@ int test_global_work_offsets(cl_device_id deviceID, cl_context context, cl_comma for( int j = 0; j < 3; j++ ) offsets[ j ] = random_in_range( 0, MAX_OFFSET, seed ); - log_info( "\tTesting %ld,%ld,%ld (%ld,%ld,%ld) with offsets (%ld,%ld,%ld)...\n", - threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ], - offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] ); + log_info("\tTesting %zu,%zu,%zu (%zu,%zu,%zu) with offsets " + "(%zu,%zu,%zu)...\n", + threads[0], threads[1], threads[2], localThreads[0], + localThreads[1], localThreads[2], offsets[0], offsets[1], + offsets[2]); // Now set up and run for( int i = 0; i < 3; i++ ) @@ -187,9 +196,11 @@ int test_global_work_offsets(cl_device_id deviceID, cl_context context, cl_comma // but they won't be in order, so we need to construct a count map to determine what we got if( check_results( threads, offsets, outputA, outputB, outputC ) ) { - log_error( "\t(Test failed for global dim %ld,%ld,%ld, local dim %ld,%ld,%ld, offsets %ld,%ld,%ld)\n", - threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ], - offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] ); + log_error("\t(Test failed for global dim %zu,%zu,%zu, local dim " + "%zu,%zu,%zu, offsets %zu,%zu,%zu)\n", + threads[0], threads[1], threads[2], localThreads[0], + localThreads[1], localThreads[2], offsets[0], offsets[1], + offsets[2]); return -1; } } @@ -252,9 +263,11 @@ int test_get_global_offset(cl_device_id deviceID, cl_context context, cl_command for( int j = 0; j < 3; j++ ) offsets[ j ] = random_in_range( 0, MAX_OFFSET, seed ); - log_info( "\tTesting %ld,%ld,%ld (%ld,%ld,%ld) with offsets (%ld,%ld,%ld)...\n", - threads[ 0 ], threads[ 1 ], threads[ 2 ], localThreads[ 0 ], localThreads[ 1 ], localThreads[ 2 ], - offsets[ 0 ], offsets[ 1 ], offsets[ 2 ] ); + log_info("\tTesting %zu,%zu,%zu (%zu,%zu,%zu) with offsets " + "(%zu,%zu,%zu)...\n", + threads[0], threads[1], threads[2], localThreads[0], + localThreads[1], localThreads[2], offsets[0], offsets[1], + offsets[2]); // Now set up and run error = clSetKernelArg( kernel, 0, sizeof( streams[0] ), &streams[0] ); @@ -273,7 +286,9 @@ int test_get_global_offset(cl_device_id deviceID, cl_context context, cl_command { if( outOffsets[ j ] != (cl_int)offsets[ j ] ) { - log_error( "ERROR: get_global_offset( %d ) did not return expected value (expected %ld, got %d)\n", j, offsets[ j ], outOffsets[ j ] ); + log_error("ERROR: get_global_offset( %d ) did not return " + "expected value (expected %zu, got %d)\n", + j, offsets[j], outOffsets[j]); errors++; } } diff --git a/test_conformance/basic/test_imagearraycopy.cpp b/test_conformance/basic/test_imagearraycopy.cpp index eb784a49..0411c789 100644 --- a/test_conformance/basic/test_imagearraycopy.cpp +++ b/test_conformance/basic/test_imagearraycopy.cpp @@ -125,7 +125,7 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, { if (memcmp(&inchar[i], &outchar[i], elem_size) != 0) { - log_error("%d(0x%x) -> expected [", i, i); + log_error("%zu(0x%zx) -> expected [", i, i); for (size_t j = 0; j < elem_size; j++) log_error("0x%02x ", inchar[i + j]); log_error("] != actual ["); diff --git a/test_conformance/basic/test_imagedim.cpp b/test_conformance/basic/test_imagedim.cpp index f979aa8b..2107d4c0 100644 --- a/test_conformance/basic/test_imagedim.cpp +++ b/test_conformance/basic/test_imagedim.cpp @@ -68,7 +68,7 @@ int get_max_image_dimensions(cl_device_id device, size_t &max_img_width, nullptr); test_error(err, "clGetDeviceInfo for CL_DEVICE_IMAGE2D_MAX_HEIGHT failed"); - log_info("Device reported max image sizes of %lu x %lu, and max mem size " + log_info("Device reported max image sizes of %zu x %zu, and max mem size " "of %gMB.\n", max_image2d_width, max_image2d_height, max_mem_size / (1024.0 * 1024.0)); @@ -98,7 +98,7 @@ int get_max_image_dimensions(cl_device_id device, size_t &max_img_width, max_img_width = std::min(max_image2d_width, max_img_dim); max_img_height = std::min(max_image2d_height, max_img_dim); - log_info("Adjusted maximum image size to test is %d x %d, which is a max " + log_info("Adjusted maximum image size to test is %zu x %zu, which is a max " "mem size of %gMB.\n", max_img_width, max_img_height, (max_img_width * max_img_height * 4) / (1024.0 * 1024.0)); @@ -147,12 +147,12 @@ int test_imagedim_common(cl_context context, cl_command_queue queue, size_t threads[] = { img_width, img_height }; if (local_threads) - log_info( - "Testing image dimensions %d x %d with local threads %d x %d.\n", - img_width, img_height, local_threads[0], local_threads[1]); + log_info("Testing image dimensions %zu x %zu with local threads %zu x " + "%zu.\n", + img_width, img_height, local_threads[0], local_threads[1]); else log_info( - "Testing image dimensions %d x %d with local threads nullptr.\n", + "Testing image dimensions %zu x %zu with local threads nullptr.\n", img_width, img_height); err = clEnqueueNDRangeKernel(queue, kernel, 2, nullptr, threads, local_threads, 0, nullptr, nullptr); @@ -165,8 +165,8 @@ int test_imagedim_common(cl_context context, cl_command_queue queue, if (0 != memcmp(input.data(), output.data(), 4 * img_width * img_height)) { total_errors++; - log_error("Image Dimension test failed. image width = %d, " - "image height = %d\n", + log_error("Image Dimension test failed. image width = %zu, " + "image height = %zu\n", img_width, img_height); } return total_errors; diff --git a/test_conformance/basic/test_local.cpp b/test_conformance/basic/test_local.cpp index 75eb5659..f0ffe81e 100644 --- a/test_conformance/basic/test_local.cpp +++ b/test_conformance/basic/test_local.cpp @@ -198,8 +198,8 @@ int test_local_arg_def(cl_device_id device, cl_context context, cl_command_queue // Adjust the local thread size to fit and be a nice multiple. if (kwgsize < wgsize) { - log_info("Adjusting wgsize down from %lu to %lu.\n", wgsize, kwgsize); - local_threads[0] = kwgsize; + log_info("Adjusting wgsize down from %zu to %zu.\n", wgsize, kwgsize); + local_threads[0] = kwgsize; } while (global_threads[0] % local_threads[0] != 0) local_threads[0]--; @@ -331,8 +331,8 @@ int test_local_kernel_def(cl_device_id device, cl_context context, cl_command_qu // Adjust the local thread size to fit and be a nice multiple. if (kwgsize < wgsize) { - log_info("Adjusting wgsize down from %lu to %lu.\n", wgsize, kwgsize); - local_threads[0] = kwgsize; + log_info("Adjusting wgsize down from %zu to %zu.\n", wgsize, kwgsize); + local_threads[0] = kwgsize; } while (global_threads[0] % local_threads[0] != 0) local_threads[0]--; diff --git a/test_conformance/basic/test_local_kernel_scope.cpp b/test_conformance/basic/test_local_kernel_scope.cpp index 57174f03..8c23c1c3 100644 --- a/test_conformance/basic/test_local_kernel_scope.cpp +++ b/test_conformance/basic/test_local_kernel_scope.cpp @@ -82,7 +82,8 @@ int test_local_kernel_scope(cl_device_id device, cl_context context, cl_command_ while( testSize < 1024 ) testSize += workGroupSize; size_t numGroups = testSize / workGroupSize; - log_info( "\tTesting with %ld groups, %ld elements per group...\n", numGroups, workGroupSize ); + log_info("\tTesting with %zu groups, %zu elements per group...\n", + numGroups, workGroupSize); // Create two buffers for operation cl_uint *inputData = (cl_uint*)malloc( testSize * sizeof(cl_uint) ); @@ -124,7 +125,9 @@ int test_local_kernel_scope(cl_device_id device, cl_context context, cl_command_ if( outputData[ i ] != localMax ) { - log_error( "ERROR: Local max validation failed! (expected %u, got %u for i=%lu)\n", localMax, outputData[ i ] , i ); + log_error("ERROR: Local max validation failed! (expected %u, got " + "%u for i=%zu)\n", + localMax, outputData[i], i); free(inputData); free(outputData); return -1; diff --git a/test_conformance/basic/test_simple_image_pitch.cpp b/test_conformance/basic/test_simple_image_pitch.cpp index 2eb43b3a..83df1699 100644 --- a/test_conformance/basic/test_simple_image_pitch.cpp +++ b/test_conformance/basic/test_simple_image_pitch.cpp @@ -69,12 +69,14 @@ int test_simple_read_image_pitch(cl_device_id device, cl_context cl_context_, cl for (size_t i=0;i=imageW*pixel_bytes) && (val != 0xa)) { - log_error("Bad value %x outside image at (byte: %lu, row: %lu)\n",val,i,j); - ++errors; + log_error("Bad value %x outside image at (byte: %zu, row: %zu)\n", + val, i, j); + ++errors; } } } @@ -136,8 +138,9 @@ int test_simple_write_image_pitch(cl_device_id device, cl_context cl_context_, c for (size_t i=0;i Date: Tue, 18 Feb 2025 18:13:01 +0100 Subject: [PATCH 05/36] spirv_new: print build log in get_program_with_il (#2274) Print the build log when building the program in `get_program_with_il` fails, to make it easier to investigate spirv_new test failures. Factor out a global helper function `OutputBuildLog` for printing the build log for a single device. Signed-off-by: Sven van Haastregt --- test_common/harness/errorHelpers.cpp | 62 ++++++++++++++++------------ test_common/harness/errorHelpers.h | 1 + test_conformance/spirv_new/main.cpp | 7 +++- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/test_common/harness/errorHelpers.cpp b/test_common/harness/errorHelpers.cpp index 63bd107c..287cb82e 100644 --- a/test_common/harness/errorHelpers.cpp +++ b/test_common/harness/errorHelpers.cpp @@ -555,6 +555,39 @@ float Ulp_Error_Double(double test, long double reference) return result; } +cl_int OutputBuildLog(cl_program program, const cl_device_id device) +{ + size_t size_ret; + + // Get the build status + cl_build_status build_status; + cl_int error = + clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(build_status), &build_status, &size_ret); + test_error(error, "Unable to query build status"); + + // If the build failed then print the status, obtain the build log and + // print it. + if (build_status != CL_BUILD_SUCCESS) + { + log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n", (int)build_status); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, + nullptr, &size_ret); + test_error(error, "Unable to query build log size"); + + char *build_log = (char *)malloc(size_ret); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, + size_ret, build_log, &size_ret); + test_error(error, "Unable to query build log"); + + log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log); + + free(build_log); + } + + return CL_SUCCESS; +} + cl_int OutputBuildLogs(cl_program program, cl_uint num_devices, cl_device_id *device_list) { @@ -594,33 +627,8 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices, unsigned int i; for (i = 0; i < num_devices; i++) { - - // Get the build status - cl_build_status build_status; - error = clGetProgramBuildInfo( - program, device_list[i], CL_PROGRAM_BUILD_STATUS, - sizeof(build_status), &build_status, &size_ret); - test_error(error, "Unable to query build status"); - - // If the build failed then log the status, and allocate the build - // log, log it and free it - if (build_status != CL_BUILD_SUCCESS) - { - - log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n", - (int)build_status); - error = clGetProgramBuildInfo(program, device_list[i], - CL_PROGRAM_BUILD_LOG, 0, NULL, - &size_ret); - test_error(error, "Unable to query build log size"); - char *build_log = (char *)malloc(size_ret); - error = clGetProgramBuildInfo(program, device_list[i], - CL_PROGRAM_BUILD_LOG, size_ret, - build_log, &size_ret); - test_error(error, "Unable to query build log"); - log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log); - free(build_log); - } + error = OutputBuildLog(program, device_list[i]); + test_error(error, "OutputBuildLog failed"); } // Was the number of devices given diff --git a/test_common/harness/errorHelpers.h b/test_common/harness/errorHelpers.h index e6d4620b..cb1a9113 100644 --- a/test_common/harness/errorHelpers.h +++ b/test_common/harness/errorHelpers.h @@ -198,6 +198,7 @@ extern const char *GetQueuePropertyName(cl_command_queue_properties properties); extern const char *GetDeviceTypeName(cl_device_type type); bool check_functions_for_offline_compiler(const char *subtestname); +cl_int OutputBuildLog(cl_program program, const cl_device_id device); cl_int OutputBuildLogs(cl_program program, cl_uint num_devices, cl_device_id *device_list); diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index e3640b12..98ce18e8 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -172,7 +172,12 @@ int get_program_with_il(clProgramWrapper &prog, const cl_device_id deviceID, } err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL); - SPIRV_CHECK_ERROR(err, "Failed to build program"); + if (err != CL_SUCCESS) + { + cl_int outputErr = OutputBuildLog(prog, deviceID); + SPIRV_CHECK_ERROR(outputErr, "OutputBuildLog failed"); + return err; + } return err; } From 24597e014595fe336c052c1fc8ef699618fd24f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 18 Feb 2025 18:52:44 +0000 Subject: [PATCH 06/36] Report external sharing tests as skipped instead of failed when not supported (#2277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Throwing an exception in the constructor for VulkanTestBase was always reported as an error. Signed-off-by: Kévin Petit --- test_conformance/vulkan/vulkan_test_base.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test_conformance/vulkan/vulkan_test_base.h b/test_conformance/vulkan/vulkan_test_base.h index d4cfa684..82b8e639 100644 --- a/test_conformance/vulkan/vulkan_test_base.h +++ b/test_conformance/vulkan/vulkan_test_base.h @@ -43,15 +43,6 @@ struct VulkanTestBase vkDevice.reset( new VulkanDevice(getAssociatedVulkanPhysicalDevice(device))); - if (!(is_extension_available(device, "cl_khr_external_memory") - && is_extension_available(device, "cl_khr_external_semaphore"))) - { - log_info("Device does not support cl_khr_external_memory " - "or cl_khr_external_semaphore\n"); - log_info(" TEST SKIPPED\n"); - throw std::runtime_error("VulkanTestBase not supported"); - } - cl_platform_id platform; cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); @@ -101,6 +92,15 @@ template int MakeAndRunTest(cl_device_id device, cl_context context, cl_command_queue queue, cl_int nelems) { + if (!(is_extension_available(device, "cl_khr_external_memory") + && is_extension_available(device, "cl_khr_external_semaphore"))) + { + log_info("Device does not support cl_khr_external_memory " + "or cl_khr_external_semaphore\n"); + log_info(" TEST SKIPPED\n"); + return TEST_SKIPPED_ITSELF; + } + if (!checkVkSupport()) { log_info("Vulkan supported GPU not found \n"); From 9216c81855c8d2e0da76bc1419be9f0f8da036fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 18 Feb 2025 18:54:03 +0000 Subject: [PATCH 07/36] Migrate test_vulkan to the new registration framework (#2278) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Petit --- test_conformance/vulkan/main.cpp | 34 +------- test_conformance/vulkan/procs.h | 79 ------------------- .../vulkan/test_vulkan_api_consistency.cpp | 23 ++---- ...st_vulkan_api_consistency_for_1dimages.cpp | 9 +-- ...st_vulkan_api_consistency_for_3dimages.cpp | 9 +-- .../vulkan/test_vulkan_interop_buffer.cpp | 64 ++++++--------- .../vulkan/test_vulkan_interop_image.cpp | 10 +-- .../test_vulkan_platform_device_info.cpp | 11 +-- 8 files changed, 50 insertions(+), 189 deletions(-) delete mode 100644 test_conformance/vulkan/procs.h diff --git a/test_conformance/vulkan/main.cpp b/test_conformance/vulkan/main.cpp index 7be31b23..d2d278da 100644 --- a/test_conformance/vulkan/main.cpp +++ b/test_conformance/vulkan/main.cpp @@ -30,35 +30,8 @@ #include #endif -#include "procs.h" #include "harness/testHarness.h" -#if !defined(_WIN32) -#include -#endif - -#define BUFFERSIZE 3000 - -test_definition test_list[] = { ADD_TEST(buffer_single_queue), - ADD_TEST(buffer_multiple_queue), - ADD_TEST(buffer_multiImport_sameCtx), - ADD_TEST(buffer_multiImport_diffCtx), - ADD_TEST(buffer_single_queue_fence), - ADD_TEST(buffer_multiple_queue_fence), - ADD_TEST(buffer_multiImport_sameCtx_fence), - ADD_TEST(buffer_multiImport_diffCtx_fence), - ADD_TEST(image_single_queue), - ADD_TEST(image_multiple_queue), - ADD_TEST(consistency_external_buffer), - ADD_TEST(consistency_external_image), - ADD_TEST(consistency_external_for_3dimage), - ADD_TEST(consistency_external_for_1dimage), - ADD_TEST(consistency_external_semaphore), - ADD_TEST(platform_info), - ADD_TEST(device_info) }; - -const int test_num = ARRAY_SIZE(test_list); - unsigned int numCQ; bool multiImport; bool multiCtx; @@ -75,9 +48,9 @@ static void printUsage(const char *execName) log_info("Usage: %s [test_names] [options]\n", execName); log_info("Test names:\n"); - for (int i = 0; i < test_num; i++) + for (int i = 0; i < test_registry::getInstance().num_tests(); i++) { - log_info("\t%s\n", test_list[i].name); + log_info("\t%s\n", test_registry::getInstance().definitions()[i].name); } log_info("\n"); log_info("Options:\n"); @@ -178,5 +151,6 @@ int main(int argc, const char *argv[]) size_t argCount = parseParams(argc, argv, argList); if (argCount == 0) return 0; - return runTestHarness(argc, argv, test_num, test_list, false, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); } diff --git a/test_conformance/vulkan/procs.h b/test_conformance/vulkan/procs.h deleted file mode 100644 index 71fad68f..00000000 --- a/test_conformance/vulkan/procs.h +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright (c) 2022 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "harness/mt19937.h" - -extern int test_vulkan_interop_buffer(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_vulkan_interop_image(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_consistency_external_buffer(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_external_image(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_external_for_3dimage(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_external_for_1dimage(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_external_semaphore(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_platform_info(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_device_info(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_buffer_single_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_); -extern int test_buffer_multiple_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_multiImport_sameCtx(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_multiImport_diffCtx(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_single_queue_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_multiple_queue_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_multiImport_sameCtx_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_buffer_multiImport_diffCtx_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_); -extern int test_image_single_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_); -extern int test_image_multiple_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_); diff --git a/test_conformance/vulkan/test_vulkan_api_consistency.cpp b/test_conformance/vulkan/test_vulkan_api_consistency.cpp index 06b48fb0..a148c5d3 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency.cpp @@ -503,27 +503,20 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase } // anonymous namespace -int test_consistency_external_buffer(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_consistency_external_buffer) { - return MakeAndRunTest( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest(device, context, queue, + num_elements); } -int test_consistency_external_image(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_consistency_external_image) { - return MakeAndRunTest( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest(device, context, queue, + num_elements); } -int test_consistency_external_semaphore(cl_device_id deviceID, - cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_consistency_external_semaphore) { return MakeAndRunTest( - deviceID, context, defaultQueue, num_elements); + device, context, queue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp index 346a3ce5..a90d7754 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp @@ -204,11 +204,8 @@ struct ConsistencyExternalImage1DTest : public VulkanTestBase }; } -int test_consistency_external_for_1dimage(cl_device_id deviceID, - cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_consistency_external_for_1dimage) { - return MakeAndRunTest( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest(device, context, + queue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp index 8dd9ae9a..0beb8d18 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp @@ -208,11 +208,8 @@ struct ConsistencyExternalImage3DTest : public VulkanTestBase } // anonymous namespace -int test_consistency_external_for_3dimage(cl_device_id deviceID, - cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_consistency_external_for_3dimage) { - return MakeAndRunTest( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest(device, context, + queue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index 94078031..a05dc6ed 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -1797,93 +1797,77 @@ template struct BufferCommonBufferTest : public BufferTestBase } // anonymous namespace -int test_buffer_single_queue(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_buffer_single_queue) { params_reset(); log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiple_queue(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_buffer_multiple_queue) { params_reset(); numCQ = 2; log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiImport_sameCtx(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_multiImport_sameCtx) { params_reset(); multiImport = true; log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " "IN SAME CONTEXT...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiImport_diffCtx(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_multiImport_diffCtx) { params_reset(); multiImport = true; multiCtx = true; log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " "IN DIFFERENT CONTEXT...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_single_queue_fence(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_single_queue_fence) { params_reset(); log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiple_queue_fence(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_multiple_queue_fence) { params_reset(); numCQ = 2; log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiImport_sameCtx_fence(cl_device_id deviceID, - cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_multiImport_sameCtx_fence) { params_reset(); multiImport = true; log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " "IN SAME CONTEXT...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } -int test_buffer_multiImport_diffCtx_fence(cl_device_id deviceID, - cl_context context, - cl_command_queue defaultQueue, - int num_elements) +REGISTER_TEST(test_buffer_multiImport_diffCtx_fence) { params_reset(); multiImport = true; multiCtx = true; log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " "IN DIFFERENT CONTEXT...... \n\n"); - return MakeAndRunTest>( - deviceID, context, defaultQueue, num_elements); + return MakeAndRunTest>(device, context, queue, + num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index d529f482..c2f2727d 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -1521,22 +1521,20 @@ struct ImageCommonTest : public VulkanTestBase } // anonymous namespace -int test_image_single_queue(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_image_single_queue) { params_reset(); log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return MakeAndRunTest(deviceID, context, defaultQueue, + return MakeAndRunTest(device, context, queue, num_elements); } -int test_image_multiple_queue(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_image_multiple_queue) { params_reset(); numCQ = 2; log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return MakeAndRunTest(deviceID, context, defaultQueue, + return MakeAndRunTest(device, context, queue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp index eaf963c9..c8d7410c 100644 --- a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp +++ b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp @@ -233,16 +233,13 @@ struct DeviceInfoTest : public VulkanTestBase } // anonymous namespace -int test_platform_info(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_platform_info) { - return MakeAndRunTest(deviceID, context, defaultQueue, + return MakeAndRunTest(device, context, queue, num_elements); } -int test_device_info(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(test_device_info) { - return MakeAndRunTest(deviceID, context, defaultQueue, - num_elements); + return MakeAndRunTest(device, context, queue, num_elements); } From 485964d87cfe18e5c4c8ef4388e71a5d2b3c3d69 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 19 Feb 2025 04:47:56 +0000 Subject: [PATCH 08/36] Add CMake installation rules (#2184) Add installation rules for all the binary targets. Targets are installed under `/bin/` where `` is `CMAKE_BUILD_TYPE` for single-config generators, e.g. Unix Makefiles and Ninja, or the build configuration for multi-config generators, e.g. Ninja Multi-Config and Visual Studio. This creates the target `install` on Unix and `INSTALL` on Windows. --- test_conformance/CMakeCommon.txt | 5 +++++ test_conformance/compiler/CMakeLists.txt | 7 +++++++ test_conformance/spirv_new/spirv_asm/CMakeLists.txt | 7 +++++++ test_conformance/vulkan/shaders/CMakeLists.txt | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/test_conformance/CMakeCommon.txt b/test_conformance/CMakeCommon.txt index 0beaedc2..270a923d 100644 --- a/test_conformance/CMakeCommon.txt +++ b/test_conformance/CMakeCommon.txt @@ -7,3 +7,8 @@ add_executable(${${MODULE_NAME}_OUT} ${${MODULE_NAME}_SOURCES}) set_property(TARGET ${${MODULE_NAME}_OUT} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}") TARGET_LINK_LIBRARIES(${${MODULE_NAME}_OUT} ${HARNESS_LIB} ${CLConform_LIBRARIES}) + +include(GNUInstallDirs) + +install(TARGETS ${${MODULE_NAME}_OUT} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/$) diff --git a/test_conformance/compiler/CMakeLists.txt b/test_conformance/compiler/CMakeLists.txt index e703471d..b64d3b31 100644 --- a/test_conformance/compiler/CMakeLists.txt +++ b/test_conformance/compiler/CMakeLists.txt @@ -31,3 +31,10 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_directory ${CLConform_SOURCE_DIR}/test_conformance/compiler/secondIncludeTestDirectory ${COMPILER_TEST_RESOURCES}/secondIncludeTestDirectory) + +include(GNUInstallDirs) + +install(DIRECTORY + ${CLConform_SOURCE_DIR}/test_conformance/compiler/includeTestDirectory + ${CLConform_SOURCE_DIR}/test_conformance/compiler/secondIncludeTestDirectory + DESTINATION ${CMAKE_INSTALL_BINDIR}/$) diff --git a/test_conformance/spirv_new/spirv_asm/CMakeLists.txt b/test_conformance/spirv_new/spirv_asm/CMakeLists.txt index 71ae4a9c..0e12a285 100644 --- a/test_conformance/spirv_new/spirv_asm/CMakeLists.txt +++ b/test_conformance/spirv_new/spirv_asm/CMakeLists.txt @@ -500,3 +500,10 @@ add_custom_command( VERBATIM) add_custom_target(spirv_new_binaries DEPENDS ${assembled_spirv_binaries}) + +include(GNUInstallDirs) + +install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/../spirv_bin + DESTINATION + ${CMAKE_INSTALL_BINDIR}/$) diff --git a/test_conformance/vulkan/shaders/CMakeLists.txt b/test_conformance/vulkan/shaders/CMakeLists.txt index f09dc51c..3614e1e2 100644 --- a/test_conformance/vulkan/shaders/CMakeLists.txt +++ b/test_conformance/vulkan/shaders/CMakeLists.txt @@ -44,4 +44,11 @@ else() endforeach() add_custom_target(vulkan_shaders DEPENDS ${vulkan_spirv_files}) + + include(GNUInstallDirs) + + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION + ${CMAKE_INSTALL_BINDIR}/$) endif() From 8c298b1c3be240a0bf1ea8297b09df27a5b30681 Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Tue, 18 Feb 2025 21:48:26 -0700 Subject: [PATCH 09/36] printf: Fix printf 'mixed_format_random' (#2236) %a or %A with printf on MSVC platforms have a default precision of 13, which is in contrast to OpenCL C specification for printf which only allows for exact digits required if precision is not specified. --- test_conformance/printf/test_printf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/printf/test_printf.cpp b/test_conformance/printf/test_printf.cpp index 380878cb..e2991f39 100644 --- a/test_conformance/printf/test_printf.cpp +++ b/test_conformance/printf/test_printf.cpp @@ -247,7 +247,7 @@ cl_program makeMixedFormatPrintfProgram(cl_kernel* kernel_ptr, }; std::array, 2> formats = { - { { "%f", "%e", "%g", "%a", "%F", "%E", "%G", "%A" }, + { { "%f", "%e", "%g", "%13a", "%F", "%E", "%G", "%13A" }, { "%d", "%i", "%u", "%x", "%o", "%X" } } }; std::vector data_before(2 + genrand_int32(gMTdata) % 8); From 84fd99da762675149bd7042440b6bde7248a9c61 Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Wed, 19 Feb 2025 05:49:12 +0100 Subject: [PATCH 10/36] fix profiling execute_multipass (#2239) - fix clGetDeviceInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES) by using the proper size - clamp localThreads[2] as for localThreads[0] and localThreads[2] - clamp all localThreads elements in regard of CL_MAX_WORK_GROUP_SIZE - fix the size using to create/read the output buffer Fix #2238 --- .../profiling/execute_multipass.cpp | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/test_conformance/profiling/execute_multipass.cpp b/test_conformance/profiling/execute_multipass.cpp index 2fd89f65..d3532ceb 100644 --- a/test_conformance/profiling/execute_multipass.cpp +++ b/test_conformance/profiling/execute_multipass.cpp @@ -15,6 +15,7 @@ // #include "harness/compat.h" +#include #include #include #include @@ -97,6 +98,7 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue cl_ulong queueStart, submitStart, writeStart, writeEnd; size_t threads[3]; size_t localThreads[3]; + size_t maxWorkgroupSize; int err = 0; // set thread dimensions @@ -104,16 +106,27 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue threads[1] = h; threads[2] = d; - err = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof( cl_uint ), (size_t*)localThreads, NULL ); + err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, + 3 * sizeof(size_t), (size_t *)localThreads, NULL); if (err) { - localThreads[0] = 256; localThreads[1] = 1; localThreads[2] = 1; - err = 0; + log_error("clGetDeviceInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES) failed\n"); + return -1; } - if( localThreads[0] > threads[0] ) - localThreads[0] = threads[0]; - if( localThreads[1] > threads[1] ) - localThreads[1] = threads[1]; + err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), + &maxWorkgroupSize, NULL); + if (err) + { + log_error("clGetDeviceInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE) failed\n"); + return -1; + } + localThreads[0] = + std::min({ localThreads[0], threads[0], maxWorkgroupSize }); + localThreads[1] = std::min( + { localThreads[1], threads[1], maxWorkgroupSize / localThreads[0] }); + localThreads[2] = + std::min({ localThreads[2], threads[2], + maxWorkgroupSize / (localThreads[0] * localThreads[1]) }); cl_sampler sampler = clCreateSampler( context, CL_FALSE, CL_ADDRESS_CLAMP_TO_EDGE, CL_FILTER_NEAREST, &err ); if( err ){ @@ -131,9 +144,9 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue } // allocate an array memory object to load the filter weights + size_t outptr_size = sizeof(cl_uchar) * w * h * d * nChannels; memobjs[1] = - clCreateBuffer(context, CL_MEM_READ_WRITE, - sizeof(cl_uchar) * w * h * d * nChannels, NULL, &err); + clCreateBuffer(context, CL_MEM_READ_WRITE, outptr_size, NULL, &err); if( memobjs[1] == (cl_mem)0 ){ log_error( " unable to create array using clCreateBuffer\n" ); clReleaseMemObject( memobjs[0] ); @@ -237,9 +250,8 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue } // read output image - err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0, - sizeof(cl_uchar) * w * h * d * nChannels, outptr, - 0, NULL, NULL); + err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0, outptr_size, + outptr, 0, NULL, NULL); if( err != CL_SUCCESS ){ print_error( err, "clReadImage failed\n" ); clReleaseKernel( kernel[0] ); From 6d3d199b4261d7679cb2004aa649095a2f987b3e Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Wed, 19 Feb 2025 04:50:43 +0000 Subject: [PATCH 11/36] Deduplicate create_image from Copy/Fill image tests (#2262) 1. Remove duplicate `create_image` code that is in both clFillImage and clCopyImage test directories. 2. Unify how pitch buffer's memory is deallocated; The buffer can be allocated with either `malloc` or `align_malloc` and the free function is pre-set in `pitch_buffe_data`'s member variable `free_fn` and used when the buffer is deallocated. With this, the change removes `is_aligned` conditional variable that was used to select the appropriate free function. Signed-off-by: Michael Rizkalla --- .../images/clCopyImage/test_copy_generic.cpp | 407 +--------------- .../images/clFillImage/test_fill_generic.cpp | 337 +------------ test_conformance/images/common.cpp | 443 ++++++++++++++++++ test_conformance/images/common.h | 5 + 4 files changed, 458 insertions(+), 734 deletions(-) diff --git a/test_conformance/images/clCopyImage/test_copy_generic.cpp b/test_conformance/images/clCopyImage/test_copy_generic.cpp index 37fc8e30..761eec6b 100644 --- a/test_conformance/images/clCopyImage/test_copy_generic.cpp +++ b/test_conformance/images/clCopyImage/test_copy_generic.cpp @@ -15,406 +15,7 @@ // #include "../testBase.h" #include - -struct pitch_buffer_data -{ - void *buf; - bool is_aligned; -}; - -static void CL_CALLBACK free_pitch_buffer(cl_mem image, void *data) -{ - pitch_buffer_data *d = static_cast(data); - if (d->is_aligned) - { - align_free(d->buf); - } - else - { - free(d->buf); - } - free(d); -} - -static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf) -{ - clReleaseMemObject((cl_mem)buf); -} - -cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr& data, image_descriptor *imageInfo, int *error ) -{ - cl_mem img; - cl_image_desc imageDesc; - cl_mem_flags mem_flags = CL_MEM_READ_ONLY; - void *host_ptr = NULL; - bool is_host_ptr_aligned = false; - - memset(&imageDesc, 0x0, sizeof(cl_image_desc)); - imageDesc.image_type = imageInfo->type; - imageDesc.image_width = imageInfo->width; - imageDesc.image_height = imageInfo->height; - imageDesc.image_depth = imageInfo->depth; - imageDesc.image_array_size = imageInfo->arraySize; - imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0; - imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0; - imageDesc.num_mip_levels = gTestMipmaps ? imageInfo->num_mip_levels : 0; - - Version version; - cl_device_id device; - { - cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, - sizeof(device), &device, nullptr); - if (err != CL_SUCCESS) - { - log_error("Error: Could not get CL_QUEUE_DEVICE from queue"); - return nullptr; - } - version = get_device_cl_version(device); - } - - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D: - if ( gDebugTrace ) - log_info( " - Creating 1D image %d ...\n", (int)imageInfo->width ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->rowPitch ); - break; - case CL_MEM_OBJECT_IMAGE2D: - if ( gDebugTrace ) - log_info( " - Creating 2D image %d by %d ...\n", (int)imageInfo->width, (int)imageInfo->height ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->height * imageInfo->rowPitch ); - break; - case CL_MEM_OBJECT_IMAGE3D: - if ( gDebugTrace ) - log_info( " - Creating 3D image %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->depth * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - if ( gDebugTrace ) - log_info( " - Creating 1D image array %d by %d...\n", (int)imageInfo->width, (int)imageInfo->arraySize ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - if ( gDebugTrace ) - log_info( " - Creating 2D image array %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - if (gDebugTrace) - log_info(" - Creating 1D buffer image %d ...\n", - (int)imageInfo->width); - { - cl_int err; - cl_mem_flags buffer_flags = CL_MEM_READ_WRITE; - if (gEnablePitch) - { - if (version.major() == 1) - { - host_ptr = malloc(imageInfo->rowPitch); - } - else - { - cl_uint base_address_alignment = 0; - err = clGetDeviceInfo( - device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, - sizeof(base_address_alignment), - &base_address_alignment, nullptr); - if (err != CL_SUCCESS) - { - log_error("ERROR: Could not get " - "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT " - "from device"); - return NULL; - } - host_ptr = align_malloc(imageInfo->rowPitch, - base_address_alignment); - is_host_ptr_aligned = true; - } - buffer_flags |= CL_MEM_USE_HOST_PTR; - } - - cl_mem buffer = clCreateBuffer( - context, buffer_flags, imageInfo->rowPitch, host_ptr, &err); - if (err != CL_SUCCESS) - { - log_error("ERROR: Could not create buffer for 1D buffer " - "image. %zu bytes\n", - imageInfo->width); - return NULL; - } - imageDesc.buffer = buffer; - } - break; - } - - if ( gDebugTrace && gTestMipmaps ) - log_info(" - with %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels); - - if (gEnablePitch) - { - if ( NULL == host_ptr ) - { - log_error("ERROR: Unable to create backing store for pitched 3D " - "image. %zu bytes\n", - imageInfo->depth * imageInfo->slicePitch); - return NULL; - } - if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) - { - mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR; - } - } - - if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) - { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - host_ptr, error); - } - else - { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - nullptr, error); - } - - if (gEnablePitch) - { - pitch_buffer_data *data = - static_cast(malloc(sizeof(pitch_buffer_data))); - data->buf = host_ptr; - data->is_aligned = is_host_ptr_aligned; - if ( *error == CL_SUCCESS ) - { - int callbackError = - clSetMemObjectDestructorCallback(img, free_pitch_buffer, data); - if ( CL_SUCCESS != callbackError ) - { - free_pitch_buffer(img, data); - log_error( "ERROR: Unable to attach destructor callback to pitched 3D image. Err: %d\n", callbackError ); - clReleaseMemObject( img ); - return NULL; - } - } - else - { - free_pitch_buffer(img, data); - } - } - - if (imageDesc.buffer != NULL) - { - int callbackError = clSetMemObjectDestructorCallback( - img, release_cl_buffer, imageDesc.buffer); - if (callbackError != CL_SUCCESS) - { - log_error("Error: Unable to attach destructor callback to 1d " - "buffer image. Err: %d\n", - callbackError); - clReleaseMemObject(imageDesc.buffer); - clReleaseMemObject(img); - return NULL; - } - } - - if ( *error != CL_SUCCESS ) - { - long long unsigned imageSize = get_image_size_mb(imageInfo); - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D: - log_error("ERROR: Unable to create 1D image of size %d (%llu " - "MB):(%s)", - (int)imageInfo->width, imageSize, - IGetErrorString(*error)); - break; - case CL_MEM_OBJECT_IMAGE2D: - log_error("ERROR: Unable to create 2D image of size %d x %d " - "(%llu MB):(%s)", - (int)imageInfo->width, (int)imageInfo->height, - imageSize, IGetErrorString(*error)); - break; - case CL_MEM_OBJECT_IMAGE3D: - log_error("ERROR: Unable to create 3D image of size %d x %d x " - "%d (%llu MB):(%s)", - (int)imageInfo->width, (int)imageInfo->height, - (int)imageInfo->depth, imageSize, - IGetErrorString(*error)); - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - log_error("ERROR: Unable to create 1D image array of size %d x " - "%d (%llu MB):(%s)", - (int)imageInfo->width, (int)imageInfo->arraySize, - imageSize, IGetErrorString(*error)); - break; - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - log_error("ERROR: Unable to create 2D image array of size %d x " - "%d x %d (%llu MB):(%s)", - (int)imageInfo->width, (int)imageInfo->height, - (int)imageInfo->arraySize, imageSize, - IGetErrorString(*error)); - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - log_error( - "ERROR: Unable to create 1D buffer image of size %d (%llu " - "MB):(%s)", - (int)imageInfo->width, imageSize, IGetErrorString(*error)); - break; - } - log_error("ERROR: and %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels); - return NULL; - } - - // Copy the specified data to the image via a Map operation. - size_t mappedRow, mappedSlice; - size_t width = imageInfo->width; - size_t height = 1; - size_t depth = 1; - size_t row_pitch_lod, slice_pitch_lod; - row_pitch_lod = imageInfo->rowPitch; - slice_pitch_lod = imageInfo->slicePitch; - - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - height = imageInfo->arraySize; - depth = 1; - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - case CL_MEM_OBJECT_IMAGE1D: - height = depth = 1; - break; - case CL_MEM_OBJECT_IMAGE2D: - height = imageInfo->height; - depth = 1; - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - height = imageInfo->height; - depth = imageInfo->arraySize; - break; - case CL_MEM_OBJECT_IMAGE3D: - height = imageInfo->height; - depth = imageInfo->depth; - break; - } - - size_t origin[ 4 ] = { 0, 0, 0, 0 }; - size_t region[ 3 ] = { imageInfo->width, height, depth }; - - for ( size_t lod = 0; (gTestMipmaps && (lod < imageInfo->num_mip_levels)) || (!gTestMipmaps && (lod < 1)); lod++) - { - // Map the appropriate miplevel to copy the specified data. - if(gTestMipmaps) - { - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE3D: - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - origin[ 3 ] = lod; - break; - case CL_MEM_OBJECT_IMAGE2D: - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - origin[ 2 ] = lod; - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - case CL_MEM_OBJECT_IMAGE1D: - origin[ 1 ] = lod; - break; - } - - //Adjust image dimensions as per miplevel - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE3D: - depth = ( imageInfo->depth >> lod ) ? (imageInfo->depth >> lod) : 1; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - case CL_MEM_OBJECT_IMAGE2D: - height = ( imageInfo->height >> lod ) ? (imageInfo->height >> lod) : 1; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - case CL_MEM_OBJECT_IMAGE1D: - width = ( imageInfo->width >> lod ) ? (imageInfo->width >> lod) : 1; - } - row_pitch_lod = width * get_pixel_size(imageInfo->format); - slice_pitch_lod = row_pitch_lod * height; - region[0] = width; - region[1] = height; - region[2] = depth; - } - - void* mapped = (char*)clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, error); - if (*error != CL_SUCCESS) - { - log_error( "ERROR: Unable to map image for writing: %s\n", IGetErrorString( *error ) ); - return NULL; - } - size_t mappedSlicePad = mappedSlice - (mappedRow * height); - - // For 1Darray, the height variable actually contains the arraysize, - // so it can't be used for calculating the slice padding. - if (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY) - mappedSlicePad = mappedSlice - (mappedRow * 1); - - // Copy the image. - size_t scanlineSize = row_pitch_lod; - size_t sliceSize = slice_pitch_lod - scanlineSize * height; - size_t imageSize = scanlineSize * height * depth; - size_t data_lod_offset = 0; - if( gTestMipmaps ) - data_lod_offset = compute_mip_level_offset(imageInfo, lod); - - char* src = (char*)data + data_lod_offset; - char* dst = (char*)mapped; - - if ((mappedRow == scanlineSize) && (mappedSlicePad==0 || (imageInfo->depth==0 && imageInfo->arraySize==0))) { - // Copy the whole image. - memcpy( dst, src, imageSize ); - } - else { - // Else copy one scan line at a time. - size_t dstPitch2D = 0; - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE3D: - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - case CL_MEM_OBJECT_IMAGE2D: - dstPitch2D = mappedRow; - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - case CL_MEM_OBJECT_IMAGE1D: - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - dstPitch2D = mappedSlice; - break; - } - for ( size_t z = 0; z < depth; z++ ) - { - for ( size_t y = 0; y < height; y++ ) - { - memcpy( dst, src, scanlineSize ); - dst += dstPitch2D; - src += scanlineSize; - } - - // mappedSlicePad is incorrect for 2D images here, but we will exit the z loop before this is a problem. - dst += mappedSlicePad; - src += sliceSize; - } - } - - // Unmap the image. - *error = clEnqueueUnmapMemObject(queue, img, mapped, 0, NULL, NULL); - if (*error != CL_SUCCESS) - { - log_error( "ERROR: Unable to unmap image after writing: %s\n", IGetErrorString( *error ) ); - return NULL; - } - } - return img; -} +#include "../common.h" int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ) @@ -463,7 +64,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d if( gDebugTrace ) log_info( " - Writing source image...\n" ); - srcImage = create_image( context, queue, srcData, srcImageInfo, &error ); + srcImage = create_image(context, queue, srcData, srcImageInfo, gEnablePitch, + gTestMipmaps, &error); if( srcImage == NULL ) return error; @@ -508,7 +110,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d if( gDebugTrace ) log_info( " - Writing destination image...\n" ); - dstImage = create_image( context, queue, dstData, dstImageInfo, &error ); + dstImage = create_image(context, queue, dstData, dstImageInfo, gEnablePitch, + gTestMipmaps, &error); if( dstImage == NULL ) return error; diff --git a/test_conformance/images/clFillImage/test_fill_generic.cpp b/test_conformance/images/clFillImage/test_fill_generic.cpp index 24c91813..f9b9096c 100644 --- a/test_conformance/images/clFillImage/test_fill_generic.cpp +++ b/test_conformance/images/clFillImage/test_fill_generic.cpp @@ -14,338 +14,10 @@ // limitations under the License. // #include "../testBase.h" -extern void read_image_pixel_float( void *imageData, image_descriptor *imageInfo, int x, int y, int z, float *outData ); +#include "../common.h" -struct pitch_buffer_data -{ - void *buf; - bool is_aligned; -}; -static void CL_CALLBACK free_pitch_buffer(cl_mem image, void *data) -{ - struct pitch_buffer_data *d = (struct pitch_buffer_data *)data; - if (d->is_aligned) - { - align_free(d->buf); - } - else - { - free(d->buf); - } - free(d); -} -static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf) -{ - clReleaseMemObject((cl_mem)buf); -} - -cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr& data, image_descriptor *imageInfo, int *error ) -{ - cl_mem img; - cl_image_desc imageDesc; - cl_mem_flags mem_flags = CL_MEM_READ_ONLY; - void *host_ptr = NULL; - - memset(&imageDesc, 0x0, sizeof(cl_image_desc)); - imageDesc.image_type = imageInfo->type; - imageDesc.image_width = imageInfo->width; - imageDesc.image_height = imageInfo->height; - imageDesc.image_depth = imageInfo->depth; - imageDesc.image_array_size = imageInfo->arraySize; - imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0; - imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0; - cl_device_id device; - Version version; - { - cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, - sizeof(device), &device, nullptr); - if (err != CL_SUCCESS) - { - log_error("Error: Could not get CL_QUEUE_DEVICE from queue"); - return NULL; - } - version = get_device_cl_version(device); - } - - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D: - if ( gDebugTrace ) - log_info( " - Creating 1D image %d ...\n", (int)imageInfo->width ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->rowPitch ); - break; - case CL_MEM_OBJECT_IMAGE2D: - if ( gDebugTrace ) - log_info( " - Creating 2D image %d by %d ...\n", (int)imageInfo->width, (int)imageInfo->height ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->height * imageInfo->rowPitch ); - break; - case CL_MEM_OBJECT_IMAGE3D: - if ( gDebugTrace ) - log_info( " - Creating 3D image %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->depth * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - if ( gDebugTrace ) - log_info( " - Creating 1D image array %d by %d...\n", (int)imageInfo->width, (int)imageInfo->arraySize ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - if ( gDebugTrace ) - log_info( " - Creating 2D image array %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize ); - if ( gEnablePitch ) - host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch ); - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - if (gDebugTrace) - log_info(" - Creating 1D buffer image %d ...\n", - (int)imageInfo->width); - { - cl_int err; - cl_mem_flags buffer_flags = CL_MEM_READ_WRITE; - if (gEnablePitch) - { - if (version.major() == 1) - { - host_ptr = malloc(imageInfo->rowPitch); - } - else - { - cl_uint base_address_alignment = 0; - err = clGetDeviceInfo( - device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, - sizeof(base_address_alignment), - &base_address_alignment, nullptr); - if (err != CL_SUCCESS) - { - log_error("ERROR: Could not get " - "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT " - "from device"); - return NULL; - } - host_ptr = align_malloc(imageInfo->rowPitch, - base_address_alignment); - } - buffer_flags |= CL_MEM_USE_HOST_PTR; - } - cl_mem buffer = clCreateBuffer( - context, buffer_flags, imageInfo->rowPitch, host_ptr, &err); - if (err != CL_SUCCESS) - { - log_error("ERROR: Could not create buffer for 1D buffer " - "image. %zu bytes\n", - imageInfo->rowPitch); - return NULL; - } - imageDesc.buffer = buffer; - } - break; - } - - if (gEnablePitch) - { - if ( NULL == host_ptr ) - { - log_error("ERROR: Unable to create backing store for pitched 3D " - "image. %zu bytes\n", - imageInfo->depth * imageInfo->slicePitch); - return NULL; - } - if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) - { - mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR; - } - } - - if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) - { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - host_ptr, error); - } - else - { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - nullptr, error); - } - - if (gEnablePitch) - { - struct pitch_buffer_data *data = (struct pitch_buffer_data *)malloc( - sizeof(struct pitch_buffer_data)); - data->buf = host_ptr; - data->is_aligned = (version.major() != 1) - && (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_BUFFER); - if (*error == CL_SUCCESS) - { - int callbackError = - clSetMemObjectDestructorCallback(img, free_pitch_buffer, data); - if (CL_SUCCESS != callbackError) - { - free_pitch_buffer(img, data); - log_error("ERROR: Unable to attach destructor callback to " - "pitched 3D image. Err: %d\n", - callbackError); - clReleaseMemObject(img); - return NULL; - } - } - else - { - free_pitch_buffer(img, data); - } - } - - if (imageDesc.buffer != NULL) - { - int callbackError = clSetMemObjectDestructorCallback( - img, release_cl_buffer, imageDesc.buffer); - if (callbackError != CL_SUCCESS) - { - log_error("Error: Unable to attach destructor callback to 1d " - "buffer image. Err: %d\n", - callbackError); - clReleaseMemObject(imageDesc.buffer); - clReleaseMemObject(img); - return NULL; - } - } - - if ( *error != CL_SUCCESS ) - { - long long unsigned imageSize = get_image_size_mb( imageInfo ); - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D: - log_error( "ERROR: Unable to create 1D image of size %d (%llu MB): %s\n", (int)imageInfo->width, imageSize, IGetErrorString( *error ) ); - break; - case CL_MEM_OBJECT_IMAGE2D: - log_error( "ERROR: Unable to create 2D image of size %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, imageSize, IGetErrorString( *error ) ); - break; - case CL_MEM_OBJECT_IMAGE3D: - log_error( "ERROR: Unable to create 3D image of size %d x %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth, imageSize, IGetErrorString( *error ) ); - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - log_error( "ERROR: Unable to create 1D image array of size %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->arraySize, imageSize, IGetErrorString( *error ) ); - break; - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - log_error( "ERROR: Unable to create 2D image array of size %d x %d x %d (%llu MB): %s\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize, imageSize, IGetErrorString( *error ) ); - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - log_error( - "ERROR: Unable to create 1D buffer image of size %d (%llu " - "MB):(%s)", - (int)imageInfo->width, imageSize, IGetErrorString(*error)); - break; - } - return NULL; - } - - // Copy the specified data to the image via a Map operation. - size_t mappedRow, mappedSlice; - size_t height; - size_t depth; - size_t imageSize = 0; - - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - height = imageInfo->arraySize; - depth = 1; - imageSize = imageInfo->rowPitch * imageInfo->arraySize; - break; - case CL_MEM_OBJECT_IMAGE1D_BUFFER: - case CL_MEM_OBJECT_IMAGE1D: - height = depth = 1; - imageSize = imageInfo->rowPitch; - break; - case CL_MEM_OBJECT_IMAGE2D: - height = imageInfo->height; - depth = 1; - imageSize = imageInfo->rowPitch * imageInfo->height; - break; - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - height = imageInfo->height; - depth = imageInfo->arraySize; - imageSize = imageInfo->slicePitch * imageInfo->arraySize; - break; - case CL_MEM_OBJECT_IMAGE3D: - height = imageInfo->height; - depth = imageInfo->depth; - imageSize = imageInfo->slicePitch * imageInfo->depth; - break; - default: - log_error("ERROR Invalid imageInfo->type = %d\n", imageInfo->type); - height = 0; - depth = 0; - break; - } - - size_t origin[ 3 ] = { 0, 0, 0 }; - size_t region[ 3 ] = { imageInfo->width, height, depth }; - - void* mapped = (char*)clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, error); - if (*error != CL_SUCCESS || !mapped) - { - log_error( "ERROR: Unable to map image for writing: %s\n", IGetErrorString( *error ) ); - return NULL; - } - size_t mappedSlicePad = mappedSlice - (mappedRow * height); - - // Copy the image. - size_t scanlineSize = imageInfo->rowPitch; - size_t sliceSize = imageInfo->slicePitch - scanlineSize * height; - - char* src = (char*)data; - char* dst = (char*)mapped; - - if ((mappedRow == scanlineSize) && ((mappedSlice == imageInfo->slicePitch) || (imageInfo->depth==0 && imageInfo->arraySize==0))) { - // Copy the whole image. - memcpy( dst, src, imageSize ); - } - else { - // Else copy one scan line at a time. - size_t dstPitch2D = 0; - switch (imageInfo->type) - { - case CL_MEM_OBJECT_IMAGE3D: - case CL_MEM_OBJECT_IMAGE2D_ARRAY: - case CL_MEM_OBJECT_IMAGE2D: - dstPitch2D = mappedRow; - break; - case CL_MEM_OBJECT_IMAGE1D_ARRAY: - case CL_MEM_OBJECT_IMAGE1D: - case CL_MEM_OBJECT_IMAGE1D_BUFFER: dstPitch2D = mappedSlice; break; - } - - for ( size_t z = 0; z < depth; z++ ) - { - for ( size_t y = 0; y < height; y++ ) - { - memcpy( dst, src, imageInfo->width * get_pixel_size(imageInfo->format) ); - dst += dstPitch2D; - src += scanlineSize; - } - - // mappedSlicePad is incorrect for 2D images here, but we will exit the z loop before this is a problem. - dst += mappedSlicePad; - src += sliceSize; - } - } - - // Unmap the image. - *error = clEnqueueUnmapMemObject(queue, img, mapped, 0, NULL, NULL); - if (*error != CL_SUCCESS) - { - log_error( "ERROR: Unable to unmap image after writing: %s\n", IGetErrorString( *error ) ); - return NULL; - } - - return img; -} +extern void read_image_pixel_float(void *imageData, image_descriptor *imageInfo, + int x, int y, int z, float *outData); static void fill_region_with_value( image_descriptor *imageInfo, void *imageValues, void *value, const size_t origin[], const size_t region[] ) @@ -438,7 +110,8 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d if ( gDebugTrace ) log_info( " - Creating image...\n" ); - image = create_image( context, queue, imgData, imageInfo, &error ); + image = create_image(context, queue, imgData, imageInfo, gEnablePitch, + false, &error); if ( image == NULL ) return error; diff --git a/test_conformance/images/common.cpp b/test_conformance/images/common.cpp index 178f962f..f11a0215 100644 --- a/test_conformance/images/common.cpp +++ b/test_conformance/images/common.cpp @@ -146,3 +146,446 @@ size_t random_in_ranges(size_t minimum, size_t rangeA, size_t rangeB, MTdata d) if (rangeA < minimum) return rangeA; return (size_t)random_in_range((int)minimum, (int)rangeA - 1, d); } + +using free_function_t = void (*)(void *); +struct pitch_buffer_data +{ + void *buf; + free_function_t free_fn; + + static void CL_CALLBACK free_buffer(cl_mem, void *data) + { + pitch_buffer_data *d = static_cast(data); + d->free_fn(d->buf); + delete d; + } +}; + +static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf) +{ + clReleaseMemObject((cl_mem)buf); +} + +clMemWrapper create_image(cl_context context, cl_command_queue queue, + BufferOwningPtr &data, + image_descriptor *imageInfo, bool enable_pitch, + bool create_mipmaps, int *error) +{ + cl_mem img; + cl_image_desc imageDesc; + cl_mem_flags mem_flags = CL_MEM_READ_ONLY; + void *host_ptr = nullptr; + bool is_host_ptr_aligned = false; + + memset(&imageDesc, 0x0, sizeof(cl_image_desc)); + imageDesc.image_type = imageInfo->type; + imageDesc.image_width = imageInfo->width; + imageDesc.image_height = imageInfo->height; + imageDesc.image_depth = imageInfo->depth; + imageDesc.image_array_size = imageInfo->arraySize; + imageDesc.image_row_pitch = enable_pitch ? imageInfo->rowPitch : 0; + imageDesc.image_slice_pitch = enable_pitch ? imageInfo->slicePitch : 0; + imageDesc.num_mip_levels = create_mipmaps ? imageInfo->num_mip_levels : 0; + + Version version; + cl_device_id device; + { + cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, + sizeof(device), &device, nullptr); + if (err != CL_SUCCESS) + { + log_error("Error: Could not get CL_QUEUE_DEVICE from queue"); + return nullptr; + } + version = get_device_cl_version(device); + } + + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE1D: + if (gDebugTrace) + log_info(" - Creating 1D image %d ...\n", + (int)imageInfo->width); + if (enable_pitch) host_ptr = malloc(imageInfo->rowPitch); + break; + case CL_MEM_OBJECT_IMAGE2D: + if (gDebugTrace) + log_info(" - Creating 2D image %d by %d ...\n", + (int)imageInfo->width, (int)imageInfo->height); + if (enable_pitch) + host_ptr = malloc(imageInfo->height * imageInfo->rowPitch); + break; + case CL_MEM_OBJECT_IMAGE3D: + if (gDebugTrace) + log_info(" - Creating 3D image %d by %d by %d...\n", + (int)imageInfo->width, (int)imageInfo->height, + (int)imageInfo->depth); + if (enable_pitch) + host_ptr = malloc(imageInfo->depth * imageInfo->slicePitch); + break; + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + if (gDebugTrace) + log_info(" - Creating 1D image array %d by %d...\n", + (int)imageInfo->width, (int)imageInfo->arraySize); + if (enable_pitch) + host_ptr = malloc(imageInfo->arraySize * imageInfo->slicePitch); + break; + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + if (gDebugTrace) + log_info(" - Creating 2D image array %d by %d by %d...\n", + (int)imageInfo->width, (int)imageInfo->height, + (int)imageInfo->arraySize); + if (enable_pitch) + host_ptr = malloc(imageInfo->arraySize * imageInfo->slicePitch); + break; + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + if (gDebugTrace) + log_info(" - Creating 1D buffer image %d ...\n", + (int)imageInfo->width); + { + cl_int err; + cl_mem_flags buffer_flags = CL_MEM_READ_WRITE; + if (enable_pitch) + { + if (version.major() == 1) + { + host_ptr = malloc(imageInfo->rowPitch); + } + else + { + cl_uint base_address_alignment = 0; + err = clGetDeviceInfo( + device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, + sizeof(base_address_alignment), + &base_address_alignment, nullptr); + if (err != CL_SUCCESS) + { + log_error("ERROR: Could not get " + "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT " + "from device"); + return nullptr; + } + host_ptr = align_malloc(imageInfo->rowPitch, + base_address_alignment); + is_host_ptr_aligned = true; + } + buffer_flags |= CL_MEM_USE_HOST_PTR; + } + + cl_mem buffer = clCreateBuffer( + context, buffer_flags, imageInfo->rowPitch, host_ptr, &err); + if (err != CL_SUCCESS) + { + log_error("ERROR: Could not create buffer for 1D buffer " + "image. %zu bytes\n", + imageInfo->width); + if (host_ptr) + { + if (is_host_ptr_aligned) + { + align_free(host_ptr); + } + else + { + free(host_ptr); + } + } + return nullptr; + } + imageDesc.buffer = buffer; + } + break; + } + + if (gDebugTrace && create_mipmaps) + log_info(" - with %llu mip levels\n", + (unsigned long long)imageInfo->num_mip_levels); + + if (enable_pitch) + { + if (nullptr == host_ptr) + { + log_error("ERROR: Unable to create backing store for pitched 3D " + "image. %zu bytes\n", + imageInfo->depth * imageInfo->slicePitch); + return nullptr; + } + if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) + { + mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR; + } + } + + if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) + { + img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, + host_ptr, error); + } + else + { + img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, + nullptr, error); + } + + if (enable_pitch) + { + free_function_t free_fn = is_host_ptr_aligned ? align_free : free; + if (*error == CL_SUCCESS) + { + pitch_buffer_data *buf_data = new pitch_buffer_data; + buf_data->buf = host_ptr; + buf_data->free_fn = free_fn; + + int callbackError = clSetMemObjectDestructorCallback( + img, pitch_buffer_data::free_buffer, buf_data); + if (CL_SUCCESS != callbackError) + { + pitch_buffer_data::free_buffer(img, buf_data); + log_error("ERROR: Unable to attach destructor callback to " + "pitched 3D image. Err: %d\n", + callbackError); + clReleaseMemObject(img); + return nullptr; + } + } + else + { + free_fn(host_ptr); + } + } + + if (imageDesc.buffer != nullptr) + { + int callbackError = clSetMemObjectDestructorCallback( + img, release_cl_buffer, imageDesc.buffer); + if (callbackError != CL_SUCCESS) + { + log_error("Error: Unable to attach destructor callback to 1d " + "buffer image. Err: %d\n", + callbackError); + clReleaseMemObject(imageDesc.buffer); + clReleaseMemObject(img); + return nullptr; + } + } + + if (*error != CL_SUCCESS) + { + long long unsigned imageSize = get_image_size_mb(imageInfo); + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE1D: + log_error("ERROR: Unable to create 1D image of size %d (%llu " + "MB):(%s)", + (int)imageInfo->width, imageSize, + IGetErrorString(*error)); + break; + case CL_MEM_OBJECT_IMAGE2D: + log_error("ERROR: Unable to create 2D image of size %d x %d " + "(%llu MB):(%s)", + (int)imageInfo->width, (int)imageInfo->height, + imageSize, IGetErrorString(*error)); + break; + case CL_MEM_OBJECT_IMAGE3D: + log_error("ERROR: Unable to create 3D image of size %d x %d x " + "%d (%llu MB):(%s)", + (int)imageInfo->width, (int)imageInfo->height, + (int)imageInfo->depth, imageSize, + IGetErrorString(*error)); + break; + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + log_error("ERROR: Unable to create 1D image array of size %d x " + "%d (%llu MB):(%s)", + (int)imageInfo->width, (int)imageInfo->arraySize, + imageSize, IGetErrorString(*error)); + break; + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + log_error("ERROR: Unable to create 2D image array of size %d x " + "%d x %d (%llu MB):(%s)", + (int)imageInfo->width, (int)imageInfo->height, + (int)imageInfo->arraySize, imageSize, + IGetErrorString(*error)); + break; + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + log_error( + "ERROR: Unable to create 1D buffer image of size %d (%llu " + "MB):(%s)", + (int)imageInfo->width, imageSize, IGetErrorString(*error)); + break; + } + log_error("ERROR: and %llu mip levels\n", + (unsigned long long)imageInfo->num_mip_levels); + return nullptr; + } + + // Copy the specified data to the image via a Map operation. + size_t mappedRow, mappedSlice; + size_t width = imageInfo->width; + size_t height = 1; + size_t depth = 1; + size_t row_pitch_lod, slice_pitch_lod; + row_pitch_lod = imageInfo->rowPitch; + slice_pitch_lod = imageInfo->slicePitch; + + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + height = imageInfo->arraySize; + depth = 1; + break; + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + case CL_MEM_OBJECT_IMAGE1D: height = depth = 1; break; + case CL_MEM_OBJECT_IMAGE2D: + height = imageInfo->height; + depth = 1; + break; + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + height = imageInfo->height; + depth = imageInfo->arraySize; + break; + case CL_MEM_OBJECT_IMAGE3D: + height = imageInfo->height; + depth = imageInfo->depth; + break; + default: + log_error("ERROR Invalid imageInfo->type = %d\n", imageInfo->type); + height = 0; + depth = 0; + return nullptr; + break; + } + + size_t origin[4] = { 0, 0, 0, 0 }; + size_t region[3] = { imageInfo->width, height, depth }; + + for (size_t lod = 0; (create_mipmaps && (lod < imageInfo->num_mip_levels)) + || (!create_mipmaps && (lod < 1)); + lod++) + { + // Map the appropriate miplevel to copy the specified data. + if (create_mipmaps) + { + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE3D: + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + origin[0] = origin[1] = origin[2] = 0; + origin[3] = lod; + break; + case CL_MEM_OBJECT_IMAGE2D: + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + origin[0] = origin[1] = origin[3] = 0; + origin[2] = lod; + break; + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + case CL_MEM_OBJECT_IMAGE1D: + origin[0] = origin[2] = origin[3] = 0; + origin[1] = lod; + break; + } + + // Adjust image dimensions as per miplevel + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE3D: + depth = (imageInfo->depth >> lod) + ? (imageInfo->depth >> lod) + : 1; + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + case CL_MEM_OBJECT_IMAGE2D: + height = (imageInfo->height >> lod) + ? (imageInfo->height >> lod) + : 1; + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + case CL_MEM_OBJECT_IMAGE1D: + width = (imageInfo->width >> lod) + ? (imageInfo->width >> lod) + : 1; + } + row_pitch_lod = width * get_pixel_size(imageInfo->format); + slice_pitch_lod = row_pitch_lod * height; + region[0] = width; + region[1] = height; + region[2] = depth; + } + + char *mapped = static_cast(clEnqueueMapImage( + queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, + &mappedSlice, 0, nullptr, nullptr, error)); + if (*error != CL_SUCCESS || !mapped) + { + log_error("ERROR: Unable to map image for writing: %s\n", + IGetErrorString(*error)); + return nullptr; + } + size_t mappedSlicePad = mappedSlice - (mappedRow * height); + + // For 1Darray, the height variable actually contains the arraysize, + // so it can't be used for calculating the slice padding. + if (imageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY) + mappedSlicePad = mappedSlice - (mappedRow * 1); + + // Copy the image. + size_t scanlineSize = row_pitch_lod; + size_t sliceSize = slice_pitch_lod - scanlineSize * height; + size_t imageSize = scanlineSize * height * depth; + size_t data_lod_offset = 0; + if (create_mipmaps) + { + data_lod_offset = compute_mip_level_offset(imageInfo, lod); + } + + char *src = static_cast(data) + data_lod_offset; + char *dst = mapped; + + if ((mappedRow == scanlineSize) + && (mappedSlicePad == 0 + || (imageInfo->depth == 0 && imageInfo->arraySize == 0))) + { + // Copy the whole image. + memcpy(dst, src, imageSize); + } + else + { + // Else copy one scan line at a time. + size_t dstPitch2D = 0; + switch (imageInfo->type) + { + case CL_MEM_OBJECT_IMAGE3D: + case CL_MEM_OBJECT_IMAGE2D_ARRAY: + case CL_MEM_OBJECT_IMAGE2D: dstPitch2D = mappedRow; break; + case CL_MEM_OBJECT_IMAGE1D_ARRAY: + case CL_MEM_OBJECT_IMAGE1D: + case CL_MEM_OBJECT_IMAGE1D_BUFFER: + dstPitch2D = mappedSlice; + break; + } + for (size_t z = 0; z < depth; z++) + { + for (size_t y = 0; y < height; y++) + { + memcpy(dst, src, scanlineSize); + dst += dstPitch2D; + src += scanlineSize; + } + + // mappedSlicePad is incorrect for 2D images here, but we will + // exit the z loop before this is a problem. + dst += mappedSlicePad; + src += sliceSize; + } + } + + // Unmap the image. + *error = + clEnqueueUnmapMemObject(queue, img, mapped, 0, nullptr, nullptr); + if (*error != CL_SUCCESS) + { + log_error("ERROR: Unable to unmap image after writing: %s\n", + IGetErrorString(*error)); + return nullptr; + } + } + return img; +} diff --git a/test_conformance/images/common.h b/test_conformance/images/common.h index 27e8679b..f7aa1495 100644 --- a/test_conformance/images/common.h +++ b/test_conformance/images/common.h @@ -50,4 +50,9 @@ int get_format_list(cl_context context, cl_mem_object_type imageType, cl_mem_flags flags); size_t random_in_ranges(size_t minimum, size_t rangeA, size_t rangeB, MTdata d); +clMemWrapper create_image(cl_context context, cl_command_queue queue, + BufferOwningPtr &data, + image_descriptor *imageInfo, bool enable_pitch, + bool create_mipmaps, int *error); + #endif // IMAGES_COMMON_H From bdd0eb0b7ee4ff12e0122ea2215553ba0342ce3b Mon Sep 17 00:00:00 2001 From: zzk0 <30856589+zzk0@users.noreply.github.com> Date: Wed, 19 Feb 2025 12:51:19 +0800 Subject: [PATCH 12/36] bugfix nan test for basic fpmath (#2268) This PR fixes the validation logic for cases where the data type is not half. Because the variable nan_test is always false, types like float never trigger a validation failure. --- test_conformance/basic/test_fpmath.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test_conformance/basic/test_fpmath.cpp b/test_conformance/basic/test_fpmath.cpp index 77247bba..fc7b9108 100644 --- a/test_conformance/basic/test_fpmath.cpp +++ b/test_conformance/basic/test_fpmath.cpp @@ -98,14 +98,20 @@ int verify_fp(std::vector (&input)[2], std::vector &output, auto &inB = input[1]; for (size_t i = 0; i < output.size(); i++) { - bool nan_test = false; - T r = test.ref(inA[i], inB[i]); + bool both_nan = false; if (std::is_same::value) - nan_test = !(isHalfNan(r) && isHalfNan(output[i])); + { + both_nan = isHalfNan(r) && isHalfNan(output[i]); + } + else if (std::is_floating_point::value) + { + both_nan = std::isnan(r) && std::isnan(output[i]); + } - if (r != output[i] && nan_test) + // If not both nan, check if the result is the same + if (!both_nan && (r != output[i])) { log_error("FP math test for type: %s, vec size: %zu, failed at " "index %zu, %a '%c' %a, expected %a, get %a\n", From 32361e1d893a51dc8e9b42d21506578b20d8456f Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Tue, 18 Feb 2025 21:51:36 -0700 Subject: [PATCH 13/36] bruteforce: Check both input values for nan (#2270) --- test_conformance/math_brute_force/reference_math.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test_conformance/math_brute_force/reference_math.cpp b/test_conformance/math_brute_force/reference_math.cpp index acde1136..90b4adb4 100644 --- a/test_conformance/math_brute_force/reference_math.cpp +++ b/test_conformance/math_brute_force/reference_math.cpp @@ -1641,6 +1641,7 @@ double reference_expm1(double x) double reference_fmax(double x, double y) { if (isnan(y)) return x; + if (isnan(x)) return y; return x >= y ? x : y; } @@ -1648,6 +1649,7 @@ double reference_fmax(double x, double y) double reference_fmin(double x, double y) { if (isnan(y)) return x; + if (isnan(x)) return y; return x <= y ? x : y; } @@ -3611,6 +3613,7 @@ long double reference_expm1l(long double x) long double reference_fmaxl(long double x, long double y) { if (isnan(y)) return x; + if (isnan(x)) return y; return x >= y ? x : y; } @@ -3618,6 +3621,7 @@ long double reference_fmaxl(long double x, long double y) long double reference_fminl(long double x, long double y) { if (isnan(y)) return x; + if (isnan(x)) return y; return x <= y ? x : y; } From 0ddfbbe6735f773e0f655d421d4f4ab7e7454b75 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 25 Feb 2025 17:42:09 +0100 Subject: [PATCH 14/36] Added object comparability verification for context devices query (#2176) Fixes #1485 according to work plan, point `CL_CONTEXT_DEVICES` --- test_conformance/api/testBase.h | 20 ++++ test_conformance/api/test_queries.cpp | 156 ++++++++++++++++++++++++-- 2 files changed, 168 insertions(+), 8 deletions(-) diff --git a/test_conformance/api/testBase.h b/test_conformance/api/testBase.h index 02f76e94..beb3c924 100644 --- a/test_conformance/api/testBase.h +++ b/test_conformance/api/testBase.h @@ -27,4 +27,24 @@ #include #include +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto &device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + #endif // _testBase_h diff --git a/test_conformance/api/test_queries.cpp b/test_conformance/api/test_queries.cpp index 92eff9c1..81b99495 100644 --- a/test_conformance/api/test_queries.cpp +++ b/test_conformance/api/test_queries.cpp @@ -18,8 +18,10 @@ #include "harness/propertyHelpers.h" #include #include +#include #include #include +#include #include REGISTER_TEST(get_platform_info) @@ -476,18 +478,41 @@ REGISTER_TEST(get_command_queue_info_compatibility) REGISTER_TEST(get_context_info) { int error; + + // query single device context and perform object comparability test + cl_uint num_devices = 0; + error = clGetContextInfo(context, CL_CONTEXT_NUM_DEVICES, sizeof(cl_uint), + &num_devices, nullptr); + test_error(error, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n"); + + test_assert_error(num_devices == 1, + "Context must contain exactly one device\n"); + + cl_device_id comp_device = nullptr; + error = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(cl_device_id), + &comp_device, nullptr); + test_error(error, "clGetContextInfo CL_CONTEXT_DEVICES failed\n"); + + test_assert_error(device == comp_device, + "Unexpected result returned by CL_CONTEXT_DEVICES query"); + + // query context properties against valid size size_t size; cl_context_properties props; + error = clGetContextInfo(context, CL_CONTEXT_PROPERTIES, sizeof(props), + &props, &size); + test_error(error, "Unable to get context props"); - error = clGetContextInfo( context, CL_CONTEXT_PROPERTIES, sizeof( props ), &props, &size ); - test_error( error, "Unable to get context props" ); - - if (size == 0) { + if (size == 0) + { // Valid size return 0; - } else if (size == sizeof(cl_context_properties)) { + } + else if (size == sizeof(cl_context_properties)) + { // Data must be NULL - if (props != 0) { + if (props != 0) + { log_error("ERROR: Returned properties is no NULL.\n"); return -1; } @@ -495,11 +520,126 @@ REGISTER_TEST(get_context_info) return 0; } // Size was not 0 or 1 - log_error( "ERROR: Returned size of context props is not valid! (expected 0 or %d, got %d)\n", - (int)sizeof(cl_context_properties), (int)size ); + log_error("ERROR: Returned size of context props is not valid! (expected 0 " + "or %d, got %d)\n", + (int)sizeof(cl_context_properties), (int)size); return -1; } +REGISTER_TEST(get_context_info_mult_devices) +{ + cl_int err = CL_SUCCESS; + size_t size = 0; + + // query multi-device context and perform objects comparability test + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES, 0, nullptr, + &size); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (size == 0) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + std::vector supported_props( + size / sizeof(cl_device_partition_property), 0); + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES, + supported_props.size() + * sizeof(cl_device_partition_property), + supported_props.data(), &size); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (supported_props.empty() || supported_props.front() == 0) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_uint maxComputeUnits = 0; + err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, NULL); + test_error_fail(err, "Unable to get maximal number of compute units"); + + std::vector> partition_props = { + { CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1, + CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 } + }; + + std::unique_ptr scope_guard; + cl_uint num_devices = 0; + for (auto &sup_prop : supported_props) + { + for (auto &prop : partition_props) + { + if (sup_prop == prop[0]) + { + // how many sub-devices can we create? + err = clCreateSubDevices(device, prop.data(), 0, nullptr, + &num_devices); + test_error_fail(err, "clCreateSubDevices failed"); + if (num_devices < 2) continue; + + // get the list of subDevices + scope_guard.reset(new SubDevicesScopeGuarded(num_devices)); + err = clCreateSubDevices(device, prop.data(), num_devices, + scope_guard->sub_devices.data(), + &num_devices); + test_error_fail(err, "clCreateSubDevices failed"); + break; + } + } + if (scope_guard.get() != nullptr) break; + } + + if (scope_guard.get() == nullptr) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + /* Create a multi device context */ + clContextWrapper multi_device_context = clCreateContext( + NULL, (cl_uint)num_devices, scope_guard->sub_devices.data(), nullptr, + nullptr, &err); + test_error_fail(err, "Unable to create testing context"); + + err = clGetContextInfo(multi_device_context, CL_CONTEXT_NUM_DEVICES, + sizeof(cl_uint), &num_devices, nullptr); + test_error_fail(err, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n"); + + test_assert_error(num_devices == scope_guard->sub_devices.size(), + "Context must contain exact number of devices\n"); + + std::vector devices(num_devices); + err = clGetContextInfo(multi_device_context, CL_CONTEXT_DEVICES, + num_devices * sizeof(cl_device_id), devices.data(), + nullptr); + test_error_fail(err, "clGetContextInfo CL_CONTEXT_DEVICES failed\n"); + + test_assert_error(devices.size() == scope_guard->sub_devices.size(), + "Size of devices arrays must be in sync\n"); + + for (cl_uint i = 0; i < devices.size(); i++) + { + bool found = false; + for (auto &it : scope_guard->sub_devices) + { + if (it == devices[i]) + { + found = true; + break; + } + } + test_error_fail( + !found, "Unexpected result returned by CL_CONTEXT_DEVICES query"); + } + return TEST_PASS; +} + void CL_CALLBACK mem_obj_destructor_callback( cl_mem, void *data ) { free( data ); From a90a8194bce33fb72463b781d13cd3cbaaf78f9b Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 25 Feb 2025 17:43:12 +0100 Subject: [PATCH 15/36] Added object comparability verification for program devices query (#2237) Fixes #1485 according to work plan from issue description. --- test_conformance/compiler/main.cpp | 1 + test_conformance/compiler/procs.h | 4 + test_conformance/compiler/testBase.h | 20 +++ .../compiler/test_build_helpers.cpp | 150 ++++++++++++++++-- 4 files changed, 162 insertions(+), 13 deletions(-) diff --git a/test_conformance/compiler/main.cpp b/test_conformance/compiler/main.cpp index e31300c8..167d092b 100644 --- a/test_conformance/compiler/main.cpp +++ b/test_conformance/compiler/main.cpp @@ -35,6 +35,7 @@ test_definition test_list[] = { ADD_TEST(get_program_source), ADD_TEST(get_program_build_info), ADD_TEST(get_program_info), + ADD_TEST(get_program_info_mult_devices), ADD_TEST(large_compile), ADD_TEST(async_build), diff --git a/test_conformance/compiler/procs.h b/test_conformance/compiler/procs.h index 4a425ffe..a10c436f 100644 --- a/test_conformance/compiler/procs.h +++ b/test_conformance/compiler/procs.h @@ -71,6 +71,10 @@ extern int test_get_program_build_info(cl_device_id deviceID, int num_elements); extern int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_get_program_info_mult_devices(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_large_compile(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); diff --git a/test_conformance/compiler/testBase.h b/test_conformance/compiler/testBase.h index 5b49bfd7..7edfb2da 100644 --- a/test_conformance/compiler/testBase.h +++ b/test_conformance/compiler/testBase.h @@ -25,6 +25,26 @@ #include "procs.h" +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto &device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + #endif // _testBase_h diff --git a/test_conformance/compiler/test_build_helpers.cpp b/test_conformance/compiler/test_build_helpers.cpp index 72e11e73..3caac8db 100644 --- a/test_conformance/compiler/test_build_helpers.cpp +++ b/test_conformance/compiler/test_build_helpers.cpp @@ -17,6 +17,10 @@ #include "harness/testHarness.h" #include "harness/parseParameters.h" +#include +#include +#include + const char *sample_kernel_code_single_line[] = { "__kernel void sample_test(__global float *src, __global int *dst)\n" "{\n" @@ -333,8 +337,9 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ size_t paramSize; cl_uint numInstances; - error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line); + test_error(error, "create_single_kernel_helper_create_program failed"); + if( program == NULL ) { log_error( "ERROR: Unable to create reference program!\n" ); @@ -346,18 +351,9 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ error = clGetProgramInfo( program, CL_PROGRAM_DEVICES, sizeof( device1 ), &device1, NULL ); test_error( error, "Unable to get device of program" ); - /* Since the device IDs are opaque types we check the CL_DEVICE_VENDOR_ID which is unique for identical hardware. */ - cl_uint device1_vid, deviceID_vid; - error = clGetDeviceInfo(device1, CL_DEVICE_VENDOR_ID, sizeof(device1_vid), &device1_vid, NULL ); - test_error( error, "Unable to get device CL_DEVICE_VENDOR_ID" ); - error = clGetDeviceInfo(deviceID, CL_DEVICE_VENDOR_ID, sizeof(deviceID_vid), &deviceID_vid, NULL ); - test_error( error, "Unable to get device CL_DEVICE_VENDOR_ID" ); - - if( device1_vid != deviceID_vid ) - { - log_error( "ERROR: Incorrect device returned for program! (Expected vendor ID 0x%x, got 0x%x)\n", deviceID_vid, device1_vid ); - return -1; - } + /* Object comparability test. */ + test_assert_error(device1 == deviceID, + "Unexpected result returned by CL_PROGRAM_DEVICES query"); cl_uint devCount; error = clGetProgramInfo( program, CL_PROGRAM_NUM_DEVICES, sizeof( devCount ), &devCount, NULL ); @@ -422,6 +418,134 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ return 0; } +int test_get_program_info_mult_devices(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, int num_elements) +{ + size_t size = 0; + + // query multi-device context and perform objects comparability test + cl_int err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, 0, + nullptr, &size); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (size == 0) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + std::vector supported_props( + size / sizeof(cl_device_partition_property), 0); + err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, + supported_props.size() + * sizeof(cl_device_partition_property), + supported_props.data(), &size); + test_error_fail(err, "clGetDeviceInfo failed"); + + if (supported_props.empty() || supported_props.front() == 0) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_uint maxComputeUnits = 0; + err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, nullptr); + test_error_ret(err, "Unable to get maximal number of compute units", + TEST_FAIL); + + std::vector> partition_props = { + { CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1, + CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 } + }; + + std::unique_ptr scope_guard; + cl_uint num_devices = 0; + for (auto &sup_prop : supported_props) + { + for (auto &prop : partition_props) + { + if (sup_prop == prop[0]) + { + // how many sub-devices can we create? + err = clCreateSubDevices(deviceID, prop.data(), 0, nullptr, + &num_devices); + test_error_fail(err, "clCreateSubDevices failed"); + if (num_devices < 2) continue; + + // get the list of subDevices + scope_guard.reset(new SubDevicesScopeGuarded(num_devices)); + err = clCreateSubDevices(deviceID, prop.data(), num_devices, + scope_guard->sub_devices.data(), + &num_devices); + test_error_fail(err, "clCreateSubDevices failed"); + break; + } + } + if (scope_guard.get() != nullptr) break; + } + + if (scope_guard.get() == nullptr) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + /* Create a multi device context */ + clContextWrapper multi_device_context = clCreateContext( + nullptr, (cl_uint)num_devices, scope_guard->sub_devices.data(), nullptr, + nullptr, &err); + test_error_ret(err, "Unable to create testing context", + TEST_SKIPPED_ITSELF); + + clProgramWrapper program = nullptr; + err = create_single_kernel_helper_create_program( + multi_device_context, &program, 1, sample_kernel_code_single_line); + test_error_ret(err, "create_single_kernel_helper_create_program failed", + TEST_FAIL); + + if (program == nullptr) + { + log_error("ERROR: Unable to create reference program!\n"); + return -1; + } + + err = clGetProgramInfo(program, CL_PROGRAM_NUM_DEVICES, sizeof(num_devices), + &num_devices, nullptr); + test_error_ret(err, "Unable to get device count of program", TEST_FAIL); + + test_assert_error_ret( + num_devices == scope_guard->sub_devices.size(), + "Program must be associated to exact number of devices\n", TEST_FAIL); + + std::vector devices(num_devices); + err = clGetProgramInfo(program, CL_PROGRAM_DEVICES, + num_devices * sizeof(cl_device_id), devices.data(), + nullptr); + test_error_ret(err, "Unable to get devices of program", TEST_FAIL); + + for (cl_uint i = 0; i < devices.size(); i++) + { + bool found = false; + for (auto &it : scope_guard->sub_devices) + { + if (it == devices[i]) + { + found = true; + break; + } + } + test_error_fail( + !found, "Unexpected result returned by CL_CONTEXT_DEVICES query"); + } + + return TEST_PASS; +} + int test_get_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { cl_program program; From c84b71236661e567265ede388d4fc3bd17e2afc0 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 25 Feb 2025 17:48:05 +0100 Subject: [PATCH 16/36] Added object comparability verification for program devices query (#2237) Fixes #1485 according to work plan from issue description. From 803e6656832219b787bd53632d4e99147dc72864 Mon Sep 17 00:00:00 2001 From: Ahmed <36049290+AhmedAmraniAkdi@users.noreply.github.com> Date: Tue, 25 Feb 2025 20:54:26 +0000 Subject: [PATCH 17/36] Correct reference for fma for RTZ devices for half (#2269) The reference was always being calculated using round to nearest even for fma when testing half precision. Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/2224 --- .../math_brute_force/reference_math.cpp | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test_conformance/math_brute_force/reference_math.cpp b/test_conformance/math_brute_force/reference_math.cpp index 90b4adb4..4d312c1e 100644 --- a/test_conformance/math_brute_force/reference_math.cpp +++ b/test_conformance/math_brute_force/reference_math.cpp @@ -2734,6 +2734,34 @@ static double round_to_nearest_even_double(cl_ulong hi, cl_ulong lo, return u.d; } +static double round_toward_zero_double(cl_ulong hi, cl_ulong lo, int exponent) +{ + union { + cl_ulong u; + cl_double d; + } u; + + // edges + if (exponent > 1023) return CL_DBL_MAX; + if (exponent <= -1074) return 0.0; + + // Figure out which bits go where + int shift = 11; + if (exponent < -1022) + { + shift -= 1022 + exponent; // subnormal: shift is not 52 + exponent = -1023; // set exponent to 0 + } + else + hi &= 0x7fffffffffffffffULL; // normal: leading bit is implicit. Remove + // it. + + // Assemble the double (round toward zero) + u.u = (hi >> shift) | ((cl_ulong)(exponent + 1023) << 52); + + return u.d; +} + // Shift right. Bits lost on the right will be OR'd together and OR'd with the // LSB static inline void shift_right_sticky_128(cl_ulong *hi, cl_ulong *lo, int shift) @@ -2966,7 +2994,14 @@ long double reference_fmal(long double x, long double y, long double z) } // round - ua.d = round_to_nearest_even_double(hi, lo, exponent); + if (gIsInRTZMode) + { + ua.d = round_toward_zero_double(hi, lo, exponent); + } + else + { + ua.d = round_to_nearest_even_double(hi, lo, exponent); + } // Set the sign ua.u |= sign; From 6419744d76100cf69b2738eeafe0e1c2fb425139 Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Tue, 25 Feb 2025 13:54:53 -0700 Subject: [PATCH 18/36] printf: Fix the format specifier for %A to add the decimal point (#2290) --- test_conformance/printf/test_printf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/printf/test_printf.cpp b/test_conformance/printf/test_printf.cpp index e2991f39..69bf1abb 100644 --- a/test_conformance/printf/test_printf.cpp +++ b/test_conformance/printf/test_printf.cpp @@ -247,7 +247,7 @@ cl_program makeMixedFormatPrintfProgram(cl_kernel* kernel_ptr, }; std::array, 2> formats = { - { { "%f", "%e", "%g", "%13a", "%F", "%E", "%G", "%13A" }, + { { "%f", "%e", "%g", "%.13a", "%F", "%E", "%G", "%.13A" }, { "%d", "%i", "%u", "%x", "%o", "%X" } } }; std::vector data_before(2 + genrand_int32(gMTdata) % 8); From 9ba6f062d4f7acc01df515beaad8309cc3b59af0 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:51:22 +0000 Subject: [PATCH 19/36] Add support for allocating DMA buffers (#2170) This adds support for allocating DMA buffers on systems that support it, i.e. Linux and Android. On mainline Linux, starting version 5.6 (equivalent to Android 12), there is a new kernel module framework available called [DMA-BUF Heaps](https://github.com/torvalds/linux/blob/master/drivers/dma-buf/dma-heap.c). The goal of this framework is to provide a standardised way for user applications to allocate and share memory buffers between different devices, subsystems, etc. The main feature of interest is that the framework provides device-agnostic allocation; it abstracts away the underlying hardware, and provides a single IOCTL, `DMA_HEAP_IOCTL_ALLOC`. Mainline implementation provides two heaps that act as character devices that can allocate DMA buffers; system, which uses the buddy allocator, and cma, which uses the [CMA](https://developer.toradex.com/software/linux-resources/linux-features/contiguous-memory-allocator-cma-linux/) (Contiguous Memory Allocator). Both of these are [kernel configuration options](https://github.com/torvalds/linux/blob/master/drivers/dma-buf/heaps/Kconfig) that need to be enabled when building the Linux kernel. Generally, any kernel module implementing this framework is made available under /dev/dma_heaps/, e.g. /dev/dma_heaps/system. The implementation currently only supports one type of DMA heaps; `system`, the default device path for which is `/dev/dma_heap/system`. The path can be overridden at runtime using an environment variable, `OCL_CTS_DMA_HEAP_PATH_SYSTEM`, if needed. Extending this in the future should be trivial (subject to platform support), by adding an entry to the enum `dma_buf_heap_type`, and an appropriate default path and overriding environment variable name. The proposed implementation will conditionally compile if the conditions are met (i.e. building for Linux or Android, using kernel headers >= 5.6.0), and will provide a compile-time warning otherwise, and return `-1` as the DMA handle in runtime if not. To demonstrate the functionality, a new test is added for the `cl_khr_external_memory_dma_buf` extension. If the extension is supported by the device, a DMA buffer will be allocated and used to create a CL buffer, that is then used by a simple kernel. This should provide a way forward for adding more tests that depend on DMA buffers. --------- Signed-off-by: Gorazd Sumkovski Signed-off-by: Ahmed Hesham Co-authored-by: Gorazd Sumkovski --- test_common/CMakeLists.txt | 1 + test_common/harness/alloc.cpp | 123 +++++++++++++++ test_common/harness/alloc.h | 39 ++++- test_conformance/extensions/CMakeLists.txt | 1 + .../CMakeLists.txt | 8 + .../cl_khr_external_memory_dma_buf/main.cpp | 23 +++ .../test_external_memory_dma_buf.cpp | 143 ++++++++++++++++++ 7 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 test_common/harness/alloc.cpp create mode 100644 test_conformance/extensions/cl_khr_external_memory_dma_buf/CMakeLists.txt create mode 100644 test_conformance/extensions/cl_khr_external_memory_dma_buf/main.cpp create mode 100644 test_conformance/extensions/cl_khr_external_memory_dma_buf/test_external_memory_dma_buf.cpp diff --git a/test_common/CMakeLists.txt b/test_common/CMakeLists.txt index b0505345..3acc742c 100644 --- a/test_common/CMakeLists.txt +++ b/test_common/CMakeLists.txt @@ -1,5 +1,6 @@ set(HARNESS_SOURCES + harness/alloc.cpp harness/typeWrappers.cpp harness/mt19937.cpp harness/conversions.cpp diff --git a/test_common/harness/alloc.cpp b/test_common/harness/alloc.cpp new file mode 100644 index 00000000..685ff272 --- /dev/null +++ b/test_common/harness/alloc.cpp @@ -0,0 +1,123 @@ +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "alloc.h" +#include "errorHelpers.h" +#include "testHarness.h" + +#if defined(linux) || defined(__linux__) || defined(__ANDROID__) +#include +#include +#include +#include +#include +#include +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +#include +#endif + +struct dma_buf_heap_helper_t +{ + dma_buf_heap_type heap_type; + const char* env_var = nullptr; + const char* default_path = nullptr; + + constexpr dma_buf_heap_helper_t(dma_buf_heap_type heap_type, + const char* env_var, + const char* default_path) + : heap_type(heap_type), env_var(env_var), default_path(default_path) + {} +}; + +constexpr dma_buf_heap_helper_t DMA_BUF_HEAP_TABLE[] = { + { dma_buf_heap_type::SYSTEM, "OCL_CTS_DMA_HEAP_PATH_SYSTEM", + "/dev/dma_heap/system" }, +}; + +static dma_buf_heap_helper_t lookup_dma_heap(dma_buf_heap_type heap_type) +{ + for (const auto& entry : DMA_BUF_HEAP_TABLE) + { + if (heap_type == entry.heap_type) + { + return entry; + } + } + + assert(false + && "DMA heap type does not have an entry in DMA_BUF_HEAP_TABLE"); + return DMA_BUF_HEAP_TABLE[0]; +} + +int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) + constexpr int DMA_HEAP_FLAGS = O_RDWR | O_CLOEXEC; + + const auto entry = lookup_dma_heap(heap_type); + const auto override_path = getenv(entry.env_var); + const auto dma_heap_path = + (override_path == nullptr) ? entry.default_path : override_path; + + const int dma_heap_fd = open(dma_heap_path, DMA_HEAP_FLAGS); + if (dma_heap_fd == -1) + { + log_error( + "Opening the DMA heap device: %s failed with error: %d (%s)\n", + dma_heap_path, errno, strerror(errno)); + + return TEST_SKIPPED_ITSELF; + } + + dma_heap_allocation_data dma_heap_data = { 0 }; + dma_heap_data.len = size; + dma_heap_data.fd_flags = O_RDWR | O_CLOEXEC; + + int result = ioctl(dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &dma_heap_data); + if (result != 0) + { + log_error("DMA heap allocation IOCTL call failed, error: %d\n", result); + + close(dma_heap_fd); + return -1; + } + + result = close(dma_heap_fd); + if (result == -1) + { + log_info("Failed to close the DMA heap device: %s\n", dma_heap_path); + } + + return dma_heap_data.fd; +#else +#warning \ + "Kernel version doesn't support DMA buffer heaps (at least v5.6.0 is required)." + return TEST_SKIPPED_ITSELF; +#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +} + +#else +int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type) +{ + log_error( + "OS doesn't have DMA buffer heaps (only Linux and Android do).\n"); + + return TEST_SKIPPED_ITSELF; +} +#endif // defined(linux) || defined(__linux__) || defined(__ANDROID__) diff --git a/test_common/harness/alloc.h b/test_common/harness/alloc.h index 3b00d7c9..49093c71 100644 --- a/test_common/harness/alloc.h +++ b/test_common/harness/alloc.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2020 The Khronos Group Inc. +// Copyright (c) 2020 - 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. @@ -24,11 +24,16 @@ #include #endif #endif +#include #if defined(__MINGW32__) #include "mingw_compat.h" #endif +#if defined(_WIN32) +#include +#endif + inline void* align_malloc(size_t size, size_t alignment) { #if defined(_WIN32) && defined(_MSC_VER) @@ -66,4 +71,36 @@ inline void align_free(void* ptr) #endif } +enum class dma_buf_heap_type +{ + SYSTEM +}; + +/** + * @brief Allocate a DMA buffer. + * + * On systems that support it, use the DMA buffer heaps to allocate a DMA buffer + * of the requested size, using the requested heap type. The heap type defaults + * to using the system heap if no type is specified. + * + * A heap type will use a default path if one exists, and can be overriden using + * an environment variable for each type, as follows: + * + * SYSTEM: + * * Default path: /dev/dma_heap/system + * * Environment variable: OCL_CTS_DMA_HEAP_PATH_SYSTEM + * + * DMA buffer heaps require a minimum Linux kernel version 5.6. A compile-time + * warning is issued on older systems, as well as an error message at runtime. + * + * @param size [in] The requested buffer size in bytes. + * @param heap_type [in,opt] The heap type to use for the allocation. + * + * @retrun A file descriptor representing the allocated DMA buffer on success, + * -1 otherwise. Failure to open the DMA device returns TEST_SKIPPED_ITSELF so + * it can be handled separately to other failures. + */ +int allocate_dma_buf(uint64_t size, + dma_buf_heap_type heap_type = dma_buf_heap_type::SYSTEM); + #endif // #ifndef HARNESS_ALLOC_H_ diff --git a/test_conformance/extensions/CMakeLists.txt b/test_conformance/extensions/CMakeLists.txt index e0e790c2..d064e8a9 100644 --- a/test_conformance/extensions/CMakeLists.txt +++ b/test_conformance/extensions/CMakeLists.txt @@ -5,6 +5,7 @@ add_subdirectory( cl_ext_cxx_for_opencl ) add_subdirectory( cl_khr_command_buffer ) add_subdirectory( cl_khr_dx9_media_sharing ) +add_subdirectory( cl_khr_external_memory_dma_buf ) add_subdirectory( cl_khr_semaphore ) add_subdirectory( cl_khr_kernel_clock ) if(VULKAN_IS_SUPPORTED) diff --git a/test_conformance/extensions/cl_khr_external_memory_dma_buf/CMakeLists.txt b/test_conformance/extensions/cl_khr_external_memory_dma_buf/CMakeLists.txt new file mode 100644 index 00000000..c5a45a6c --- /dev/null +++ b/test_conformance/extensions/cl_khr_external_memory_dma_buf/CMakeLists.txt @@ -0,0 +1,8 @@ +set(MODULE_NAME CL_KHR_EXTERNAL_MEMORY_DMA_BUF) + +set(${MODULE_NAME}_SOURCES + main.cpp + test_external_memory_dma_buf.cpp +) + +include(../../CMakeCommon.txt) diff --git a/test_conformance/extensions/cl_khr_external_memory_dma_buf/main.cpp b/test_conformance/extensions/cl_khr_external_memory_dma_buf/main.cpp new file mode 100644 index 00000000..b0f8a718 --- /dev/null +++ b/test_conformance/extensions/cl_khr_external_memory_dma_buf/main.cpp @@ -0,0 +1,23 @@ +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "harness/testHarness.h" + +int main(int argc, const char *argv[]) +{ + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); +} diff --git a/test_conformance/extensions/cl_khr_external_memory_dma_buf/test_external_memory_dma_buf.cpp b/test_conformance/extensions/cl_khr_external_memory_dma_buf/test_external_memory_dma_buf.cpp new file mode 100644 index 00000000..dc158e30 --- /dev/null +++ b/test_conformance/extensions/cl_khr_external_memory_dma_buf/test_external_memory_dma_buf.cpp @@ -0,0 +1,143 @@ +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include "harness/typeWrappers.h" +#include "harness/testHarness.h" + +static const char* kernel_function_inc_buffer = R"( + kernel void inc_buffer(global uint *src, global uint *imp, global uint *dst) + { + uint global_id = get_global_id(0); + + imp[global_id] = src[global_id] + 1; + dst[global_id] = imp[global_id] + 1; + } + )"; + +/** + * Demonstrate the functionality of the cl_khr_external_memory_dma_buf extension + * by creating an imported buffer from a DMA buffer, then writing into, and + * reading from it. + */ + +REGISTER_TEST(external_memory_dma_buf) +{ + if (!is_extension_available(device, "cl_khr_external_memory_dma_buf")) + { + log_info("The device does not support the " + "cl_khr_external_memory_dma_buf extension.\n"); + + return TEST_SKIPPED_ITSELF; + } + + const size_t buffer_size = static_cast(num_elements); + const size_t buffer_size_bytes = sizeof(uint32_t) * buffer_size; + + clProgramWrapper program; + clKernelWrapper kernel; + cl_int error; + + error = + create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_function_inc_buffer, "inc_buffer"); + test_error(error, "Failed to create program with source."); + + /* Source buffer initialisation */ + std::vector src_data(buffer_size); + // Arithmetic progression starting at 0 and incrementing by 1 + std::iota(std::begin(src_data), std::end(src_data), 0); + + clMemWrapper src_buffer = + clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, + buffer_size_bytes, src_data.data(), &error); + test_error(error, "Failed to create the source buffer."); + + /* Imported buffer creation */ + int dma_buf_fd = allocate_dma_buf(buffer_size_bytes); + if (dma_buf_fd < 0) + { + if (dma_buf_fd == TEST_SKIPPED_ITSELF) + { + return TEST_SKIPPED_ITSELF; + } + + log_error( + "Failed to obtain a valid DMA buffer file descriptor, got %i.\n", + dma_buf_fd); + + return TEST_FAIL; + } + + const cl_mem_properties ext_mem_properties[] = { + CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR, + static_cast(dma_buf_fd), CL_PROPERTIES_LIST_END_EXT + }; + + clMemWrapper imp_buffer = clCreateBufferWithProperties( + context, ext_mem_properties, CL_MEM_READ_WRITE, buffer_size_bytes, + nullptr, &error); + test_error(error, "Failed to create the imported buffer."); + + /* Destination buffer creation */ + clMemWrapper dst_buffer = clCreateBuffer( + context, CL_MEM_WRITE_ONLY, buffer_size_bytes, nullptr, &error); + test_error(error, "Failed to create the destination buffer."); + + /* Kernel arguments setup */ + error = clSetKernelArg(kernel, 0, sizeof(src_buffer), &src_buffer); + test_error(error, "Failed to set kernel argument 0 to src_buffer."); + + error = clSetKernelArg(kernel, 1, sizeof(imp_buffer), &imp_buffer); + test_error(error, "Failed to set kernel argument 1 to imp_buffer."); + + error = clSetKernelArg(kernel, 2, sizeof(dst_buffer), &dst_buffer); + test_error(error, "Failed to set kernel argument 2 to dst_buffer."); + + /* Kernel execution */ + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &buffer_size, + nullptr, 0, nullptr, nullptr); + test_error(error, "Failed to enqueue the kernel."); + + error = clFinish(queue); + test_error(error, "Failed to finish the queue."); + + /* Verification */ + std::vector dst_data(buffer_size, 0); + + error = clEnqueueReadBuffer(queue, dst_buffer, CL_BLOCKING, 0, + buffer_size_bytes, dst_data.data(), 0, nullptr, + nullptr); + test_error(error, "Failed to read the contents of the destination buffer."); + + std::vector expected_data(buffer_size); + std::iota(std::begin(expected_data), std::end(expected_data), 2); + + for (size_t i = 0; i < buffer_size; ++i) + { + if (dst_data[i] != expected_data[i]) + { + log_error( + "Verification failed at index %zu, expected %u but got %u\n", i, + expected_data[i], dst_data[i]); + + return TEST_FAIL; + } + } + + return TEST_PASS; +} From a7c4d7f4c74b1bce88971faea9e3c2fcc20fcc07 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Wed, 26 Feb 2025 18:55:38 +0100 Subject: [PATCH 20/36] Added test to verify program queries after rebuilding (#2253) Fixes #2163 according to issue description --- test_conformance/compiler/main.cpp | 1 + test_conformance/compiler/procs.h | 5 +- .../compiler/test_build_helpers.cpp | 137 +++++++++++++++++- 3 files changed, 141 insertions(+), 2 deletions(-) diff --git a/test_conformance/compiler/main.cpp b/test_conformance/compiler/main.cpp index 167d092b..8f9ffb15 100644 --- a/test_conformance/compiler/main.cpp +++ b/test_conformance/compiler/main.cpp @@ -35,6 +35,7 @@ test_definition test_list[] = { ADD_TEST(get_program_source), ADD_TEST(get_program_build_info), ADD_TEST(get_program_info), + ADD_TEST(get_program_info_kernel_names), ADD_TEST(get_program_info_mult_devices), ADD_TEST(large_compile), diff --git a/test_conformance/compiler/procs.h b/test_conformance/compiler/procs.h index a10c436f..13420e9d 100644 --- a/test_conformance/compiler/procs.h +++ b/test_conformance/compiler/procs.h @@ -71,11 +71,14 @@ extern int test_get_program_build_info(cl_device_id deviceID, int num_elements); extern int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_get_program_info_kernel_names(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_get_program_info_mult_devices(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - extern int test_large_compile(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_async_build(cl_device_id deviceID, cl_context context, diff --git a/test_conformance/compiler/test_build_helpers.cpp b/test_conformance/compiler/test_build_helpers.cpp index 3caac8db..05dac356 100644 --- a/test_conformance/compiler/test_build_helpers.cpp +++ b/test_conformance/compiler/test_build_helpers.cpp @@ -65,6 +65,28 @@ const char *sample_kernel_code_bad_multi_line[] = { "", "}" }; +const char *sample_multi_kernel_code_with_macro = R"( +__kernel void sample_test_A(__global float *src, __global int *dst) +{ + size_t tid = get_global_id(0); + dst[tid] = (int)src[tid]; +} + +#ifdef USE_SAMPLE_TEST_B +__kernel void sample_test_B(__global float *src, __global int *dst) +{ + size_t tid = get_global_id(0); + dst[tid] = (int)src[tid]; +} +#endif + +__kernel void sample_test_C(__global float *src, __global int *dst) +{ + size_t tid = get_global_id(0); + dst[tid] = (int)src[tid]; +} +)"; + int test_load_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { @@ -242,7 +264,6 @@ int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_contex return 0; } - int test_load_discreet_length_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { int error; @@ -418,6 +439,120 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ return 0; } +int test_get_program_info_kernel_names(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, int num_elements) +{ + int error = CL_SUCCESS; + size_t total_kernels = 0; + size_t kernel_names_len = 0; + + clProgramWrapper program = nullptr; + + // 1) Program without build call. Query CL_PROGRAM_NUM_KERNELS and check + // that it fails with CL_INVALID_PROGRAM_EXECUTABLE. Query + // CL_PROGRAM_KERNEL_NAMES and check that it fails with + // CL_INVALID_PROGRAM_EXECUTABLE. + { + program = clCreateProgramWithSource( + context, 1, &sample_multi_kernel_code_with_macro, nullptr, &error); + test_error(error, "clCreateProgramWithSource failed"); + + error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS, + sizeof(size_t), &total_kernels, nullptr); + test_failure_error(error, CL_INVALID_PROGRAM_EXECUTABLE, + "Unexpected clGetProgramInfo result"); + + error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr, + &kernel_names_len); + test_failure_error(error, CL_INVALID_PROGRAM_EXECUTABLE, + "Unexpected clGetProgramInfo result"); + } + + // 2) Build the program with the preprocessor macro undefined. + // Query CL_PROGRAM_NUM_KERNELS and check that the correct number is + // returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right + // kernel names are returned. + { + error = + clBuildProgram(program, 1, &deviceID, nullptr, nullptr, nullptr); + test_error(error, "clBuildProgram failed"); + + error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS, + sizeof(size_t), &total_kernels, nullptr); + test_error(error, "clGetProgramInfo failed"); + + test_assert_error(total_kernels == 2, + "Unexpected clGetProgramInfo result"); + + error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr, + &kernel_names_len); + test_error(error, "clGetProgramInfo failed"); + + std::vector actual_names = { "sample_test_A", + "sample_test_C" }; + + const size_t len = kernel_names_len + 1; + std::vector kernel_names(len, '\0'); + error = + clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len, + kernel_names.data(), &kernel_names_len); + test_error(error, "Unable to get kernel names list."); + + std::string program_names = kernel_names.data(); + for (const auto &name : actual_names) + { + test_assert_error(program_names.find(name) != std::string::npos, + "Unexpected kernel name"); + } + + test_assert_error(program_names.find("sample_test_B") + == std::string::npos, + "sample_test_B should not be present"); + } + + // 3) Build the program again with the preprocessor macro defined. + // Query CL_PROGRAM_NUM_KERNELS and check that the correct number is + // returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right + // kernel names are returned. + { + const char *build_options = "-DUSE_SAMPLE_TEST_B"; + error = clBuildProgram(program, 1, &deviceID, build_options, nullptr, + nullptr); + test_error(error, "clBuildProgram failed"); + + error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS, + sizeof(size_t), &total_kernels, nullptr); + test_error(error, "clGetProgramInfo failed"); + + test_assert_error(total_kernels == 3, + "Unexpected clGetProgramInfo result"); + + error = clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, 0, nullptr, + &kernel_names_len); + test_error(error, "clGetProgramInfo failed"); + + std::vector actual_names = { "sample_test_A", + "sample_test_B", + "sample_test_C" }; + + const size_t len = kernel_names_len + 1; + std::vector kernel_names(len, '\0'); + error = + clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len, + kernel_names.data(), &kernel_names_len); + test_error(error, "Unable to get kernel names list."); + + std::string program_names = kernel_names.data(); + for (const auto &name : actual_names) + { + test_assert_error(program_names.find(name) != std::string::npos, + "Unexpected kernel name"); + } + } + return CL_SUCCESS; +} + int test_get_program_info_mult_devices(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) From 5a652786133defe33e5f47510c8b57e62ae580c9 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Thu, 27 Feb 2025 15:30:08 +0000 Subject: [PATCH 21/36] Fix compilation failure caused by DMA heaps (#2292) Project fails to build on systems with a kernel version older than 5.6.0 because of `-Wunused-function` combined with `-Werror`. Expand the conditional compilation guard to include the offending code. --- test_common/harness/alloc.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test_common/harness/alloc.cpp b/test_common/harness/alloc.cpp index 685ff272..2a42dd7c 100644 --- a/test_common/harness/alloc.cpp +++ b/test_common/harness/alloc.cpp @@ -30,7 +30,6 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) #include -#endif struct dma_buf_heap_helper_t { @@ -64,6 +63,7 @@ static dma_buf_heap_helper_t lookup_dma_heap(dma_buf_heap_type heap_type) && "DMA heap type does not have an entry in DMA_BUF_HEAP_TABLE"); return DMA_BUF_HEAP_TABLE[0]; } +#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type) { @@ -106,8 +106,6 @@ int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type) return dma_heap_data.fd; #else -#warning \ - "Kernel version doesn't support DMA buffer heaps (at least v5.6.0 is required)." return TEST_SKIPPED_ITSELF; #endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) } From 5167d7202b1e43418ecb2928841dff51cb011221 Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Wed, 5 Mar 2025 00:51:18 +0000 Subject: [PATCH 22/36] Fix signalling and waiting on semaphore from two queues (#2271) `semaphores_ooo_ops_cross_queue` uses two OOO command queues to run the test. In one queue, a semaphore is signalled and the semahpore is waited on in the other queue. The CL specification requires the application to synchronize the queues if objects are shared. Signed-off-by: Michael Rizkalla --- .../cl_khr_semaphore/test_semaphores_cross_queue.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp index 0a86d5aa..4067fd4e 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp @@ -266,6 +266,15 @@ struct SemaphoreOutOfOrderOps : public SemaphoreTestBase err = clEnqueueBarrierWithWaitList(consumer_queue, 0, nullptr, nullptr); test_error(err, " clEnqueueBarrierWithWaitList "); + if (!single_queue) + { + // Both producer and consumer queues run independently. + // A blocking call to clEnqueueReadBuffer in consumer_queue will not + // flush the producer queue. + err = clFlush(producer_queue); + test_error(err, "clFlush failed"); + } + std::vector host_buffer(num_elems, 0); auto verify_result = [&](const cl_mem &out_mem, const cl_int pattern) { err = clEnqueueReadBuffer(consumer_queue, out_mem, CL_TRUE, 0, From 7feb93cdd7b2f19d7bbd974f273e3e1e67420249 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Wed, 5 Mar 2025 01:52:28 +0100 Subject: [PATCH 23/36] math_brute_force: treat reciprocal as unary function (#2281) Treat reciprocal as a unary function, instead of handling it through the binary function testing mechanism and special-casing it there. This addresses two shortcomings of the previous implementation: - Testing took significantly longer as the entire input domain was tested many times (e.g. fp16 reciprocal has only 2^16 possible input values, but binary function testing iterates over 2^16 * 2^16 input values). - The reciprocal test kernel was identical to the divide kernel. Thus the device compiler would see a regular divide operation instead of a reciprocal operation and would be unlikely to emit a specialized reciprocal sequence. This reverts all of the changes in binary_operator*.cpp made by bcfa1f7c2 ("Added corrections to re-enable reciprocal test in math_brute_force suite for relaxed math mode (#2221)", 2025-02-04). Signed-off-by: Sven van Haastregt --- .../binary_operator_double.cpp | 38 +++------- .../binary_operator_float.cpp | 70 +++++-------------- .../math_brute_force/binary_operator_half.cpp | 48 ++++--------- .../math_brute_force/function_list.cpp | 5 +- .../math_brute_force/unary_double.cpp | 7 +- .../math_brute_force/unary_float.cpp | 7 +- .../math_brute_force/unary_half.cpp | 7 +- 7 files changed, 62 insertions(+), 120 deletions(-) diff --git a/test_conformance/math_brute_force/binary_operator_double.cpp b/test_conformance/math_brute_force/binary_operator_double.cpp index 4dce5052..35d93f84 100644 --- a/test_conformance/math_brute_force/binary_operator_double.cpp +++ b/test_conformance/math_brute_force/binary_operator_double.cpp @@ -214,12 +214,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) cl_double *s; cl_double *s2; - bool reciprocal = strcmp(name, "reciprocal") == 0; - const double reciprocalArrayX[] = { 1.0 }; - const double *specialValuesX = - reciprocal ? reciprocalArrayX : specialValues; - size_t specialValuesCountX = reciprocal ? 1 : specialValuesCount; - Force64BitFPUPrecision(); cl_event e[VECTOR_SIZE_COUNT]; @@ -248,7 +242,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) cl_ulong *p = (cl_ulong *)gIn + thread_id * buffer_elements; cl_ulong *p2 = (cl_ulong *)gIn2 + thread_id * buffer_elements; cl_uint idx = 0; - int totalSpecialValueCount = specialValuesCountX * specialValuesCount; + int totalSpecialValueCount = specialValuesCount * specialValuesCount; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; // Test edge cases @@ -258,15 +252,14 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) cl_double *fp2 = (cl_double *)p2; uint32_t x, y; - x = (job_id * buffer_elements) % specialValuesCountX; + x = (job_id * buffer_elements) % specialValuesCount; y = (job_id * buffer_elements) / specialValuesCount; for (; idx < buffer_elements; idx++) { - fp[idx] = specialValuesX[x]; + fp[idx] = specialValues[x]; fp2[idx] = specialValues[y]; - ++x; - if (x >= specialValuesCountX) + if (++x >= specialValuesCount) { x = 0; y++; @@ -278,8 +271,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) // Init any remaining values for (; idx < buffer_elements; idx++) { - p[idx] = - reciprocal ? ((cl_ulong *)specialValuesX)[0] : genrand_int64(d); + p[idx] = genrand_int64(d); p2[idx] = genrand_int64(d); } @@ -372,13 +364,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) r = (cl_double *)gOut_Ref + thread_id * buffer_elements; s = (cl_double *)gIn + thread_id * buffer_elements; s2 = (cl_double *)gIn2 + thread_id * buffer_elements; - - if (reciprocal) - for (size_t j = 0; j < buffer_elements; j++) - r[j] = (float)func.f_f(s2[j]); - else - for (size_t j = 0; j < buffer_elements; j++) - r[j] = (cl_double)func.f_ff(s[j], s2[j]); + for (size_t j = 0; j < buffer_elements; j++) + r[j] = (cl_double)func.f_ff(s[j], s2[j]); // Read the data back -- no need to wait for the first N-1 buffers but wait // for the last buffer. This is an in order queue. @@ -408,9 +395,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (t[j] != q[j]) { cl_double test = ((cl_double *)q)[j]; - long double correct = - reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]); - + long double correct = func.f_ff(s[j], s2[j]); float err = Bruteforce_Ulp_Error_Double(test, correct); int fail = !(fabsf(err) <= ulps); @@ -483,11 +468,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) } else if (IsDoubleSubnormal(s2[j])) { - long double correct2 = - reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0); - long double correct3 = - reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0); - + long double correct2 = func.f_ff(s[j], 0.0); + long double correct3 = func.f_ff(s[j], -0.0); float err2 = Bruteforce_Ulp_Error_Double(test, correct2); float err3 = diff --git a/test_conformance/math_brute_force/binary_operator_float.cpp b/test_conformance/math_brute_force/binary_operator_float.cpp index c0c11c2e..cce6e122 100644 --- a/test_conformance/math_brute_force/binary_operator_float.cpp +++ b/test_conformance/math_brute_force/binary_operator_float.cpp @@ -208,11 +208,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) cl_float *s2 = 0; RoundingMode oldRoundMode; - bool reciprocal = strcmp(name, "reciprocal") == 0; - const float reciprocalArrayX[] = { 1.f }; - const float *specialValuesX = reciprocal ? reciprocalArrayX : specialValues; - size_t specialValuesCountX = reciprocal ? 1 : specialValuesCount; - if (relaxedMode) { func = job->f->rfunc; @@ -244,7 +239,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) cl_uint *p = (cl_uint *)gIn + thread_id * buffer_elements; cl_uint *p2 = (cl_uint *)gIn2 + thread_id * buffer_elements; cl_uint idx = 0; - int totalSpecialValueCount = specialValuesCountX * specialValuesCount; + int totalSpecialValueCount = specialValuesCount * specialValuesCount; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; if (job_id <= (cl_uint)lastSpecialJobIndex) @@ -252,15 +247,15 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) // Insert special values uint32_t x, y; - x = (job_id * buffer_elements) % specialValuesCountX; + x = (job_id * buffer_elements) % specialValuesCount; y = (job_id * buffer_elements) / specialValuesCount; for (; idx < buffer_elements; idx++) { - p[idx] = ((cl_uint *)specialValuesX)[x]; + p[idx] = ((cl_uint *)specialValues)[x]; p2[idx] = ((cl_uint *)specialValues)[y]; ++x; - if (x >= specialValuesCountX) + if (x >= specialValuesCount) { x = 0; y++; @@ -274,19 +269,13 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (pj < 0x20800000 || pj > 0x5e800000) p[idx] = 0x7fc00000; if (p2j < 0x20800000 || p2j > 0x5e800000) p2[idx] = 0x7fc00000; } - else if (relaxedMode && reciprocal) - { - cl_uint p2j = p2[idx] & 0x7fffffff; - // Replace values outside [2^-126, 2^126] with QNaN - if (p2j < 0x00807d99 || p2j > 0x7e800000) p2[idx] = 0x7fc00000; - } } } // Init any remaining values for (; idx < buffer_elements; idx++) { - p[idx] = reciprocal ? ((cl_uint *)specialValuesX)[0] : genrand_int32(d); + p[idx] = genrand_int32(d); p2[idx] = genrand_int32(d); if (relaxedMode && strcmp(name, "divide") == 0) @@ -297,12 +286,6 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (pj < 0x20800000 || pj > 0x5e800000) p[idx] = 0x7fc00000; if (p2j < 0x20800000 || p2j > 0x5e800000) p2[idx] = 0x7fc00000; } - else if (relaxedMode && reciprocal) - { - cl_uint p2j = p2[idx] & 0x7fffffff; - // Replace values outside [2^-126, 2^126] with QNaN - if (p2j < 0x00807d99 || p2j > 0x7e800000) p2[idx] = 0x7fc00000; - } } if ((error = clEnqueueWriteBuffer(tinfo->tQueue, tinfo->inBuf, CL_FALSE, 0, @@ -408,31 +391,18 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) s2 = (float *)gIn2 + thread_id * buffer_elements; if (gInfNanSupport) { - if (reciprocal) - for (size_t j = 0; j < buffer_elements; j++) - r[j] = (float)func.f_f(s2[j]); - else - for (size_t j = 0; j < buffer_elements; j++) - r[j] = (float)func.f_ff(s[j], s2[j]); + for (size_t j = 0; j < buffer_elements; j++) + r[j] = (float)func.f_ff(s[j], s2[j]); } else { - if (reciprocal) - for (size_t j = 0; j < buffer_elements; j++) - { - feclearexcept(FE_OVERFLOW); - r[j] = (float)func.f_f(s2[j]); - overflow[j] = - FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW)); - } - else - for (size_t j = 0; j < buffer_elements; j++) - { - feclearexcept(FE_OVERFLOW); - r[j] = (float)func.f_ff(s[j], s2[j]); - overflow[j] = - FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW)); - } + for (size_t j = 0; j < buffer_elements; j++) + { + feclearexcept(FE_OVERFLOW); + r[j] = (float)func.f_ff(s[j], s2[j]); + overflow[j] = + FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW)); + } } if (gIsInRTZMode) (void)set_round(oldRoundMode, kfloat); @@ -467,8 +437,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (t[j] != q[j]) { float test = ((float *)q)[j]; - double correct = - reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]); + double correct = func.f_ff(s[j], s2[j]); // Per section 10 paragraph 6, accept any result if an input or // output is a infinity or NaN or overflow @@ -505,7 +474,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) } // retry per section 6.5.3.3 - if (!reciprocal && IsFloatSubnormal(s[j])) + if (IsFloatSubnormal(s[j])) { double correct2, correct3; float err2, err3; @@ -611,10 +580,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (!gInfNanSupport) feclearexcept(FE_OVERFLOW); - correct2 = - reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0); - correct3 = - reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0); + correct2 = func.f_ff(s[j], 0.0); + correct3 = func.f_ff(s[j], -0.0); // Per section 10 paragraph 6, accept any result if an // input or output is a infinity or NaN or overflow @@ -647,6 +614,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) } } + if (fabsf(err) > tinfo->maxError) { tinfo->maxError = fabsf(err); diff --git a/test_conformance/math_brute_force/binary_operator_half.cpp b/test_conformance/math_brute_force/binary_operator_half.cpp index 3bd45857..09d3ea01 100644 --- a/test_conformance/math_brute_force/binary_operator_half.cpp +++ b/test_conformance/math_brute_force/binary_operator_half.cpp @@ -120,12 +120,6 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) std::vector s(0), s2(0); RoundingMode oldRoundMode; - bool reciprocal = strcmp(name, "reciprocal") == 0; - const cl_half reciprocalArrayHalfX[] = { 0x3c00 }; - const cl_half *specialValuesHalfX = - reciprocal ? reciprocalArrayHalfX : specialValuesHalf; - size_t specialValuesHalfCountX = reciprocal ? 1 : specialValuesHalfCount; - cl_event e[VECTOR_SIZE_COUNT]; cl_half *out[VECTOR_SIZE_COUNT]; @@ -154,7 +148,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) cl_half *p2 = (cl_half *)gIn2 + thread_id * buffer_elements; cl_uint idx = 0; int totalSpecialValueCount = - specialValuesHalfCountX * specialValuesHalfCount; + specialValuesHalfCount * specialValuesHalfCount; int lastSpecialJobIndex = (totalSpecialValueCount - 1) / buffer_elements; if (job_id <= (cl_uint)lastSpecialJobIndex) @@ -162,15 +156,14 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) // Insert special values uint32_t x, y; - x = (job_id * buffer_elements) % specialValuesHalfCountX; + x = (job_id * buffer_elements) % specialValuesHalfCount; y = (job_id * buffer_elements) / specialValuesHalfCount; for (; idx < buffer_elements; idx++) { - p[idx] = specialValuesHalfX[x]; + p[idx] = specialValuesHalf[x]; p2[idx] = specialValuesHalf[y]; - ++x; - if (x >= specialValuesHalfCountX) + if (++x >= specialValuesHalfCount) { x = 0; y++; @@ -182,8 +175,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) // Init any remaining values for (; idx < buffer_elements; idx++) { - p[idx] = reciprocal ? ((cl_half *)specialValuesHalfX)[0] - : (cl_half)genrand_int32(d); + p[idx] = (cl_half)genrand_int32(d); p2[idx] = (cl_half)genrand_int32(d); } if ((error = clEnqueueWriteBuffer(tinfo->tQueue, tinfo->inBuf, CL_FALSE, 0, @@ -280,23 +272,11 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) s.resize(buffer_elements); s2.resize(buffer_elements); - if (reciprocal) + for (size_t j = 0; j < buffer_elements; j++) { - for (size_t j = 0; j < buffer_elements; j++) - { - s[j] = HTF(p[j]); - s2[j] = HTF(p2[j]); - r[j] = HFF(func.f_f(s2[j])); - } - } - else - { - for (size_t j = 0; j < buffer_elements; j++) - { - s[j] = HTF(p[j]); - s2[j] = HTF(p2[j]); - r[j] = HFF(func.f_ff(s[j], s2[j])); - } + s[j] = HTF(p[j]); + s2[j] = HTF(p2[j]); + r[j] = HFF(func.f_ff(s[j], s2[j])); } if (ftz) RestoreFPState(&oldMode); @@ -329,8 +309,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) if (r[j] != q[j]) { float test = HTF(q[j]); - float correct = - reciprocal ? func.f_f(s2[j]) : func.f_ff(s[j], s2[j]); + float correct = func.f_ff(s[j], s2[j]); // Per section 10 paragraph 6, accept any result if an input or // output is a infinity or NaN or overflow @@ -456,10 +435,9 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) double correct2, correct3; float err2, err3; - correct2 = - reciprocal ? func.f_f(0.0) : func.f_ff(s[j], 0.0); - correct3 = - reciprocal ? func.f_f(-0.0) : func.f_ff(s[j], -0.0); + correct2 = func.f_ff(s[j], 0.0); + correct3 = func.f_ff(s[j], -0.0); + // Per section 10 paragraph 6, accept any result if an // input or output is a infinity or NaN or overflow diff --git a/test_conformance/math_brute_force/function_list.cpp b/test_conformance/math_brute_force/function_list.cpp index 14e0830a..74f29930 100644 --- a/test_conformance/math_brute_force/function_list.cpp +++ b/test_conformance/math_brute_force/function_list.cpp @@ -427,9 +427,8 @@ const Func functionList[] = { // basic operations OPERATOR_ENTRY(add, "+", 0.0f, 0.0f, 0.0f, 0.0f, FTZ_OFF, binaryOperatorF), OPERATOR_ENTRY(subtract, "-", 0.0f, 0.0f, 0.0f, 0.0f, FTZ_OFF, binaryOperatorF), - //ENTRY(reciprocal, 1.0f, 1.0f, FTZ_OFF, unaryF), { "reciprocal", - "/", + "reciprocal", { (void*)reference_reciprocal }, { (void*)reference_reciprocall }, { (void*)reference_relaxed_reciprocal }, @@ -442,7 +441,7 @@ const Func functionList[] = { INFINITY, FTZ_OFF, RELAXED_ON, - binaryOperatorF }, + unaryF}, { "divide", "/", { (void*)reference_divide }, diff --git a/test_conformance/math_brute_force/unary_double.cpp b/test_conformance/math_brute_force/unary_double.cpp index 4762a81d..5c537332 100644 --- a/test_conformance/math_brute_force/unary_double.cpp +++ b/test_conformance/math_brute_force/unary_double.cpp @@ -29,7 +29,12 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p) BuildKernelInfo &info = *(BuildKernelInfo *)p; auto generator = [](const std::string &kernel_name, const char *builtin, cl_uint vector_size_index) { - return GetUnaryKernel(kernel_name, builtin, ParameterType::Double, + const char *builtinCall = builtin; + if (strcmp(builtin, "reciprocal") == 0) + { + builtinCall = "((RETTYPE)(1.0))/"; + } + return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Double, ParameterType::Double, vector_size_index); }; return BuildKernels(info, job_id, generator); diff --git a/test_conformance/math_brute_force/unary_float.cpp b/test_conformance/math_brute_force/unary_float.cpp index 0a2af3be..ae0a0646 100644 --- a/test_conformance/math_brute_force/unary_float.cpp +++ b/test_conformance/math_brute_force/unary_float.cpp @@ -28,7 +28,12 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p) BuildKernelInfo &info = *(BuildKernelInfo *)p; auto generator = [](const std::string &kernel_name, const char *builtin, cl_uint vector_size_index) { - return GetUnaryKernel(kernel_name, builtin, ParameterType::Float, + const char *builtinCall = builtin; + if (strcmp(builtin, "reciprocal") == 0) + { + builtinCall = "((RETTYPE)(1.0f))/"; + } + return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Float, ParameterType::Float, vector_size_index); }; return BuildKernels(info, job_id, generator); diff --git a/test_conformance/math_brute_force/unary_half.cpp b/test_conformance/math_brute_force/unary_half.cpp index 877e1fad..56565cc3 100644 --- a/test_conformance/math_brute_force/unary_half.cpp +++ b/test_conformance/math_brute_force/unary_half.cpp @@ -28,7 +28,12 @@ cl_int BuildKernel_HalfFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p) BuildKernelInfo &info = *(BuildKernelInfo *)p; auto generator = [](const std::string &kernel_name, const char *builtin, cl_uint vector_size_index) { - return GetUnaryKernel(kernel_name, builtin, ParameterType::Half, + const char *builtinCall = builtin; + if (strcmp(builtin, "reciprocal") == 0) + { + builtinCall = "((RETTYPE)(1.0h))/"; + } + return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Half, ParameterType::Half, vector_size_index); }; return BuildKernels(info, job_id, generator); From 733cc78c3986f18cab5c704bc98c958c261cbb82 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Wed, 5 Mar 2025 01:53:25 +0100 Subject: [PATCH 24/36] spirv_new: ensure int64 printf test uses 64 bits (#2295) The `extinst_printf_operands_scalar_int64` test could fail on 32-bit platforms with `CL_INVALID_ARG_SIZE`, because the helper function was not guaranteed to be instantiated using a 64-bit integer template type. Signed-off-by: Sven van Haastregt --- test_conformance/spirv_new/test_extinst_printf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test_conformance/spirv_new/test_extinst_printf.cpp b/test_conformance/spirv_new/test_extinst_printf.cpp index 54bb8326..d55935e2 100644 --- a/test_conformance/spirv_new/test_extinst_printf.cpp +++ b/test_conformance/spirv_new/test_extinst_printf.cpp @@ -30,6 +30,8 @@ #define streamDup2(fd1, fd2) dup2(fd1, fd2) #endif +#include + #include #include @@ -232,8 +234,9 @@ lX = 4 return TEST_SKIPPED_ITSELF; } - return printf_operands_helper(device, "printf_operands_scalar_int64", - "printf_operands_scalar_int64", expected, 4L); + return printf_operands_helper( + device, "printf_operands_scalar_int64", "printf_operands_scalar_int64", + expected, 4L); } REGISTER_TEST(extinst_printf_operands_scalar_fp64) From 9a5041a25b249a033a0d6e7d6fda89e0b2f336d6 Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Wed, 5 Mar 2025 00:53:50 +0000 Subject: [PATCH 25/36] Fix inconsistent variable name in REGISTER_TEST and REQUIRE_EXTENSION (#2296) Both `REGISTER_TEST` and `REQUIRE_EXTENSION` expect cl_device_id variable but the variable name is inconsistent which makes both macros unusable together. This change renames `deviceID` in `REQUIRE_EXTENSION` to `device` to be consistent with `REGISTER_TEST`. Signed-off-by: Michael Rizkalla --- test_common/harness/testHarness.h | 2 +- .../test_external_semaphore.cpp | 147 +++++++++--------- 2 files changed, 74 insertions(+), 75 deletions(-) diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index 32f88bd8..32ed18b4 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -153,7 +153,7 @@ template T *register_test(const char *name, Version version) #define REQUIRE_EXTENSION(name) \ do \ { \ - if (!is_extension_available(deviceID, name)) \ + if (!is_extension_available(device, name)) \ { \ log_info(name \ " is not supported on this device. Skipping test.\n"); \ diff --git a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp index 849d1c7c..e04449ea 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp +++ b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp @@ -119,14 +119,14 @@ static cl_int get_device_semaphore_handle_types( } // Confirm the semaphores can be successfully queried -int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, +int test_external_semaphores_queries(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_semaphore"); REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -135,13 +135,13 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, VulkanDevice vkDevice; - GET_PFN(deviceID, clGetSemaphoreInfoKHR); - GET_PFN(deviceID, clReleaseSemaphoreKHR); - GET_PFN(deviceID, clRetainSemaphoreKHR); + GET_PFN(device, clGetSemaphoreInfoKHR); + GET_PFN(device, clReleaseSemaphoreKHR); + GET_PFN(device, clRetainSemaphoreKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -156,7 +156,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, vkExternalSemaphoreHandleType); clExternalImportableSemaphore sema_ext( - vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, device); // Needed by the macro cl_semaphore_khr sema = sema_ext.getCLSemaphore(); @@ -165,7 +165,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, CL_SEMAPHORE_TYPE_BINARY_KHR); SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, - deviceID); + device); // Confirm that querying CL_SEMAPHORE_CONTEXT_KHR returns the right // context @@ -199,30 +199,30 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_external_semaphores_cross_context(cl_device_id deviceID, +int test_external_semaphores_cross_context(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); - GET_PFN(deviceID, clCreateSemaphoreWithPropertiesKHR); - GET_PFN(deviceID, clGetSemaphoreHandleForTypeKHR); - GET_PFN(deviceID, clReleaseSemaphoreKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clCreateSemaphoreWithPropertiesKHR); + GET_PFN(device, clGetSemaphoreHandleForTypeKHR); + GET_PFN(device, clReleaseSemaphoreKHR); std::vector import_handle_types; std::vector export_handle_types; cl_int err = CL_SUCCESS; err = get_device_semaphore_handle_types( - deviceID, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, + device, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, import_handle_types); test_error(err, "Failed to query import handle types"); err = get_device_semaphore_handle_types( - deviceID, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, + device, CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, export_handle_types); test_error(err, "Failed to query export handle types"); @@ -243,15 +243,15 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, std::back_inserter(import_export_handle_types)); cl_context context2 = - clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &err); + clCreateContext(NULL, 1, &device, notify_callback, NULL, &err); test_error(err, "Failed to create context2"); clCommandQueueWrapper queue1 = - clCreateCommandQueue(context, deviceID, 0, &err); + clCreateCommandQueue(context, device, 0, &err); test_error(err, "Could not create command queue"); clCommandQueueWrapper queue2 = - clCreateCommandQueue(context2, deviceID, 0, &err); + clCreateCommandQueue(context2, device, 0, &err); test_error(err, "Could not create command queue"); if (import_export_handle_types.empty()) @@ -284,7 +284,7 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, cl_semaphore_properties_khr handle = 0; // The handle must fit in cl_semaphore_properties_khr - err = clGetSemaphoreHandleForTypeKHR(exportable_semaphore, deviceID, + err = clGetSemaphoreHandleForTypeKHR(exportable_semaphore, device, handle_type, sizeof(handle), &handle, nullptr); test_error(err, "Failed to export handle from semaphore"); @@ -325,13 +325,13 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, } // Confirm that a signal followed by a wait will complete successfully -int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, +int test_external_semaphores_simple_1(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -341,12 +341,12 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -363,14 +363,14 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, clExternalSemaphore *raw_sema_ext = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext(raw_sema_ext); cl_int err = CL_SUCCESS; // Create ooo queue clCommandQueueWrapper queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); test_error(err, "Could not create command queue"); // Signal semaphore @@ -400,13 +400,13 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, // Confirm that signal a semaphore with no event dependencies will not result // in an implicit dependency on everything previously submitted -int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, +int test_external_semaphores_simple_2(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -416,12 +416,12 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -437,14 +437,14 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, clExternalSemaphore *raw_sema_ext = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext(raw_sema_ext); cl_int err = CL_SUCCESS; // Create ooo queue clCommandQueueWrapper queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); test_error(err, "Could not create command queue"); // Create user event @@ -507,13 +507,13 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, } // Confirm that a semaphore can be reused multiple times -int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, +int test_external_semaphores_reuse(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -523,12 +523,12 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -544,14 +544,14 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, clExternalSemaphore *raw_sema_ext = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext(raw_sema_ext); cl_int err = CL_SUCCESS; // Create ooo queue clCommandQueueWrapper queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); test_error(err, "Could not create command queue"); // Create Kernel @@ -626,14 +626,14 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, // Helper function that signals and waits on semaphore across two different // queues. -static int external_semaphore_cross_queue_helper(cl_device_id deviceID, +static int external_semaphore_cross_queue_helper(cl_device_id device, cl_context context, cl_command_queue queue_1, cl_command_queue queue_2) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -643,12 +643,12 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -664,7 +664,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, clExternalSemaphore *raw_sema_ext = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext, vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext(raw_sema_ext); cl_int err = CL_SUCCESS; @@ -741,14 +741,14 @@ int test_external_semaphores_cross_queues_io(cl_device_id deviceID, queue_2); } -int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, +int test_external_semaphores_cross_queues_io2(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -760,19 +760,19 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, cl_int err = CL_SUCCESS; clContextWrapper context2 = - clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &err); + clCreateContext(NULL, 1, &device, notify_callback, NULL, &err); if (!context2) { print_error(err, "Unable to create testing context"); return TEST_FAIL; } - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -788,20 +788,20 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, clExternalSemaphore *raw_sema_ext_1 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_1(raw_sema_ext_1); clExternalSemaphore *raw_sema_ext_2 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore, context2, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_2(raw_sema_ext_2); clCommandQueueWrapper queue1 = - clCreateCommandQueue(context, deviceID, 0, &err); + clCreateCommandQueue(context, device, 0, &err); test_error(err, "Could not create command queue"); clCommandQueueWrapper queue2 = - clCreateCommandQueue(context2, deviceID, 0, &err); + clCreateCommandQueue(context2, device, 0, &err); test_error(err, "Could not create command queue"); // Signal semaphore 1 @@ -850,14 +850,14 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, } // Confirm that we can signal multiple semaphores with one command -int test_external_semaphores_multi_signal(cl_device_id deviceID, +int test_external_semaphores_multi_signal(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -867,12 +867,12 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -890,19 +890,19 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, clExternalSemaphore *raw_sema_ext_1 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore1, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_1(raw_sema_ext_1); clExternalSemaphore *raw_sema_ext_2 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore2, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_2(raw_sema_ext_2); cl_int err = CL_SUCCESS; // Create ooo queue clCommandQueueWrapper queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); test_error(err, "Could not create command queue"); // Signal semaphore 1 and 2 @@ -941,14 +941,13 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, } // Confirm that we can wait for multiple semaphores with one command -int test_external_semaphores_multi_wait(cl_device_id deviceID, - cl_context context, +int test_external_semaphores_multi_wait(cl_device_id device, cl_context context, cl_command_queue defaultQueue, int num_elements) { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vulkan_device(1, &deviceID)) + if (init_vulkan_device(1, &device)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -958,12 +957,12 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, VulkanDevice vkDevice; // Obtain pointers to semaphore's API - GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); - GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(device, clEnqueueSignalSemaphoresKHR); + GET_PFN(device, clEnqueueWaitSemaphoresKHR); std::vector vkExternalSemaphoreHandleTypeList = - getSupportedInteropExternalSemaphoreHandleTypes(deviceID, vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, vkDevice); if (vkExternalSemaphoreHandleTypeList.empty()) { @@ -981,19 +980,19 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, clExternalSemaphore *raw_sema_ext_1 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_1, vkVk2CLSemaphore1, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_1(raw_sema_ext_1); clExternalSemaphore *raw_sema_ext_2 = NULL; CREATE_OPENCL_SEMAPHORE(raw_sema_ext_2, vkVk2CLSemaphore2, context, - vkExternalSemaphoreHandleType, deviceID, true); + vkExternalSemaphoreHandleType, device, true); std::unique_ptr sema_ext_2(raw_sema_ext_2); cl_int err = CL_SUCCESS; // Create ooo queue clCommandQueueWrapper queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); test_error(err, "Could not create command queue"); // Signal semaphore 1 From 6a36bd9d5ce8ab62652666e6c5263d1b2d61cdf4 Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Wed, 5 Mar 2025 08:29:26 -0800 Subject: [PATCH 26/36] add SPIR-V 1.6 testing for UniformDecoration decorations (#2254) Adds a basic test for the SPIR-V 1.6 UniformDecoration decorations. Specifically: * Tests both the Uniform and UniformId decorations. * Tests the decorations on constants, function parameters, and variables. --- .../spirv_new/spirv_asm/CMakeLists.txt | 6 ++ .../spv1.6/uniformdecoration_uniform.spvasm32 | 36 +++++++++ .../spv1.6/uniformdecoration_uniform.spvasm64 | 38 ++++++++++ .../uniformdecoration_uniformid.spvasm32 | 40 ++++++++++ .../uniformdecoration_uniformid.spvasm64 | 42 ++++++++++ test_conformance/spirv_new/test_spirv_16.cpp | 76 +++++++++++++++++++ 6 files changed, 238 insertions(+) create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm32 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm64 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm32 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm64 diff --git a/test_conformance/spirv_new/spirv_asm/CMakeLists.txt b/test_conformance/spirv_new/spirv_asm/CMakeLists.txt index 0e12a285..34bb30bf 100644 --- a/test_conformance/spirv_new/spirv_asm/CMakeLists.txt +++ b/test_conformance/spirv_new/spirv_asm/CMakeLists.txt @@ -411,6 +411,12 @@ set(spirv_sources spv1.5/basic.spvasm64 spv1.6/basic.spvasm32 spv1.6/basic.spvasm64 + spv1.6/image_operand_nontemporal.spvasm32 + spv1.6/image_operand_nontemporal.spvasm64 + spv1.6/uniformdecoration_uniformid.spvasm32 + spv1.6/uniformdecoration_uniformid.spvasm64 + spv1.6/uniformdecoration_uniform.spvasm32 + spv1.6/uniformdecoration_uniform.spvasm64 undef_char_simple.spvasm32 undef_char_simple.spvasm64 undef_double_simple.spvasm32 diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm32 new file mode 100644 index 00000000..be2c0143 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm32 @@ -0,0 +1,36 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability UniformDecoration + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid + OpDecorate %gid BuiltIn GlobalInvocationId + OpDecorate %gid Constant + ; Decoration on a constant + OpDecorate %uint_0 Uniform + ; Decoration on a function parameter + OpDecorate %value Uniform + OpDecorate %base Uniform + ; Decoration on a variable + OpDecorate %newvalue Uniform + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %ptr_gid = OpTypePointer Input %v3uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint %uint + %gid = OpVariable %ptr_gid Input + %kernel = OpFunction %void None %kernel_sig + %base = OpFunctionParameter %gptr_uint + %value = OpFunctionParameter %uint + %entry = OpLabel + %gidv3 = OpLoad %v3uint %gid Aligned 32 + %gid0 = OpCompositeExtract %uint %gidv3 0 + %ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0 + %newvalue = OpIAdd %uint %value %uint_1 + OpStore %ptr %newvalue Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm64 new file mode 100644 index 00000000..6cefca8c --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniform.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability UniformDecoration + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid + OpDecorate %gid BuiltIn GlobalInvocationId + OpDecorate %gid Constant + ; Decoration on a constant + OpDecorate %uint_0 Uniform + ; Decoration on a function parameter + OpDecorate %value Uniform + OpDecorate %base Uniform + ; Decoration on a variable + OpDecorate %newvalue Uniform + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 + %ptr_gid = OpTypePointer Input %v3ulong + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint %uint + %gid = OpVariable %ptr_gid Input + %kernel = OpFunction %void None %kernel_sig + %base = OpFunctionParameter %gptr_uint + %value = OpFunctionParameter %uint + %entry = OpLabel + %gidv3 = OpLoad %v3ulong %gid Aligned 32 + %gid0 = OpCompositeExtract %ulong %gidv3 0 + %ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0 + %newvalue = OpIAdd %uint %value %uint_1 + OpStore %ptr %newvalue Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm32 new file mode 100644 index 00000000..db4c23a4 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm32 @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability UniformDecoration + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid + OpDecorate %gid BuiltIn GlobalInvocationId + OpDecorate %gid Constant + ; Decoration on a constant + OpDecorateId %uint_0 UniformId %scope_CrossDevice + ; Decoration on a function parameter + OpDecorateId %value UniformId %scope_Device + OpDecorateId %base UniformId %scope_Workgroup + ; Decoration on a variable + OpDecorateId %newvalue UniformId %scope_Subgroup + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %ptr_gid = OpTypePointer Input %v3uint +%scope_CrossDevice = OpConstant %uint 0 +%scope_Device = OpConstant %uint 1 +%scope_Workgroup = OpConstant %uint 2 +%scope_Subgroup = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint %uint + %gid = OpVariable %ptr_gid Input + %kernel = OpFunction %void None %kernel_sig + %base = OpFunctionParameter %gptr_uint + %value = OpFunctionParameter %uint + %entry = OpLabel + %gidv3 = OpLoad %v3uint %gid Aligned 32 + %gid0 = OpCompositeExtract %uint %gidv3 0 + %ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0 + %newvalue = OpIAdd %uint %value %uint_1 + OpStore %ptr %newvalue Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm64 new file mode 100644 index 00000000..156ed536 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/uniformdecoration_uniformid.spvasm64 @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.6 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability UniformDecoration + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "test_uniformdecoration" %gid + OpDecorate %gid BuiltIn GlobalInvocationId + OpDecorate %gid Constant + ; Decoration on a constant + OpDecorateId %uint_0 UniformId %scope_CrossDevice + ; Decoration on a function parameter + OpDecorateId %value UniformId %scope_Device + OpDecorateId %base UniformId %scope_Workgroup + ; Decoration on a variable + OpDecorateId %newvalue UniformId %scope_Subgroup + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 + %ptr_gid = OpTypePointer Input %v3ulong +%scope_CrossDevice = OpConstant %uint 0 +%scope_Device = OpConstant %uint 1 +%scope_Workgroup = OpConstant %uint 2 +%scope_Subgroup = OpConstant %uint 3 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint %uint + %gid = OpVariable %ptr_gid Input + %kernel = OpFunction %void None %kernel_sig + %base = OpFunctionParameter %gptr_uint + %value = OpFunctionParameter %uint + %entry = OpLabel + %gidv3 = OpLoad %v3ulong %gid Aligned 32 + %gid0 = OpCompositeExtract %ulong %gidv3 0 + %ptr = OpInBoundsPtrAccessChain %gptr_uint %base %gid0 + %newvalue = OpIAdd %uint %value %uint_1 + OpStore %ptr %newvalue Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/test_spirv_16.cpp b/test_conformance/spirv_new/test_spirv_16.cpp index 169a2cb7..9c9b05a5 100644 --- a/test_conformance/spirv_new/test_spirv_16.cpp +++ b/test_conformance/spirv_new/test_spirv_16.cpp @@ -82,3 +82,79 @@ REGISTER_TEST(spirv16_image_operand_nontemporal) return TEST_PASS; } + +static int test_uniformdecoration_helper(cl_device_id device, + cl_context context, + cl_command_queue queue, + bool test_uniformid) +{ + constexpr size_t global_size = 16; + const cl_uint value = 42; + const cl_uint check = value + 1; + + const char* filename = test_uniformid ? "spv1.6/uniformdecoration_uniformid" + : "spv1.6/uniformdecoration_uniform"; + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il(prog, device, context, filename); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = + clCreateKernel(prog, "test_uniformdecoration", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + std::vector h_dst(global_size); + clMemWrapper dst = + clCreateBuffer(context, CL_MEM_READ_WRITE, + h_dst.size() * sizeof(cl_uint), nullptr, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(value), &value); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &global_size, + nullptr, 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + h_dst.size() * sizeof(cl_uint), h_dst.data(), 0, + nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Unable to read dst buffer"); + + for (size_t i = 0; i < global_size; i++) + { + if (h_dst[i] != check) + { + log_error("Result mismatch at index %zu! Got %u, wanted %u.\n", i, + h_dst[i], check); + return TEST_FAIL; + } + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv16_uniformdecoration_uniform) +{ + if (!is_spirv_version_supported(device, "SPIR-V_1.6")) + { + log_info("SPIR-V 1.6 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + return test_uniformdecoration_helper(device, context, queue, false); +} + +REGISTER_TEST(spirv16_uniformdecoration_uniformid) +{ + if (!is_spirv_version_supported(device, "SPIR-V_1.6")) + { + log_info("SPIR-V 1.6 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + return test_uniformdecoration_helper(device, context, queue, true); +} From 637deb0011afd05ccf2bb7672f6cf5831d6b24ae Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Fri, 7 Mar 2025 10:08:58 -0800 Subject: [PATCH 27/36] add missing Float16 capability (#2304) A recent improvement to the SPIR-V validator added checks to ensure the **Float16** capability is declared when directly operating on fp16 values, which identified issues in one of our SPIR-V test files. This PR fixes the SPIR-V files to add the missing capability. --- .../spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm32 | 1 + .../spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm64 | 1 + 2 files changed, 2 insertions(+) diff --git a/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm32 b/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm32 index 2195ebe8..fa95d0a5 100644 --- a/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm32 @@ -5,6 +5,7 @@ ; Schema: 0 OpCapability Addresses OpCapability Kernel + OpCapability Float16 OpCapability Float16Buffer %1 = OpExtInstImport "OpenCL.std" OpMemoryModel Physical32 OpenCL diff --git a/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm64 b/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm64 index 47dc418a..eb4b897d 100644 --- a/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/op_spec_constant_half_simple.spvasm64 @@ -5,6 +5,7 @@ ; Schema: 0 OpCapability Addresses OpCapability Kernel + OpCapability Float16 OpCapability Float16Buffer %1 = OpExtInstImport "OpenCL.std" OpMemoryModel Physical64 OpenCL From 11db332281c2875dcda4d771e0cd2feced6fea28 Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Sat, 8 Mar 2025 00:43:00 +0100 Subject: [PATCH 28/36] fix error message in work_item_functions_out_of_range (#2303) The value printed in the error message is not the correct one (used in the comparison statement) --- test_conformance/basic/test_work_item_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/basic/test_work_item_functions.cpp b/test_conformance/basic/test_work_item_functions.cpp index 52d789b8..ce427dc3 100644 --- a/test_conformance/basic/test_work_item_functions.cpp +++ b/test_conformance/basic/test_work_item_functions.cpp @@ -439,7 +439,7 @@ struct TestWorkItemFnsOutOfRange "ERROR: get_enqueued_local_size(%d) did not return " "proper value for the argument out of range " "(expected 1, got %d)\n", - (int)dim, (int)testData[q].globalSize); + (int)dim, (int)testData[q].enqueuedLocalSize); return false; } } From 521d067083e964680f3812c0f8c86607de17aa1e Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sat, 8 Mar 2025 22:37:04 +0000 Subject: [PATCH 29/36] Migrate device_partition suite to the new test registration framework (#2301) Contributes to #2181 --- test_conformance/device_partition/main.cpp | 29 +---- test_conformance/device_partition/procs.h | 29 ----- test_conformance/device_partition/testBase.h | 7 +- .../test_device_partition.cpp | 107 +++++++++++------- 4 files changed, 67 insertions(+), 105 deletions(-) delete mode 100644 test_conformance/device_partition/procs.h diff --git a/test_conformance/device_partition/main.cpp b/test_conformance/device_partition/main.cpp index a8af6ffb..65777e48 100644 --- a/test_conformance/device_partition/main.cpp +++ b/test_conformance/device_partition/main.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -13,33 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" - -#include -#include -#include "procs.h" #include "harness/testHarness.h" -#include "harness/mt19937.h" - -#if !defined(_WIN32) -#include -#endif - -test_definition test_list[] = { - ADD_TEST( partition_equally ), - ADD_TEST( partition_by_counts ), - ADD_TEST( partition_by_affinity_domain_numa ), - ADD_TEST( partition_by_affinity_domain_l4_cache ), - ADD_TEST( partition_by_affinity_domain_l3_cache ), - ADD_TEST( partition_by_affinity_domain_l2_cache ), - ADD_TEST( partition_by_affinity_domain_l1_cache ), - ADD_TEST( partition_by_affinity_domain_next_partitionable ), - ADD_TEST( partition_all ), -}; - -const int test_num = ARRAY_SIZE( test_list ); int main(int argc, const char *argv[]) { - return runTestHarness(argc, argv, test_num, test_list, true, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), true, 0); } diff --git a/test_conformance/device_partition/procs.h b/test_conformance/device_partition/procs.h deleted file mode 100644 index 1e543daf..00000000 --- a/test_conformance/device_partition/procs.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) 2017 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/mt19937.h" - -extern int test_partition_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_equally(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_counts(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_numa(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_l4_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_l3_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_l2_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_l1_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_partition_by_affinity_domain_next_partitionable(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); diff --git a/test_conformance/device_partition/testBase.h b/test_conformance/device_partition/testBase.h index 5b49bfd7..a358b81a 100644 --- a/test_conformance/device_partition/testBase.h +++ b/test_conformance/device_partition/testBase.h @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -23,9 +23,4 @@ #include #include -#include "procs.h" - #endif // _testBase_h - - - diff --git a/test_conformance/device_partition/test_device_partition.cpp b/test_conformance/device_partition/test_device_partition.cpp index 2daa09a0..9573e5f9 100644 --- a/test_conformance/device_partition/test_device_partition.cpp +++ b/test_conformance/device_partition/test_device_partition.cpp @@ -416,14 +416,16 @@ int test_device_partition_type_support(cl_device_id parentDevice, const cl_devic return -1; } -int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, cl_device_partition_property *partition_type, +int test_partition_of_device(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements, + cl_device_partition_property *partition_type, cl_uint starting_property, cl_uint ending_property) { cl_uint maxComputeUnits; cl_uint maxSubDevices; // maximal number of sub-devices that can be created in one call to clCreateSubDevices int err = 0; - if (init_device_partition_test(deviceID, maxComputeUnits, maxSubDevices) != 0) + if (init_device_partition_test(device, maxComputeUnits, maxSubDevices) != 0) return -1; if (maxComputeUnits <= 1) @@ -432,10 +434,11 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma if (partition_type != NULL) { // if we're not the root device size_t psize; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_TYPE, 0, NULL, &psize); + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_TYPE, 0, NULL, &psize); test_error( err, "Unable to get CL_DEVICE_PARTITION_TYPE" ); cl_device_partition_property *properties_returned = (cl_device_partition_property *)alloca(psize); - err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_TYPE, psize, (void *) properties_returned, NULL); + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_TYPE, psize, + (void *)properties_returned, NULL); test_error( err, "Unable to get CL_DEVICE_PARTITION_TYPE" ); // test returned type @@ -480,31 +483,36 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma // loop thru each type, creating sub-devices for each type for (cl_uint i = starting_property;i < ending_property;i++) { - if (test_device_partition_type_support(deviceID, partitionProp[i][0], partitionProp[i][1]) != 0) - { - if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) + if (test_device_partition_type_support(device, partitionProp[i][0], + partitionProp[i][1]) + != 0) { - log_info( "Device partition type \"%s\" \"%s\" is not supported on device %p. Skipping test...\n", - printPartition(partitionProp[i][0]), - printAffinity(partitionProp[i][1]), deviceID); - } - else - { - log_info( "Device partition type \"%s\" is not supported on device %p. Skipping test...\n", - printPartition(partitionProp[i][0]), deviceID); - } - continue; + if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) + { + log_info("Device partition type \"%s\" \"%s\" is not supported " + "on device %p. Skipping test...\n", + printPartition(partitionProp[i][0]), + printAffinity(partitionProp[i][1]), device); + } + else + { + log_info("Device partition type \"%s\" is not supported on " + "device %p. Skipping test...\n", + printPartition(partitionProp[i][0]), device); + } + continue; } if (partitionProp[i][0] == CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) { - log_info("Testing on device %p partition type \"%s\" \"%s\"\n", deviceID, printPartition(partitionProp[i][0]), - printAffinity(partitionProp[i][1])); + log_info("Testing on device %p partition type \"%s\" \"%s\"\n", + device, printPartition(partitionProp[i][0]), + printAffinity(partitionProp[i][1])); } else { log_info("Testing on device %p partition type \"%s\" (%d,%d)\n", - deviceID, printPartition(partitionProp[i][0]), + device, printPartition(partitionProp[i][0]), static_cast(partitionProp[i][1]), static_cast(partitionProp[i][2])); } @@ -512,9 +520,9 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma cl_uint deviceCount; // how many sub-devices can we create? - err = clCreateSubDevices(deviceID, partitionProp[i], 0, NULL, &deviceCount); + err = clCreateSubDevices(device, partitionProp[i], 0, NULL, &deviceCount); if ( err == CL_DEVICE_PARTITION_FAILED ) { - log_info( "The device %p could not be further partitioned.\n", deviceID ); + log_info("The device %p could not be further partitioned.\n", device); continue; } test_error( err, "Failed to get number of sub-devices" ); @@ -522,7 +530,8 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma // get the list of subDevices // create room for 1 more device_id, so that we can put the parent device in there. cl_device_id *subDevices = (cl_device_id*)alloca(sizeof(cl_device_id) * (deviceCount + 1)); - err = clCreateSubDevices(deviceID, partitionProp[i], deviceCount, subDevices, &deviceCount); + err = clCreateSubDevices(device, partitionProp[i], deviceCount, + subDevices, &deviceCount); test_error( err, "Actual creation of sub-devices failed" ); log_info("Testing on all devices in context\n"); @@ -532,8 +541,9 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma log_info("Testing on a parent device for context\n"); // add the parent device - subDevices[deviceCount] = deviceID; - err = test_device_set(deviceCount + 1, deviceCount, subDevices, num_elements, &deviceID); + subDevices[deviceCount] = device; + err = test_device_set(deviceCount + 1, deviceCount, subDevices, + num_elements, &device); } if (err != 0) { @@ -557,52 +567,61 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma } // for - log_info("Testing on all device %p finished\n", deviceID); + log_info("Testing on all device %p finished\n", device); return 0; } -int test_partition_equally(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_equally) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 0, 1); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 0, 1); } -int test_partition_by_counts(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_counts) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 1, 2); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 1, 2); } -int test_partition_by_affinity_domain_numa(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_numa) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 2, 3); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 2, 3); } -int test_partition_by_affinity_domain_l4_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_l4_cache) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 3, 4); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 3, 4); } -int test_partition_by_affinity_domain_l3_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_l3_cache) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 4, 5); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 4, 5); } -int test_partition_by_affinity_domain_l2_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_l2_cache) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 5, 6); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 5, 6); } -int test_partition_by_affinity_domain_l1_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_l1_cache) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 6, 7); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 6, 7); } -int test_partition_by_affinity_domain_next_partitionable(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_by_affinity_domain_next_partitionable) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 7, 8); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 7, 8); } -int test_partition_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(partition_all) { - return test_partition_of_device(deviceID, context, queue, num_elements, NULL, 0, 8); + return test_partition_of_device(device, context, queue, num_elements, NULL, + 0, 8); } From 5b47d4b19f9607b33bf973ab063c9e77f6109312 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:42:10 +0000 Subject: [PATCH 30/36] Migrate pipes suite to the new test registration framework (#2302) Contributes to #2181 Signed-off-by: Ahmed Hesham --- test_conformance/pipes/main.cpp | 69 +-- test_conformance/pipes/procs.h | 92 ---- test_conformance/pipes/test_pipe_info.cpp | 5 +- test_conformance/pipes/test_pipe_limits.cpp | 17 +- .../pipes/test_pipe_query_functions.cpp | 6 +- .../pipes/test_pipe_read_write.cpp | 462 ++++++++++-------- .../pipes/test_pipe_readwrite_errors.cpp | 5 +- .../pipes/test_pipe_subgroups.cpp | 15 +- 8 files changed, 296 insertions(+), 375 deletions(-) delete mode 100644 test_conformance/pipes/procs.h diff --git a/test_conformance/pipes/main.cpp b/test_conformance/pipes/main.cpp index 4241c4d4..34ab7b9f 100644 --- a/test_conformance/pipes/main.cpp +++ b/test_conformance/pipes/main.cpp @@ -16,7 +16,6 @@ #include "harness/compat.h" #include "harness/testHarness.h" -#include "procs.h" #include #include @@ -48,67 +47,9 @@ test_status InitCL(cl_device_id device) { return TEST_PASS; } -test_definition test_list[] = { - ADD_TEST(pipe_readwrite_int), - ADD_TEST(pipe_readwrite_uint), - ADD_TEST(pipe_readwrite_long), - ADD_TEST(pipe_readwrite_ulong), - ADD_TEST(pipe_readwrite_short), - ADD_TEST(pipe_readwrite_ushort), - ADD_TEST(pipe_readwrite_float), - ADD_TEST(pipe_readwrite_half), - ADD_TEST(pipe_readwrite_char), - ADD_TEST(pipe_readwrite_uchar), - ADD_TEST(pipe_readwrite_double), - ADD_TEST(pipe_readwrite_struct), - ADD_TEST(pipe_workgroup_readwrite_int), - ADD_TEST(pipe_workgroup_readwrite_uint), - ADD_TEST(pipe_workgroup_readwrite_long), - ADD_TEST(pipe_workgroup_readwrite_ulong), - ADD_TEST(pipe_workgroup_readwrite_short), - ADD_TEST(pipe_workgroup_readwrite_ushort), - ADD_TEST(pipe_workgroup_readwrite_float), - ADD_TEST(pipe_workgroup_readwrite_half), - ADD_TEST(pipe_workgroup_readwrite_char), - ADD_TEST(pipe_workgroup_readwrite_uchar), - ADD_TEST(pipe_workgroup_readwrite_double), - ADD_TEST(pipe_workgroup_readwrite_struct), - ADD_TEST(pipe_subgroup_readwrite_int), - ADD_TEST(pipe_subgroup_readwrite_uint), - ADD_TEST(pipe_subgroup_readwrite_long), - ADD_TEST(pipe_subgroup_readwrite_ulong), - ADD_TEST(pipe_subgroup_readwrite_short), - ADD_TEST(pipe_subgroup_readwrite_ushort), - ADD_TEST(pipe_subgroup_readwrite_float), - ADD_TEST(pipe_subgroup_readwrite_half), - ADD_TEST(pipe_subgroup_readwrite_char), - ADD_TEST(pipe_subgroup_readwrite_uchar), - ADD_TEST(pipe_subgroup_readwrite_double), - ADD_TEST(pipe_subgroup_readwrite_struct), - ADD_TEST(pipe_convenience_readwrite_int), - ADD_TEST(pipe_convenience_readwrite_uint), - ADD_TEST(pipe_convenience_readwrite_long), - ADD_TEST(pipe_convenience_readwrite_ulong), - ADD_TEST(pipe_convenience_readwrite_short), - ADD_TEST(pipe_convenience_readwrite_ushort), - ADD_TEST(pipe_convenience_readwrite_float), - ADD_TEST(pipe_convenience_readwrite_half), - ADD_TEST(pipe_convenience_readwrite_char), - ADD_TEST(pipe_convenience_readwrite_uchar), - ADD_TEST(pipe_convenience_readwrite_double), - ADD_TEST(pipe_convenience_readwrite_struct), - ADD_TEST(pipe_info), - ADD_TEST(pipe_max_args), - ADD_TEST(pipe_max_packet_size), - ADD_TEST(pipe_max_active_reservations), - ADD_TEST(pipe_query_functions), - ADD_TEST(pipe_readwrite_errors), - ADD_TEST(pipe_subgroups_divergence), -}; - -const int test_num = ARRAY_SIZE(test_list); - -int main(int argc, const char *argv[]) { - return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, - 0, InitCL); +int main(int argc, const char *argv[]) +{ + return runTestHarnessWithCheck( + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, InitCL); } diff --git a/test_conformance/pipes/procs.h b/test_conformance/pipes/procs.h deleted file mode 100644 index 5cbe7952..00000000 --- a/test_conformance/pipes/procs.h +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) 2017 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef __PROCS_H__ -#define __PROCS_H__ - -#include "harness/kernelHelpers.h" -#include "harness/testHarness.h" -#include "harness/errorHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/mt19937.h" -#include "harness/conversions.h" - -#ifndef __APPLE__ -#include -#endif - -extern int test_pipe_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_pipe_workgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_workgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_pipe_subgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_subgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_pipe_convenience_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_convenience_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_pipe_readwrite_errors(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - - -#endif // #ifndef __PROCS_H__ - diff --git a/test_conformance/pipes/test_pipe_info.cpp b/test_conformance/pipes/test_pipe_info.cpp index b230a4c4..5525a554 100644 --- a/test_conformance/pipes/test_pipe_info.cpp +++ b/test_conformance/pipes/test_pipe_info.cpp @@ -16,14 +16,15 @@ #include -#include "procs.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" #include "harness/parseParameters.h" const char* pipe_kernel_code = { "__kernel void pipe_kernel(__write_only pipe int out_pipe)\n" "{}\n" }; -int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_info) { clMemWrapper pipe; cl_int err; diff --git a/test_conformance/pipes/test_pipe_limits.cpp b/test_conformance/pipes/test_pipe_limits.cpp index 76b80b15..f403c03d 100644 --- a/test_conformance/pipes/test_pipe_limits.cpp +++ b/test_conformance/pipes/test_pipe_limits.cpp @@ -25,8 +25,9 @@ #include #include -#include "procs.h" +#include "harness/testHarness.h" #include "harness/errorHelpers.h" +#include "harness/typeWrappers.h" #define STRING_LENGTH 1024 @@ -150,7 +151,7 @@ static int verify_result_int(void *ptr1, void *ptr2, int n) return 0; } -int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_max_args) { clMemWrapper pipes[1024]; @@ -177,7 +178,7 @@ int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_que size_t min_alignment = get_min_alignment(context); - err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, + err = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(max_pipe_args), (void *)&max_pipe_args, NULL); if (err) { @@ -263,7 +264,7 @@ int test_pipe_max_args(cl_device_id deviceID, cl_context context, cl_command_que } -int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_max_packet_size) { clMemWrapper pipe; clMemWrapper buffers[2]; @@ -290,7 +291,7 @@ int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_comm std::stringstream source; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE, + err = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE, sizeof(max_pipe_packet_size), (void *)&max_pipe_packet_size, NULL); test_error_ret(err, " clCreatePipe failed", -1); @@ -402,7 +403,7 @@ int test_pipe_max_packet_size(cl_device_id deviceID, cl_context context, cl_comm return 0; } -int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_max_active_reservations) { clMemWrapper pipe; clMemWrapper buffers[2]; @@ -437,12 +438,12 @@ int test_pipe_max_active_reservations(cl_device_id deviceID, cl_context context, global_work_size[0] = 1; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, + err = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, sizeof(max_active_reservations), (void *)&max_active_reservations, NULL); test_error_ret(err, " clGetDeviceInfo failed", -1); - err = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, + err = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(max_global_size), (void *)&max_global_size, NULL); test_error_ret(err, " clGetDeviceInfo failed", -1); diff --git a/test_conformance/pipes/test_pipe_query_functions.cpp b/test_conformance/pipes/test_pipe_query_functions.cpp index 21d19505..8f7fc41d 100644 --- a/test_conformance/pipes/test_pipe_query_functions.cpp +++ b/test_conformance/pipes/test_pipe_query_functions.cpp @@ -20,8 +20,9 @@ #include #include -#include "procs.h" +#include "harness/testHarness.h" #include "harness/errorHelpers.h" +#include "harness/typeWrappers.h" #define TEST_PRIME_INT ((1<<16)+1) @@ -77,7 +78,7 @@ static int verify_result(void *ptr1, void *ptr2, int n) return 0; } -int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_query_functions) { clMemWrapper pipe; clMemWrapper buffers[4]; @@ -252,4 +253,3 @@ int test_pipe_query_functions(cl_device_id deviceID, cl_context context, cl_comm } return 0; } - diff --git a/test_conformance/pipes/test_pipe_read_write.cpp b/test_conformance/pipes/test_pipe_read_write.cpp index 425c7aee..ad1ed91d 100644 --- a/test_conformance/pipes/test_pipe_read_write.cpp +++ b/test_conformance/pipes/test_pipe_read_write.cpp @@ -25,9 +25,10 @@ #include #include -#include "procs.h" #include "kernels.h" #include "harness/errorHelpers.h" +#include "harness/typeWrappers.h" +#include "harness/conversions.h" #ifndef uchar typedef unsigned char uchar; @@ -694,7 +695,7 @@ int test_pipe_readwrite_struct_generic( cl_device_id deviceID, cl_context contex } -int test_pipe_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_int) { cl_int *inptr[5]; size_t ptrSizes[5]; @@ -721,20 +722,24 @@ int test_pipe_readwrite_int( cl_device_id deviceID, cl_context context, cl_comma } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - workgroup_int_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", + 5, (void **)inptr, workgroup_int_kernel_name, foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - subgroup_int_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", + 5, (void **)inptr, subgroup_int_kernel_name, foo); } else if(useConvenienceBuiltIn == 1) { - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - convenience_int_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", + 5, (void **)inptr, convenience_int_kernel_name, foo); } else { - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - int_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_int), (char *)"int", 5, + (void **)inptr, int_kernel_name, foo); } @@ -744,10 +749,9 @@ int test_pipe_readwrite_int( cl_device_id deviceID, cl_context context, cl_comma free_mtdata(d); return err; - } -int test_pipe_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -774,20 +778,25 @@ int test_pipe_readwrite_uint( cl_device_id deviceID, cl_context context, cl_comm } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - workgroup_uint_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_uint), + (char *)"uint", 5, (void **)inptr, workgroup_uint_kernel_name, foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - subgroup_uint_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_uint), + (char *)"uint", 5, (void **)inptr, subgroup_uint_kernel_name, foo); } else if(useConvenienceBuiltIn == 1) { - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - convenience_uint_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uint), (char *)"uint", 5, + (void **)inptr, convenience_uint_kernel_name, + foo); } else { - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - uint_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uint), (char *)"uint", 5, + (void **)inptr, uint_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -796,10 +805,9 @@ int test_pipe_readwrite_uint( cl_device_id deviceID, cl_context context, cl_comm free_mtdata(d); return err; - } -int test_pipe_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_short) { cl_short *inptr[5]; size_t ptrSizes[5]; @@ -826,20 +834,27 @@ int test_pipe_readwrite_short( cl_device_id deviceID, cl_context context, cl_com } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - workgroup_short_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, workgroup_short_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - subgroup_short_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, subgroup_short_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - convenience_short_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, convenience_short_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - short_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, short_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -848,10 +863,9 @@ int test_pipe_readwrite_short( cl_device_id deviceID, cl_context context, cl_com free_mtdata(d); return err; - } -int test_pipe_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -878,20 +892,27 @@ int test_pipe_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_co } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - workgroup_ushort_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, workgroup_ushort_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - subgroup_ushort_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, subgroup_ushort_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - convenience_ushort_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, + convenience_ushort_kernel_name, foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - ushort_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, ushort_kernel_name, foo); } @@ -901,10 +922,9 @@ int test_pipe_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_co free_mtdata(d); return err; - } -int test_pipe_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_char) { cl_char *inptr[5]; size_t ptrSizes[5]; @@ -931,20 +951,25 @@ int test_pipe_readwrite_char( cl_device_id deviceID, cl_context context, cl_comm } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - workgroup_char_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_char), + (char *)"char", 5, (void **)inptr, workgroup_char_kernel_name, foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - subgroup_char_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_char), + (char *)"char", 5, (void **)inptr, subgroup_char_kernel_name, foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - convenience_char_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_char), (char *)"char", 5, + (void **)inptr, convenience_char_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - char_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_char), (char *)"char", 5, + (void **)inptr, char_kernel_name, foo); } @@ -954,10 +979,9 @@ int test_pipe_readwrite_char( cl_device_id deviceID, cl_context context, cl_comm free_mtdata(d); return err; - } -int test_pipe_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_uchar) { cl_uchar *inptr[5]; size_t ptrSizes[5]; @@ -984,20 +1008,27 @@ int test_pipe_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_com } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - workgroup_uchar_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, workgroup_uchar_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - subgroup_uchar_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, subgroup_uchar_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - convenience_uchar_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, convenience_uchar_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - uchar_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, uchar_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1005,10 +1036,9 @@ int test_pipe_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_com free_mtdata(d); return err; - } -int test_pipe_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1035,20 +1065,27 @@ int test_pipe_readwrite_float( cl_device_id deviceID, cl_context context, cl_com } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - workgroup_float_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, workgroup_float_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - subgroup_float_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, subgroup_float_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - convenience_float_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, convenience_float_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - float_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, float_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -1057,10 +1094,9 @@ int test_pipe_readwrite_float( cl_device_id deviceID, cl_context context, cl_com free_mtdata(d); return err; - } -int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_half) { float *inptr[5]; size_t ptrSizes[5]; @@ -1073,7 +1109,7 @@ int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_comm foo = verify_readwrite_half; - if(!is_extension_available(deviceID, "cl_khr_fp16")) + if (!is_extension_available(device, "cl_khr_fp16")) { log_info( "cl_khr_fp16 is not supported on this platform. Skipping test.\n"); @@ -1093,20 +1129,25 @@ int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_comm } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_half ), (char*)"half", 5, (void**)inptr, - workgroup_half_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_half), + (char *)"half", 5, (void **)inptr, workgroup_half_kernel_name, foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_half ), (char*)"half", 5, (void**)inptr, - subgroup_half_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_half), + (char *)"half", 5, (void **)inptr, subgroup_half_kernel_name, foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_half ), (char*)"half", 5, (void**)inptr, - convenience_half_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_half), (char *)"half", 5, + (void **)inptr, convenience_half_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_half ), (char*)"half", 5, (void**)inptr, - half_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_half), (char *)"half", 5, + (void **)inptr, half_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -1117,7 +1158,7 @@ int test_pipe_readwrite_half( cl_device_id deviceID, cl_context context, cl_comm return err; } -int test_pipe_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1151,20 +1192,25 @@ int test_pipe_readwrite_long( cl_device_id deviceID, cl_context context, cl_comm } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", 5, (void**)inptr, - workgroup_long_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"long", 5, (void **)inptr, workgroup_long_kernel_name, foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", 5, (void**)inptr, - subgroup_long_kernel_name, foo); + err = test_pipe_readwrite( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"long", 5, (void **)inptr, subgroup_long_kernel_name, foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", 5, (void**)inptr, - convenience_long_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_long), (char *)"long", 5, + (void **)inptr, convenience_long_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", 5, (void**)inptr, - long_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_long), (char *)"long", 5, + (void **)inptr, long_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -1173,10 +1219,9 @@ int test_pipe_readwrite_long( cl_device_id deviceID, cl_context context, cl_comm free_mtdata(d); return err; - } -int test_pipe_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1210,20 +1255,27 @@ int test_pipe_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_com } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", 5, (void**)inptr, - workgroup_ulong_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong", 5, + (void **)inptr, workgroup_ulong_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", 5, (void**)inptr, - subgroup_ulong_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong", 5, + (void **)inptr, subgroup_ulong_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", 5, (void**)inptr, - convenience_ulong_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong", 5, + (void **)inptr, convenience_ulong_kernel_name, + foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", 5, (void**)inptr, - ulong_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong", 5, + (void **)inptr, ulong_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -1232,10 +1284,9 @@ int test_pipe_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_com free_mtdata(d); return err; - } -int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_double) { cl_double *inptr[5]; size_t ptrSizes[5]; @@ -1255,7 +1306,7 @@ int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_co ptrSizes[4] = ptrSizes[3] << 1; //skip devices that don't support double - if(!is_extension_available(deviceID, "cl_khr_fp64")) + if (!is_extension_available(device, "cl_khr_fp64")) { log_info( "cl_khr_fp64 is not supported on this platform. Skipping test.\n"); @@ -1270,20 +1321,27 @@ int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_co } if(useWorkgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_double ), (char*)"double", 5, (void**)inptr, - workgroup_double_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_double), (char *)"double", 5, + (void **)inptr, workgroup_double_kernel_name, + foo); } else if(useSubgroupReserve == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_double ), (char*)"double", 5, (void**)inptr, - subgroup_double_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_double), (char *)"double", 5, + (void **)inptr, subgroup_double_kernel_name, + foo); } else if(useConvenienceBuiltIn == 1){ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_double ), (char*)"double", 5, (void**)inptr, - convenience_double_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_double), (char *)"double", 5, + (void **)inptr, + convenience_double_kernel_name, foo); } else{ - err = test_pipe_readwrite( deviceID, context, queue, num_elements, sizeof( cl_double ), (char*)"double", 5, (void**)inptr, - double_kernel_name, foo); + err = test_pipe_readwrite(device, context, queue, num_elements, + sizeof(cl_double), (char *)"double", 5, + (void **)inptr, double_kernel_name, foo); } for ( i = 0; i < 5; i++ ){ @@ -1292,392 +1350,398 @@ int test_pipe_readwrite_double( cl_device_id deviceID, cl_context context, cl_co free_mtdata(d); return err; - } -int test_pipe_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_readwrite_struct) { const char *kernelNames[] = {"test_pipe_write_struct","test_pipe_read_struct"}; - return test_pipe_readwrite_struct_generic(deviceID, context, queue, num_elements, pipe_readwrite_struct_kernel_code, kernelNames); + return test_pipe_readwrite_struct_generic( + device, context, queue, num_elements, pipe_readwrite_struct_kernel_code, + kernelNames); } // Work-group functions for pipe reserve/commits -int test_pipe_workgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_int) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_int(deviceID, context, queue, num_elements); + return test_pipe_readwrite_int(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_uint) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_uint(deviceID, context, queue, num_elements); + return test_pipe_readwrite_uint(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_short) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_short(deviceID, context, queue, num_elements); + return test_pipe_readwrite_short(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_ushort) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_ushort(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ushort(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_char) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_char(deviceID, context, queue, num_elements); + return test_pipe_readwrite_char(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_uchar) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_uchar(deviceID, context, queue, num_elements); + return test_pipe_readwrite_uchar(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_float) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_float(deviceID, context, queue, num_elements); + return test_pipe_readwrite_float(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_half) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_half(deviceID, context, queue, num_elements); + return test_pipe_readwrite_half(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_long) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_long(deviceID, context, queue, num_elements); + return test_pipe_readwrite_long(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_ulong) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_ulong(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ulong(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_double) { useWorkgroupReserve = 1; useSubgroupReserve = 0; useConvenienceBuiltIn = 0; - return test_pipe_readwrite_double(deviceID, context, queue, num_elements); + return test_pipe_readwrite_double(device, context, queue, num_elements); } -int test_pipe_workgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_workgroup_readwrite_struct) { const char *kernelNames[] = {"test_pipe_workgroup_write_struct","test_pipe_workgroup_read_struct"}; - return test_pipe_readwrite_struct_generic(deviceID, context, queue, num_elements, pipe_workgroup_readwrite_struct_kernel_code, kernelNames); + return test_pipe_readwrite_struct_generic( + device, context, queue, num_elements, + pipe_workgroup_readwrite_struct_kernel_code, kernelNames); } // Sub-group functions for pipe reserve/commits -int test_pipe_subgroup_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_int) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_int(deviceID, context, queue, num_elements); + return test_pipe_readwrite_int(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_uint) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_uint(deviceID, context, queue, num_elements); + return test_pipe_readwrite_uint(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_short) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_short(deviceID, context, queue, num_elements); + return test_pipe_readwrite_short(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_ushort) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_ushort(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ushort(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_char) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_char(deviceID, context, queue, num_elements); + return test_pipe_readwrite_char(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_uchar) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_uchar(deviceID, context, queue, num_elements); - + return test_pipe_readwrite_uchar(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_float) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_float(deviceID, context, queue, num_elements); + return test_pipe_readwrite_float(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_half) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_half(deviceID, context, queue, num_elements); + return test_pipe_readwrite_half(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_long) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_long(deviceID, context, queue, num_elements); + return test_pipe_readwrite_long(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_ulong) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_ulong(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ulong(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_double) { useSubgroupReserve = 1; useWorkgroupReserve = 0; useConvenienceBuiltIn = 0; - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } - return test_pipe_readwrite_double(deviceID, context, queue, num_elements); + return test_pipe_readwrite_double(device, context, queue, num_elements); } -int test_pipe_subgroup_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_subgroup_readwrite_struct) { - if(!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); return CL_SUCCESS; } const char *kernelNames[] = {"test_pipe_subgroup_write_struct","test_pipe_subgroup_read_struct"}; - return test_pipe_readwrite_struct_generic(deviceID, context, queue, num_elements, pipe_subgroup_readwrite_struct_kernel_code, kernelNames); + return test_pipe_readwrite_struct_generic( + device, context, queue, num_elements, + pipe_subgroup_readwrite_struct_kernel_code, kernelNames); } // Convenience functions for pipe reserve/commits -int test_pipe_convenience_readwrite_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_int) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_int(deviceID, context, queue, num_elements); + return test_pipe_readwrite_int(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_uint) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_uint(deviceID, context, queue, num_elements); + return test_pipe_readwrite_uint(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_short) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_short(deviceID, context, queue, num_elements); + return test_pipe_readwrite_short(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_ushort) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_ushort(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ushort(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_char) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_char(deviceID, context, queue, num_elements); + return test_pipe_readwrite_char(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_uchar) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_uchar(deviceID, context, queue, num_elements); + return test_pipe_readwrite_uchar(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_float) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_float(deviceID, context, queue, num_elements); + return test_pipe_readwrite_float(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_half) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_half(deviceID, context, queue, num_elements); + return test_pipe_readwrite_half(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_long) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_long(deviceID, context, queue, num_elements); + return test_pipe_readwrite_long(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_ulong) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_ulong(deviceID, context, queue, num_elements); + return test_pipe_readwrite_ulong(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_double( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_double) { useConvenienceBuiltIn = 1; useSubgroupReserve = 0; useWorkgroupReserve = 0; - return test_pipe_readwrite_double(deviceID, context, queue, num_elements); + return test_pipe_readwrite_double(device, context, queue, num_elements); } -int test_pipe_convenience_readwrite_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(pipe_convenience_readwrite_struct) { const char *kernelNames[] = {"test_pipe_convenience_write_struct","test_pipe_convenience_read_struct"}; - return test_pipe_readwrite_struct_generic(deviceID, context, queue, num_elements, pipe_convenience_readwrite_struct_kernel_code, kernelNames); + return test_pipe_readwrite_struct_generic( + device, context, queue, num_elements, + pipe_convenience_readwrite_struct_kernel_code, kernelNames); } diff --git a/test_conformance/pipes/test_pipe_readwrite_errors.cpp b/test_conformance/pipes/test_pipe_readwrite_errors.cpp index d4b45248..087da1fb 100644 --- a/test_conformance/pipes/test_pipe_readwrite_errors.cpp +++ b/test_conformance/pipes/test_pipe_readwrite_errors.cpp @@ -20,8 +20,9 @@ #include #include -#include "procs.h" #include "harness/errorHelpers.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" const char* pipe_readwrite_errors_kernel_code = { "__kernel void test_pipe_write_error(__global int *src, __write_only pipe int out_pipe, __global int *status)\n" @@ -62,7 +63,7 @@ const char* pipe_readwrite_errors_kernel_code = { }; -int test_pipe_readwrite_errors(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_readwrite_errors) { clMemWrapper pipe; clMemWrapper buffers[3]; diff --git a/test_conformance/pipes/test_pipe_subgroups.cpp b/test_conformance/pipes/test_pipe_subgroups.cpp index 8e2f6e57..54bfd998 100644 --- a/test_conformance/pipes/test_pipe_subgroups.cpp +++ b/test_conformance/pipes/test_pipe_subgroups.cpp @@ -21,8 +21,10 @@ #include #include -#include "procs.h" +#include "harness/testHarness.h" #include "harness/errorHelpers.h" +#include "harness/typeWrappers.h" + #define TEST_INT_VALUE 100 const char* pipe_subgroups_kernel_code = { @@ -86,7 +88,7 @@ static int verify_result(void *ptr1, void *ptr2, int n) return 0; } -int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(pipe_subgroups_divergence) { clMemWrapper pipe; clMemWrapper buffers[3]; @@ -112,7 +114,7 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl global_work_size[0] = (cl_uint)num_elements; - if (!is_extension_available(deviceID, "cl_khr_subgroups")) + if (!is_extension_available(device, "cl_khr_subgroups")) { log_info("cl_khr_subgroups is not supported on this platform. Skipping " "test.\n"); @@ -165,7 +167,7 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl test_error_ret(err, " Unable to get work group size to use", -1); cl_platform_id platform; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), + err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); test_error_ret(err, " clGetDeviceInfo failed", -1); @@ -173,7 +175,10 @@ int test_pipe_subgroups_divergence(cl_device_id deviceID, cl_context context, cl (clGetKernelSubGroupInfoKHR_fn)clGetExtensionFunctionAddressForPlatform( platform, "clGetKernelSubGroupInfoKHR"); - err = clGetKernelSubGroupInfoKHR(kernel[0], deviceID, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, sizeof(local_work_size[0]), &local_work_size[0], sizeof(subgroup_count), &subgroup_count, NULL); + err = clGetKernelSubGroupInfoKHR( + kernel[0], device, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR, + sizeof(local_work_size[0]), &local_work_size[0], sizeof(subgroup_count), + &subgroup_count, NULL); test_error_ret(err, " clGetKernelSubGroupInfoKHR failed", -1); if(subgroup_count <= 1) { From 6eb1aa1d0a214116dc1c5496c741bb2c9a79c70f Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:44:59 +0000 Subject: [PATCH 31/36] Migrate printf suite to the new test registration framework (#2311) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/printf/test_printf.cpp | 154 +++++++----------------- 1 file changed, 43 insertions(+), 111 deletions(-) diff --git a/test_conformance/printf/test_printf.cpp b/test_conformance/printf/test_printf.cpp index 69bf1abb..a98a6efc 100644 --- a/test_conformance/printf/test_printf.cpp +++ b/test_conformance/printf/test_printf.cpp @@ -929,123 +929,77 @@ int doTest(cl_command_queue queue, cl_context context, } -int test_int(cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(int) { return doTest(gQueue, gContext, TYPE_INT, device); } + +REGISTER_TEST(long) { return doTest(gQueue, gContext, TYPE_LONG, device); } + +REGISTER_TEST(half) { return doTest(gQueue, gContext, TYPE_HALF, device); } + +REGISTER_TEST(half_limits) { - return doTest(gQueue, gContext, TYPE_INT, deviceID); + return doTest(gQueue, gContext, TYPE_HALF_LIMITS, device); } -int test_long(cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(float) { return doTest(gQueue, gContext, TYPE_FLOAT, device); } + +REGISTER_TEST(float_limits) { - return doTest(gQueue, gContext, TYPE_LONG, deviceID); + return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, device); } -int test_half(cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(double) { return doTest(gQueue, gContext, TYPE_DOUBLE, device); } + +REGISTER_TEST(double_limits) { - return doTest(gQueue, gContext, TYPE_HALF, deviceID); + return doTest(gQueue, gContext, TYPE_DOUBLE_LIMITS, device); } -int test_half_limits(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(octal) { return doTest(gQueue, gContext, TYPE_OCTAL, device); } + +REGISTER_TEST(unsigned) { - return doTest(gQueue, gContext, TYPE_HALF_LIMITS, deviceID); + return doTest(gQueue, gContext, TYPE_UNSIGNED, device); } -int test_float(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(hexadecimal) { - return doTest(gQueue, gContext, TYPE_FLOAT, deviceID); + return doTest(gQueue, gContext, TYPE_HEXADEC, device); } -int test_float_limits(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(char) { return doTest(gQueue, gContext, TYPE_CHAR, device); } + +REGISTER_TEST(string) { return doTest(gQueue, gContext, TYPE_STRING, device); } + +REGISTER_TEST(format_string) { - return doTest(gQueue, gContext, TYPE_FLOAT_LIMITS, deviceID); + return doTest(gQueue, gContext, TYPE_FORMAT_STRING, device); } -int test_double(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vector) { return doTest(gQueue, gContext, TYPE_VECTOR, device); } + +REGISTER_TEST(address_space) { - return doTest(gQueue, gContext, TYPE_DOUBLE, deviceID); + return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, device); } -int test_double_limits(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mixed_format_random) { - return doTest(gQueue, gContext, TYPE_DOUBLE_LIMITS, deviceID); + return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, device); } -int test_octal(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(length_specifier) { - return doTest(gQueue, gContext, TYPE_OCTAL, deviceID); + return doTest(gQueue, gContext, TYPE_LENGTH_SPECIFIER, device); } -int test_unsigned(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_UNSIGNED, deviceID); -} - -int test_hexadecimal(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_HEXADEC, deviceID); -} - -int test_char(cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) -{ - return doTest(gQueue, gContext, TYPE_CHAR, deviceID); -} - -int test_string(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_STRING, deviceID); -} - -int test_format_string(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_FORMAT_STRING, deviceID); -} - -int test_vector(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_VECTOR, deviceID); -} - -int test_address_space(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, deviceID); -} - -int test_mixed_format_random(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, deviceID); -} - -int test_length_specifier(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) -{ - return doTest(gQueue, gContext, TYPE_LENGTH_SPECIFIER, deviceID); -} - -int test_buffer_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_size) { size_t printf_buff_size = 0; const size_t printf_buff_size_req = !gIsEmbedded ? (1024 * 1024UL) : 1024UL; const size_t config_size = sizeof(printf_buff_size); cl_int err = CL_SUCCESS; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PRINTF_BUFFER_SIZE, config_size, + err = clGetDeviceInfo(device, CL_DEVICE_PRINTF_BUFFER_SIZE, config_size, &printf_buff_size, NULL); if (err != CL_SUCCESS) { @@ -1062,30 +1016,6 @@ int test_buffer_size(cl_device_id deviceID, cl_context context, return TEST_PASS; } -test_definition test_list[] = { - ADD_TEST(int), - ADD_TEST(long), - ADD_TEST(half), - ADD_TEST(half_limits), - ADD_TEST(float), - ADD_TEST(float_limits), - ADD_TEST(double), - ADD_TEST(double_limits), - ADD_TEST(octal), - ADD_TEST(unsigned), - ADD_TEST(hexadecimal), - ADD_TEST(char), - ADD_TEST(string), - ADD_TEST(format_string), - ADD_TEST(vector), - ADD_TEST(address_space), - ADD_TEST(buffer_size), - ADD_TEST(mixed_format_random), - ADD_TEST(length_specifier), -}; - -const int test_num = ARRAY_SIZE( test_list ); - //----------------------------------------- // printUsage //----------------------------------------- @@ -1094,9 +1024,9 @@ static void printUsage(void) log_info("test_printf: \n"); log_info("\tdefault is to run the full test on the default device\n"); log_info("\n"); - for (int i = 0; i < test_num; i++) + for (size_t i = 0; i < test_registry::getInstance().num_tests(); i++) { - log_info("\t%s\n", test_list[i].name); + log_info("\t%s\n", test_registry::getInstance().definitions()[i].name); } } @@ -1167,7 +1097,9 @@ int main(int argc, const char* argv[]) gMTdata = MTdataHolder(gRandomSeed); - int err = runTestHarnessWithCheck( argCount, argList, test_num, test_list, true, 0, InitCL ); + int err = runTestHarnessWithCheck( + argCount, argList, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), true, 0, InitCL); if(gQueue) { From aed6c3a214ab073f2bf8621048b260e0c0aa6be2 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:49:24 +0000 Subject: [PATCH 32/36] Migrate relationals suite to the new test registration framework (#2312) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/relationals/main.cpp | 35 +----------- test_conformance/relationals/procs.h | 55 ------------------- test_conformance/relationals/testBase.h | 16 ++++-- .../relationals/test_comparisons_fp.cpp | 36 +++++------- .../relationals/test_relationals.cpp | 10 ++-- .../relationals/test_shuffles.cpp | 11 ++-- 6 files changed, 39 insertions(+), 124 deletions(-) delete mode 100644 test_conformance/relationals/procs.h diff --git a/test_conformance/relationals/main.cpp b/test_conformance/relationals/main.cpp index 61bde2d0..db222a2d 100644 --- a/test_conformance/relationals/main.cpp +++ b/test_conformance/relationals/main.cpp @@ -14,15 +14,9 @@ // limitations under the License. // #include "harness/compat.h" - -#include -#include -#include "procs.h" #include "harness/testHarness.h" -#if !defined(_WIN32) -#include -#endif +#include "testBase.h" #if DENSE_PACK_VECS const int g_vector_aligns[] = {0, 1, 2, 3, 4, @@ -44,32 +38,9 @@ const int g_vector_allocs[] = {0, 1, 2, 4, 4, 16, 16, 16, 16}; -test_definition test_list[] = { - ADD_TEST( relational_any ), - ADD_TEST( relational_all ), - ADD_TEST( relational_bitselect ), - ADD_TEST( relational_select_signed ), - ADD_TEST( relational_select_unsigned ), - - ADD_TEST( relational_isequal ), - ADD_TEST( relational_isnotequal ), - ADD_TEST( relational_isgreater ), - ADD_TEST( relational_isgreaterequal ), - ADD_TEST( relational_isless ), - ADD_TEST( relational_islessequal ), - ADD_TEST( relational_islessgreater ), - - ADD_TEST( shuffle_copy ), - ADD_TEST( shuffle_function_call ), - ADD_TEST( shuffle_array_cast ), - ADD_TEST( shuffle_built_in ), - ADD_TEST( shuffle_built_in_dual_input ), -}; - -const int test_num = ARRAY_SIZE( test_list ); - int main(int argc, const char *argv[]) { - return runTestHarness(argc, argv, test_num, test_list, false, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); } diff --git a/test_conformance/relationals/procs.h b/test_conformance/relationals/procs.h deleted file mode 100644 index 25e1ab32..00000000 --- a/test_conformance/relationals/procs.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) 2017 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/conversions.h" -#include "harness/mt19937.h" - -// The number of errors to print out for each test in the shuffle tests -#define MAX_ERRORS_TO_PRINT 1 - -extern const int g_vector_aligns[]; -extern const int g_vector_allocs[]; - -#define DENSE_PACK_VECS 1 - -extern int create_program_and_kernel(const char *source, const char *kernel_name, cl_program *program_ret, cl_kernel *kernel_ret); - -extern int test_relational_any(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_all(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_bitselect(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_select_signed(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_select_unsigned(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_relational_isequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_isnotequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_isgreater(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_isgreaterequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_isless(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_islessequal(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_relational_islessgreater(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_shuffles(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffles_16(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffles_dual(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffle_copy(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffle_function_call(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffle_array_cast(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffle_built_in(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_shuffle_built_in_dual_input(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - - diff --git a/test_conformance/relationals/testBase.h b/test_conformance/relationals/testBase.h index 5b49bfd7..f284fef9 100644 --- a/test_conformance/relationals/testBase.h +++ b/test_conformance/relationals/testBase.h @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -17,15 +17,21 @@ #define _testBase_h #include "harness/compat.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" +#include "harness/conversions.h" #include #include #include #include -#include "procs.h" +// The number of errors to print out for each test in the shuffle tests +#define MAX_ERRORS_TO_PRINT 1 + +extern const int g_vector_aligns[]; +extern const int g_vector_allocs[]; + +#define DENSE_PACK_VECS 1 #endif // _testBase_h - - - diff --git a/test_conformance/relationals/test_comparisons_fp.cpp b/test_conformance/relationals/test_comparisons_fp.cpp index 14b1696f..66ab0729 100644 --- a/test_conformance/relationals/test_comparisons_fp.cpp +++ b/test_conformance/relationals/test_comparisons_fp.cpp @@ -596,48 +596,42 @@ cl_int IsLessGreaterFPTest::SetUp(int elements) return RelationalsFPTest::SetUp(elements); } -int test_relational_isequal(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_isequal) { - return MakeAndRunTest(device, context, queue, numElements); + return MakeAndRunTest(device, context, queue, num_elements); } -int test_relational_isnotequal(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_isnotequal) { return MakeAndRunTest(device, context, queue, - numElements); + num_elements); } -int test_relational_isgreater(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_isgreater) { - return MakeAndRunTest(device, context, queue, numElements); + return MakeAndRunTest(device, context, queue, + num_elements); } -int test_relational_isgreaterequal(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_isgreaterequal) { return MakeAndRunTest(device, context, queue, - numElements); + num_elements); } -int test_relational_isless(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_isless) { - return MakeAndRunTest(device, context, queue, numElements); + return MakeAndRunTest(device, context, queue, num_elements); } -int test_relational_islessequal(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_islessequal) { return MakeAndRunTest(device, context, queue, - numElements); + num_elements); } -int test_relational_islessgreater(cl_device_id device, cl_context context, - cl_command_queue queue, int numElements) +REGISTER_TEST(relational_islessgreater) { return MakeAndRunTest(device, context, queue, - numElements); + num_elements); } diff --git a/test_conformance/relationals/test_relationals.cpp b/test_conformance/relationals/test_relationals.cpp index d744fb2a..7f0be72a 100644 --- a/test_conformance/relationals/test_relationals.cpp +++ b/test_conformance/relationals/test_relationals.cpp @@ -199,7 +199,7 @@ int anyVerifyFn( ExplicitType vecType, unsigned int vecSize, void *inData ) } } -int test_relational_any(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(relational_any) { ExplicitType vecType[] = { kChar, kShort, kInt, kLong }; unsigned int vecSizes[] = { 1, 2, 3, 4, 8, 16, 0 }; @@ -268,7 +268,7 @@ int allVerifyFn( ExplicitType vecType, unsigned int vecSize, void *inData ) } } -int test_relational_all(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(relational_all) { ExplicitType vecType[] = { kChar, kShort, kInt, kLong }; unsigned int vecSizes[] = { 1, 2, 3, 4, 8, 16, 0 }; @@ -526,7 +526,7 @@ void bitselect_verify_fn( ExplicitType vecType, ExplicitType testVecType, unsign } } -int test_relational_bitselect(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(relational_bitselect) { constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, @@ -626,7 +626,7 @@ void select_signed_verify_fn( ExplicitType vecType, ExplicitType testVecType, un memcpy( outData, ( yep ) ? inDataB : inDataA, get_explicit_type_size( vecType ) ); } -int test_relational_select_signed(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(relational_select_signed) { constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, @@ -732,7 +732,7 @@ void select_unsigned_verify_fn( ExplicitType vecType, ExplicitType testVecType, memcpy( outData, ( yep ) ? inDataB : inDataA, get_explicit_type_size( vecType ) ); } -int test_relational_select_unsigned(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(relational_select_unsigned) { constexpr ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, diff --git a/test_conformance/relationals/test_shuffles.cpp b/test_conformance/relationals/test_shuffles.cpp index 14924374..839474ca 100644 --- a/test_conformance/relationals/test_shuffles.cpp +++ b/test_conformance/relationals/test_shuffles.cpp @@ -926,33 +926,32 @@ int test_shuffle_random(cl_device_id device, cl_context context, cl_command_queu return totalError; } -int test_shuffle_copy(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) +REGISTER_TEST(shuffle_copy) { RandomSeed seed(gRandomSeed); return test_shuffle_random( device, context, queue, kNormalMode, seed ); } -int test_shuffle_function_call(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) +REGISTER_TEST(shuffle_function_call) { RandomSeed seed(gRandomSeed); return test_shuffle_random( device, context, queue, kFunctionCallMode, seed ); } -int test_shuffle_array_cast(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) +REGISTER_TEST(shuffle_array_cast) { RandomSeed seed(gRandomSeed); return test_shuffle_random( device, context, queue, kArrayAccessMode, seed ); } -int test_shuffle_built_in(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) +REGISTER_TEST(shuffle_built_in) { RandomSeed seed(gRandomSeed); return test_shuffle_random( device, context, queue, kBuiltInFnMode, seed ); } -int test_shuffle_built_in_dual_input(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) +REGISTER_TEST(shuffle_built_in_dual_input) { RandomSeed seed(gRandomSeed); return test_shuffle_random( device, context, queue, kBuiltInDualInputFnMode, seed ); } - From 3f7774b08937af571eadf42707e5098d2475c19b Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:53:47 +0000 Subject: [PATCH 33/36] Migrate subgroups suite to the new test registration framework (#2313) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/subgroups/main.cpp | 37 ++-------- test_conformance/subgroups/procs.h | 71 ------------------- test_conformance/subgroups/test_barrier.cpp | 7 +- test_conformance/subgroups/test_ifp.cpp | 7 +- test_conformance/subgroups/test_queries.cpp | 7 +- test_conformance/subgroups/test_subgroup.cpp | 7 +- .../subgroups/test_subgroup_ballot.cpp | 4 +- .../test_subgroup_clustered_reduce.cpp | 6 +- .../test_subgroup_extended_types.cpp | 6 +- .../test_subgroup_non_uniform_arithmetic.cpp | 6 +- .../test_subgroup_non_uniform_vote.cpp | 6 +- .../subgroups/test_subgroup_rotate.cpp | 4 +- .../subgroups/test_subgroup_shuffle.cpp | 4 +- .../test_subgroup_shuffle_relative.cpp | 6 +- test_conformance/subgroups/test_workitem.cpp | 7 +- 15 files changed, 25 insertions(+), 160 deletions(-) delete mode 100644 test_conformance/subgroups/procs.h diff --git a/test_conformance/subgroups/main.cpp b/test_conformance/subgroups/main.cpp index a3ae910d..36c86d1b 100644 --- a/test_conformance/subgroups/main.cpp +++ b/test_conformance/subgroups/main.cpp @@ -14,39 +14,15 @@ // limitations under the License. // #include "harness/compat.h" - -#include -#include -#include "procs.h" #include "harness/testHarness.h" -#include "CL/cl_half.h" +#include "harness/kernelHelpers.h" +#include "harness/mt19937.cpp" + +#include MTdata gMTdata; cl_half_rounding_mode g_rounding_mode; -test_definition test_list[] = { - ADD_TEST_VERSION(sub_group_info_ext, Version(2, 0)), - ADD_TEST_VERSION(sub_group_info_core, Version(2, 1)), - ADD_TEST_VERSION(work_item_functions_ext, Version(2, 0)), - ADD_TEST_VERSION(work_item_functions_core, Version(2, 1)), - ADD_TEST_VERSION(subgroup_functions_ext, Version(2, 0)), - ADD_TEST_VERSION(subgroup_functions_core, Version(2, 1)), - ADD_TEST_VERSION(barrier_functions_ext, Version(2, 0)), - ADD_TEST_VERSION(barrier_functions_core, Version(2, 1)), - ADD_TEST_VERSION(ifp_ext, Version(2, 0)), - ADD_TEST_VERSION(ifp_core, Version(2, 1)), - ADD_TEST(subgroup_functions_extended_types), - ADD_TEST(subgroup_functions_non_uniform_vote), - ADD_TEST(subgroup_functions_non_uniform_arithmetic), - ADD_TEST(subgroup_functions_ballot), - ADD_TEST(subgroup_functions_clustered_reduce), - ADD_TEST(subgroup_functions_shuffle), - ADD_TEST(subgroup_functions_shuffle_relative), - ADD_TEST(subgroup_functions_rotate), -}; - -const int test_num = ARRAY_SIZE(test_list); - static test_status InitCL(cl_device_id device) { auto version = get_device_cl_version(device); @@ -91,6 +67,7 @@ static test_status InitCL(cl_device_id device) int main(int argc, const char *argv[]) { gMTdata = init_genrand(0); - return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, - InitCL); + return runTestHarnessWithCheck( + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, InitCL); } diff --git a/test_conformance/subgroups/procs.h b/test_conformance/subgroups/procs.h deleted file mode 100644 index ba40a9f9..00000000 --- a/test_conformance/subgroups/procs.h +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) 2017 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef _procs_h -#define _procs_h - -#include "harness/testHarness.h" -#include "harness/kernelHelpers.h" -#include "harness/errorHelpers.h" -#include "harness/conversions.h" -#include "harness/typeWrappers.h" - -int test_sub_group_info_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_sub_group_info_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_work_item_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_work_item_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_subgroup_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_subgroup_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_barrier_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_barrier_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_ifp_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_ifp_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_subgroup_functions_extended_types(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_subgroup_functions_non_uniform_vote(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_subgroup_functions_non_uniform_arithmetic(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_subgroup_functions_ballot(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_subgroup_functions_clustered_reduce(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_subgroup_functions_shuffle(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -int test_subgroup_functions_shuffle_relative(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_subgroup_functions_rotate(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -#endif /*_procs_h*/ diff --git a/test_conformance/subgroups/test_barrier.cpp b/test_conformance/subgroups/test_barrier.cpp index f97e2a33..608514de 100644 --- a/test_conformance/subgroups/test_barrier.cpp +++ b/test_conformance/subgroups/test_barrier.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "harness/conversions.h" #include "harness/typeWrappers.h" @@ -174,14 +173,12 @@ int test_barrier_functions(cl_device_id device, cl_context context, return error; } -int test_barrier_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(barrier_functions_core, Version(2, 1)) { return test_barrier_functions(device, context, queue, num_elements, true); } -int test_barrier_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(barrier_functions_ext, Version(2, 0)) { bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); diff --git a/test_conformance/subgroups/test_ifp.cpp b/test_conformance/subgroups/test_ifp.cpp index 61c65673..26403ef8 100644 --- a/test_conformance/subgroups/test_ifp.cpp +++ b/test_conformance/subgroups/test_ifp.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "harness/conversions.h" #include "harness/typeWrappers.h" @@ -332,8 +331,7 @@ static test_status checkIFPSupport(cl_device_id device, bool &ifpSupport) return TEST_PASS; } -int test_ifp_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(ifp_core, Version(2, 1)) { bool ifpSupport = true; test_status error; @@ -351,8 +349,7 @@ int test_ifp_core(cl_device_id device, cl_context context, return test_ifp(device, context, queue, num_elements, true); } -int test_ifp_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(ifp_ext, Version(2, 0)) { bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); bool ifpSupport = true; diff --git a/test_conformance/subgroups/test_queries.cpp b/test_conformance/subgroups/test_queries.cpp index 6b940935..e9e6ca5f 100644 --- a/test_conformance/subgroups/test_queries.cpp +++ b/test_conformance/subgroups/test_queries.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" typedef struct @@ -190,14 +189,12 @@ int test_sub_group_info(cl_device_id device, cl_context context, return 0; } -int test_sub_group_info_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(sub_group_info_core, Version(2, 1)) { return test_sub_group_info(device, context, queue, num_elements, true); } -int test_sub_group_info_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(sub_group_info_ext, Version(2, 0)) { bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); diff --git a/test_conformance/subgroups/test_subgroup.cpp b/test_conformance/subgroups/test_subgroup.cpp index 3b72913e..e88848b9 100644 --- a/test_conformance/subgroups/test_subgroup.cpp +++ b/test_conformance/subgroups/test_subgroup.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_kernels.h" #include "subgroup_common_templates.h" @@ -188,14 +187,12 @@ int test_subgroup_functions(cl_device_id device, cl_context context, return error; } -int test_subgroup_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(subgroup_functions_core, Version(2, 1)) { return test_subgroup_functions(device, context, queue, num_elements, true); } -int test_subgroup_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(subgroup_functions_ext, Version(2, 0)) { bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); diff --git a/test_conformance/subgroups/test_subgroup_ballot.cpp b/test_conformance/subgroups/test_subgroup_ballot.cpp index 0eb0c499..69976c50 100644 --- a/test_conformance/subgroups/test_subgroup_ballot.cpp +++ b/test_conformance/subgroups/test_subgroup_ballot.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_templates.h" #include "harness/typeWrappers.h" @@ -888,8 +887,7 @@ template int run_non_uniform_broadcast_for_type(RunTestForType rft) } -int test_subgroup_functions_ballot(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(subgroup_functions_ballot) { if (!is_extension_available(device, "cl_khr_subgroup_ballot")) { diff --git a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp index fddcce4e..c21880f9 100644 --- a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp +++ b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_templates.h" #include "harness/typeWrappers.h" @@ -181,10 +180,7 @@ int run_cluster_logical_and_or_xor_for_type(RunTestForType rft) } } -int test_subgroup_functions_clustered_reduce(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(subgroup_functions_clustered_reduce) { if (!is_extension_available(device, "cl_khr_subgroup_clustered_reduce")) { diff --git a/test_conformance/subgroups/test_subgroup_extended_types.cpp b/test_conformance/subgroups/test_subgroup_extended_types.cpp index c9e6bb61..250577de 100644 --- a/test_conformance/subgroups/test_subgroup_extended_types.cpp +++ b/test_conformance/subgroups/test_subgroup_extended_types.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_kernels.h" #include "subgroup_common_templates.h" @@ -54,10 +53,7 @@ template int run_scan_reduction_for_type(RunTestForType rft) } -int test_subgroup_functions_extended_types(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(subgroup_functions_extended_types) { if (!is_extension_available(device, "cl_khr_subgroup_extended_types")) { diff --git a/test_conformance/subgroups/test_subgroup_non_uniform_arithmetic.cpp b/test_conformance/subgroups/test_subgroup_non_uniform_arithmetic.cpp index 02fc507b..9894f428 100644 --- a/test_conformance/subgroups/test_subgroup_non_uniform_arithmetic.cpp +++ b/test_conformance/subgroups/test_subgroup_non_uniform_arithmetic.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "harness/typeWrappers.h" #include "subgroup_common_templates.h" @@ -121,10 +120,7 @@ int run_functions_logical_and_or_xor_for_type(RunTestForType rft) } -int test_subgroup_functions_non_uniform_arithmetic(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(subgroup_functions_non_uniform_arithmetic) { if (!is_extension_available(device, "cl_khr_subgroup_non_uniform_arithmetic")) diff --git a/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp b/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp index 3be1ba30..74e9144e 100644 --- a/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp +++ b/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "harness/typeWrappers.h" #include @@ -253,10 +252,7 @@ template int run_vote_all_equal_for_type(RunTestForType rft) } } -int test_subgroup_functions_non_uniform_vote(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(subgroup_functions_non_uniform_vote) { if (!is_extension_available(device, "cl_khr_subgroup_non_uniform_vote")) { diff --git a/test_conformance/subgroups/test_subgroup_rotate.cpp b/test_conformance/subgroups/test_subgroup_rotate.cpp index db0f48eb..ae828677 100644 --- a/test_conformance/subgroups/test_subgroup_rotate.cpp +++ b/test_conformance/subgroups/test_subgroup_rotate.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_kernels.h" #include "subgroup_common_templates.h" @@ -59,8 +58,7 @@ template int run_clustered_rotate_for_type(RunTestForType rft) } -int test_subgroup_functions_rotate(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(subgroup_functions_rotate) { if (!is_extension_available(device, "cl_khr_subgroup_rotate")) { diff --git a/test_conformance/subgroups/test_subgroup_shuffle.cpp b/test_conformance/subgroups/test_subgroup_shuffle.cpp index 56231cbf..5332884f 100644 --- a/test_conformance/subgroups/test_subgroup_shuffle.cpp +++ b/test_conformance/subgroups/test_subgroup_shuffle.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_kernels.h" #include "subgroup_common_templates.h" @@ -33,8 +32,7 @@ template int run_shuffle_for_type(RunTestForType rft) } -int test_subgroup_functions_shuffle(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(subgroup_functions_shuffle) { if (!is_extension_available(device, "cl_khr_subgroup_shuffle")) { diff --git a/test_conformance/subgroups/test_subgroup_shuffle_relative.cpp b/test_conformance/subgroups/test_subgroup_shuffle_relative.cpp index caa1dccc..eb0e0958 100644 --- a/test_conformance/subgroups/test_subgroup_shuffle_relative.cpp +++ b/test_conformance/subgroups/test_subgroup_shuffle_relative.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "subhelpers.h" #include "subgroup_common_kernels.h" #include "subgroup_common_templates.h" @@ -33,10 +32,7 @@ template int run_shuffle_relative_for_type(RunTestForType rft) } -int test_subgroup_functions_shuffle_relative(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(subgroup_functions_shuffle_relative) { if (!is_extension_available(device, "cl_khr_subgroup_shuffle_relative")) { diff --git a/test_conformance/subgroups/test_workitem.cpp b/test_conformance/subgroups/test_workitem.cpp index 5b2a5eb8..b4bbad74 100644 --- a/test_conformance/subgroups/test_workitem.cpp +++ b/test_conformance/subgroups/test_workitem.cpp @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" #include "harness/conversions.h" #include "harness/typeWrappers.h" #include @@ -321,14 +320,12 @@ int test_work_item_functions(cl_device_id device, cl_context context, return 0; } -int test_work_item_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(work_item_functions_core, Version(2, 1)) { return test_work_item_functions(device, context, queue, num_elements, true); } -int test_work_item_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(work_item_functions_ext, Version(2, 0)) { bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); From fbeebac9d5c47cfcdd5c0a7a6f3335376fd6eb1a Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Sun, 9 Mar 2025 09:59:01 +0000 Subject: [PATCH 34/36] Migrate buffers suite to the new test registration framework (#2315) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/buffers/array_info.cpp | 6 +- test_conformance/buffers/main.cpp | 114 +--------- test_conformance/buffers/procs.h | 132 ----------- test_conformance/buffers/testBase.h | 30 +++ test_conformance/buffers/test_buffer_copy.cpp | 7 +- test_conformance/buffers/test_buffer_fill.cpp | 112 +++++----- test_conformance/buffers/test_buffer_map.cpp | 25 ++- test_conformance/buffers/test_buffer_mem.cpp | 21 +- .../buffers/test_buffer_migrate.cpp | 40 ++-- test_conformance/buffers/test_buffer_read.cpp | 84 ++++--- .../buffers/test_buffer_write.cpp | 208 +++++++++++------- .../buffers/test_image_migrate.cpp | 47 ++-- test_conformance/buffers/test_sub_buffers.cpp | 42 ++-- 13 files changed, 379 insertions(+), 489 deletions(-) delete mode 100644 test_conformance/buffers/procs.h create mode 100644 test_conformance/buffers/testBase.h diff --git a/test_conformance/buffers/array_info.cpp b/test_conformance/buffers/array_info.cpp index f143cf37..aa6c04c3 100644 --- a/test_conformance/buffers/array_info.cpp +++ b/test_conformance/buffers/array_info.cpp @@ -21,11 +21,9 @@ #include #include -#include "procs.h" +#include "testBase.h" - - -int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(array_info_size) { cl_mem memobj; cl_int err; diff --git a/test_conformance/buffers/main.cpp b/test_conformance/buffers/main.cpp index 7c5502a7..f2a8c2a3 100644 --- a/test_conformance/buffers/main.cpp +++ b/test_conformance/buffers/main.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -13,116 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" -#include -#include -#include -#include "procs.h" +#include "harness/compat.h" #include "harness/testHarness.h" -test_definition test_list[] = { - ADD_TEST(buffer_read_async_int), - ADD_TEST(buffer_read_async_uint), - ADD_TEST(buffer_read_async_long), - ADD_TEST(buffer_read_async_ulong), - ADD_TEST(buffer_read_async_short), - ADD_TEST(buffer_read_async_ushort), - ADD_TEST(buffer_read_async_char), - ADD_TEST(buffer_read_async_uchar), - ADD_TEST(buffer_read_async_float), - ADD_TEST(buffer_read_array_barrier_int), - ADD_TEST(buffer_read_array_barrier_uint), - ADD_TEST(buffer_read_array_barrier_long), - ADD_TEST(buffer_read_array_barrier_ulong), - ADD_TEST(buffer_read_array_barrier_short), - ADD_TEST(buffer_read_array_barrier_ushort), - ADD_TEST(buffer_read_array_barrier_char), - ADD_TEST(buffer_read_array_barrier_uchar), - ADD_TEST(buffer_read_array_barrier_float), - ADD_TEST(buffer_read_int), - ADD_TEST(buffer_read_uint), - ADD_TEST(buffer_read_long), - ADD_TEST(buffer_read_ulong), - ADD_TEST(buffer_read_short), - ADD_TEST(buffer_read_ushort), - ADD_TEST(buffer_read_float), - ADD_TEST(buffer_read_half), - ADD_TEST(buffer_read_char), - ADD_TEST(buffer_read_uchar), - ADD_TEST(buffer_read_struct), - ADD_TEST(buffer_read_random_size), - ADD_TEST(buffer_map_read_int), - ADD_TEST(buffer_map_read_uint), - ADD_TEST(buffer_map_read_long), - ADD_TEST(buffer_map_read_ulong), - ADD_TEST(buffer_map_read_short), - ADD_TEST(buffer_map_read_ushort), - ADD_TEST(buffer_map_read_char), - ADD_TEST(buffer_map_read_uchar), - ADD_TEST(buffer_map_read_float), - ADD_TEST(buffer_map_read_struct), - - ADD_TEST(buffer_map_write_int), - ADD_TEST(buffer_map_write_uint), - ADD_TEST(buffer_map_write_long), - ADD_TEST(buffer_map_write_ulong), - ADD_TEST(buffer_map_write_short), - ADD_TEST(buffer_map_write_ushort), - ADD_TEST(buffer_map_write_char), - ADD_TEST(buffer_map_write_uchar), - ADD_TEST(buffer_map_write_float), - ADD_TEST(buffer_map_write_struct), - - ADD_TEST(buffer_write_int), - ADD_TEST(buffer_write_uint), - ADD_TEST(buffer_write_short), - ADD_TEST(buffer_write_ushort), - ADD_TEST(buffer_write_char), - ADD_TEST(buffer_write_uchar), - ADD_TEST(buffer_write_float), - ADD_TEST(buffer_write_half), - ADD_TEST(buffer_write_long), - ADD_TEST(buffer_write_ulong), - ADD_TEST(buffer_write_struct), - ADD_TEST(buffer_write_async_int), - ADD_TEST(buffer_write_async_uint), - ADD_TEST(buffer_write_async_short), - ADD_TEST(buffer_write_async_ushort), - ADD_TEST(buffer_write_async_char), - ADD_TEST(buffer_write_async_uchar), - ADD_TEST(buffer_write_async_float), - ADD_TEST(buffer_write_async_long), - ADD_TEST(buffer_write_async_ulong), - ADD_TEST(buffer_copy), - ADD_TEST(buffer_partial_copy), - ADD_TEST(mem_read_write_flags), - ADD_TEST(mem_write_only_flags), - ADD_TEST(mem_read_only_flags), - ADD_TEST(mem_copy_host_flags), - ADD_TEST(mem_alloc_ref_flags), - ADD_TEST(array_info_size), - - ADD_TEST(sub_buffers_read_write), - ADD_TEST(sub_buffers_read_write_dual_devices), - ADD_TEST(sub_buffers_overlapping), - - ADD_TEST(buffer_fill_int), - ADD_TEST(buffer_fill_uint), - ADD_TEST(buffer_fill_short), - ADD_TEST(buffer_fill_ushort), - ADD_TEST(buffer_fill_char), - ADD_TEST(buffer_fill_uchar), - ADD_TEST(buffer_fill_long), - ADD_TEST(buffer_fill_ulong), - ADD_TEST(buffer_fill_float), - ADD_TEST(buffer_fill_struct), - - ADD_TEST(buffer_migrate), - ADD_TEST(image_migrate), -}; - -const int test_num = ARRAY_SIZE( test_list ); +#include "testBase.h" const cl_mem_flags flag_set[] = { CL_MEM_ALLOC_HOST_PTR, @@ -141,5 +36,6 @@ const char* flag_set_names[] = { int main( int argc, const char *argv[] ) { - return runTestHarness(argc, argv, test_num, test_list, false, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); } diff --git a/test_conformance/buffers/procs.h b/test_conformance/buffers/procs.h deleted file mode 100644 index fb0f851a..00000000 --- a/test_conformance/buffers/procs.h +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright (c) 2017 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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef __PROCS_H__ -#define __PROCS_H__ - -#include "harness/kernelHelpers.h" -#include "harness/testHarness.h" -#include "harness/errorHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/mt19937.h" -#include "harness/conversions.h" - -#ifndef __APPLE__ -#include -#endif - -extern const cl_mem_flags flag_set[]; -extern const char* flag_set_names[]; -#define NUM_FLAGS 5 - -extern int test_buffer_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_random_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_read_write_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_write_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_alloc_ref_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -#endif // #ifndef __PROCS_H__ - diff --git a/test_conformance/buffers/testBase.h b/test_conformance/buffers/testBase.h new file mode 100644 index 00000000..8c5bb0e4 --- /dev/null +++ b/test_conformance/buffers/testBase.h @@ -0,0 +1,30 @@ +// +// Copyright (c) 2025 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef _testBase_h +#define _testBase_h + +#include + +#include "harness/conversions.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" + +extern const cl_mem_flags flag_set[]; +extern const char* flag_set_names[]; + +#define NUM_FLAGS 5 + +#endif // _testBase_h diff --git a/test_conformance/buffers/test_buffer_copy.cpp b/test_conformance/buffers/test_buffer_copy.cpp index 62862d2e..093987f8 100644 --- a/test_conformance/buffers/test_buffer_copy.cpp +++ b/test_conformance/buffers/test_buffer_copy.cpp @@ -21,10 +21,9 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" - static int verify_copy_buffer(int *inptr, int *outptr, int n) { int i; @@ -245,7 +244,7 @@ static int testPartialCopy( cl_command_queue queue, cl_context context, int num_ } // end testPartialCopy() -int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_copy) { int i, err = 0; int size; @@ -271,7 +270,7 @@ int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_copy() -int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_partial_copy) { int i, err = 0; int size; diff --git a/test_conformance/buffers/test_buffer_fill.cpp b/test_conformance/buffers/test_buffer_fill.cpp index 92079794..2e7a22de 100644 --- a/test_conformance/buffers/test_buffer_fill.cpp +++ b/test_conformance/buffers/test_buffer_fill.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #define TEST_PRIME_CHAR 0x77 @@ -557,10 +557,13 @@ static int verify_fill_struct( void *ptr1, void *ptr2, int n ) } - -int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, - int loops, void *inptr[5], void *hostptr[5], void *pattern[5], size_t offset_elements, size_t fill_elements, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) ) +static int test_buffer_fill(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, void *inptr[5], + void *hostptr[5], void *pattern[5], + size_t offset_elements, size_t fill_elements, + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int)) { void *outptr[5]; clProgramWrapper program[5]; @@ -700,7 +703,7 @@ int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_fill() -int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_struct) { TestStruct pattern; size_t ptrSize = sizeof( TestStruct ); @@ -890,7 +893,7 @@ int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_fill_struct() -int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_int) { cl_int *inptr[5]; cl_int *hostptr[5]; @@ -934,10 +937,11 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_ memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, + if (test_buffer_fill(device, context, queue, num_elements, + sizeof(cl_int), (char *)"int", 5, (void **)inptr, + (void **)hostptr, (void **)pattern, offset_elements, fill_elements, - buffer_fill_int_kernel_code, int_kernel_name, foo )) + buffer_fill_int_kernel_code, int_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -955,7 +959,7 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_ } // end test_buffer_int_fill() -int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_uint) { cl_uint *inptr[5]; cl_uint *hostptr[5]; @@ -999,10 +1003,11 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_uint_kernel_code, uint_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_uint), + (char *)"uint", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_uint_kernel_code, uint_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1020,7 +1025,7 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_uint_fill() -int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_short) { cl_short *inptr[5]; cl_short *hostptr[5]; @@ -1064,10 +1069,11 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_short_kernel_code, short_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_short), + (char *)"short", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_short_kernel_code, short_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1085,7 +1091,7 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_short_fill() -int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_ushort) { cl_ushort *inptr[5]; cl_ushort *hostptr[5]; @@ -1129,10 +1135,11 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_ushort_kernel_code, ushort_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_ushort), + (char *)"ushort", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_ushort_kernel_code, ushort_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1150,7 +1157,7 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_ushort_fill() -int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_char) { cl_char *inptr[5]; cl_char *hostptr[5]; @@ -1194,10 +1201,11 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_char_kernel_code, char_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_char), + (char *)"char", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_char_kernel_code, char_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1215,7 +1223,7 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_char_fill() -int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_uchar) { cl_uchar *inptr[5]; cl_uchar *hostptr[5]; @@ -1259,10 +1267,11 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_uchar_kernel_code, uchar_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_uchar), + (char *)"uchar", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_uchar_kernel_code, uchar_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1280,7 +1289,7 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_uchar_fill() -int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_long) { cl_long *inptr[5]; cl_long *hostptr[5]; @@ -1331,10 +1340,11 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_long_kernel_code, long_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"long", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_long_kernel_code, long_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1352,7 +1362,7 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_long_fill() -int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_ulong) { cl_ulong *inptr[5]; cl_ulong *hostptr[5]; @@ -1402,10 +1412,11 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_ulong_kernel_code, ulong_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_ulong), + (char *)"ulong", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_ulong_kernel_code, ulong_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1423,7 +1434,7 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_ulong_fill() -int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_float) { cl_float *inptr[5]; cl_float *hostptr[5]; @@ -1467,10 +1478,11 @@ int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_float_kernel_code, float_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_float), + (char *)"float", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_float_kernel_code, float_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ diff --git a/test_conformance/buffers/test_buffer_map.cpp b/test_conformance/buffers/test_buffer_map.cpp index 382c7a35..5cac90ab 100644 --- a/test_conformance/buffers/test_buffer_map.cpp +++ b/test_conformance/buffers/test_buffer_map.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" @@ -672,12 +672,14 @@ static int test_buffer_map_read( cl_device_id deviceID, cl_context context, cl_c } // end test_buffer_map_read() -#define DECLARE_LOCK_TEST(type, realType) \ -int test_buffer_map_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_LOCK_TEST(type, realType) \ + REGISTER_TEST(buffer_map_read_##type) \ + { \ + return test_buffer_map_read(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_LOCK_TEST(int, cl_int) DECLARE_LOCK_TEST(uint, cl_uint) @@ -689,13 +691,14 @@ DECLARE_LOCK_TEST(char, cl_char) DECLARE_LOCK_TEST(uchar, cl_uchar) DECLARE_LOCK_TEST(float, cl_float) -int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_read_struct) { int (*foo)(void *,int); foo = verify_read_struct; - return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( TestStruct ), (char*)"struct", 1, - buffer_read_struct_kernel_code, struct_kernel_name, foo ); - + return test_buffer_map_read(device, context, queue, num_elements, + sizeof(TestStruct), (char *)"struct", 1, + buffer_read_struct_kernel_code, + struct_kernel_name, foo); } // end test_buffer_map_struct_read() diff --git a/test_conformance/buffers/test_buffer_mem.cpp b/test_conformance/buffers/test_buffer_mem.cpp index 52eb7235..080569a1 100644 --- a/test_conformance/buffers/test_buffer_mem.cpp +++ b/test_conformance/buffers/test_buffer_mem.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #ifndef uchar typedef unsigned char uchar; @@ -66,9 +66,9 @@ static int verify_mem( int *outptr, int n ) } -int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements, - cl_mem_flags flags, const char **kernel_program, - const char *kernel_name) +static int test_mem_flags(cl_context context, cl_command_queue queue, + int num_elements, cl_mem_flags flags, + const char **kernel_program, const char *kernel_name) { clMemWrapper buffers[2]; cl_int *inptr, *outptr; @@ -205,38 +205,35 @@ int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements, return err; } // end test_mem_flags() -int test_mem_read_write_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_read_write_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_READ_WRITE, &mem_read_write_kernel_code, "test_mem_read_write"); } -int test_mem_write_only_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_write_only_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_WRITE_ONLY, &mem_write_kernel_code, "test_mem_write"); } -int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(mem_read_only_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_READ_ONLY, &mem_read_kernel_code, "test_mem_read"); } -int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(mem_copy_host_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE, &mem_read_write_kernel_code, "test_mem_read_write"); } -int test_mem_alloc_ref_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_alloc_ref_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, diff --git a/test_conformance/buffers/test_buffer_migrate.cpp b/test_conformance/buffers/test_buffer_migrate.cpp index 6cdc271b..7ad90668 100644 --- a/test_conformance/buffers/test_buffer_migrate.cpp +++ b/test_conformance/buffers/test_buffer_migrate.cpp @@ -16,7 +16,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #include "harness/testHarness.h" @@ -96,7 +96,7 @@ static cl_int restoreBuffer(cl_command_queue *queues, cl_mem *buffers, cl_uint n return CL_SUCCESS; } -int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_migrate) { int failed = 0; cl_uint i, j; @@ -119,9 +119,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu const size_t wgs[1] = {BUFFER_SIZE}; /* Allocate arrays whose size varies according to the maximum number of sub-devices */ - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(max_sub_devices), &max_sub_devices, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); + return -1; } if (max_sub_devices < 1) { log_error("ERROR: Invalid number of compute units returned.\n"); @@ -156,9 +159,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu } // Attempt to partition the device along each of the allowed affinity domain. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, + sizeof(domains), &domains, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); + return -1; } domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE | @@ -175,7 +181,9 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu // Determine the number of partitions for the device given the specific domain. if (domain) { property[1] = domain; - err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices); + err = clCreateSubDevices(device, + (const cl_device_partition_property *)property, + -1, NULL, &num_devices); if ((err != CL_SUCCESS) || (num_devices == 0)) { print_error(err, "Obtaining the number of partions by affinity failed."); failed = 1; @@ -187,10 +195,14 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu if (num_devices > 1) { // Create each of the sub-devices and a corresponding context. - if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) { - print_error(err, "Failed creating sub devices."); - failed = 1; - goto cleanup; + if ((err = clCreateSubDevices( + device, (const cl_device_partition_property *)property, + num_devices, devices, &num_devices)) + != CL_SUCCESS) + { + print_error(err, "Failed creating sub devices."); + failed = 1; + goto cleanup; } // Create a context containing all the sub-devices @@ -213,7 +225,7 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu } } else { // No partitioning available. Just exercise the APIs on a single device. - devices[0] = deviceID; + devices[0] = device; queues[0] = queue; ctx = context; } diff --git a/test_conformance/buffers/test_buffer_read.cpp b/test_conformance/buffers/test_buffer_read.cpp index 28317880..dbf39ab4 100644 --- a/test_conformance/buffers/test_buffer_read.cpp +++ b/test_conformance/buffers/test_buffer_read.cpp @@ -23,7 +23,7 @@ #include #include -#include "procs.h" +#include "testBase.h" //#define HK_DO_NOT_RUN_SHORT_ASYNC 1 //#define HK_DO_NOT_RUN_USHORT_ASYNC 1 @@ -618,8 +618,11 @@ static int verify_read_struct(TestStruct *outptr, int n) } //----- the test functions -int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, int)) { void *outptr[5]; void *inptr[5]; @@ -758,8 +761,12 @@ int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_read() -int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read_async(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, + const char *kernelCode[], + const char *kernelName[], + int (*fn)(void *, int)) { clProgramWrapper program[5]; clKernelWrapper kernel[5]; @@ -894,8 +901,10 @@ int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_read_array_async() -int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read_array_barrier( + cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements, size_t size, char *type, int loops, + const char *kernelCode[], const char *kernelName[], int (*fn)(void *, int)) { clProgramWrapper program[5]; clKernelWrapper kernel[5]; @@ -1033,12 +1042,14 @@ int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, c } // end test_buffer_read_array_barrier() -#define DECLARE_READ_TEST(type, realType) \ -int test_buffer_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_READ_TEST(type, realType) \ + REGISTER_TEST(buffer_read_##type) \ + { \ + return test_buffer_read(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_READ_TEST(int, cl_int) DECLARE_READ_TEST(uint, cl_uint) @@ -1050,21 +1061,24 @@ DECLARE_READ_TEST(float, cl_float) DECLARE_READ_TEST(char, cl_char) DECLARE_READ_TEST(uchar, cl_uchar) -int test_buffer_read_half(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_half) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID) - return test_buffer_read( deviceID, context, queue, num_elements, sizeof( cl_float ) / 2, (char*)"half", 5, - buffer_read_half_kernel_code, half_kernel_name, verify_read_half ); + PASSIVE_REQUIRE_FP16_SUPPORT(device) + return test_buffer_read(device, context, queue, num_elements, + sizeof(cl_float) / 2, (char *)"half", 5, + buffer_read_half_kernel_code, half_kernel_name, + verify_read_half); } -#define DECLARE_ASYNC_TEST(type, realType) \ -int test_buffer_read_async_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read_async( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_ASYNC_TEST(type, realType) \ + REGISTER_TEST(buffer_read_async_##type) \ + { \ + return test_buffer_read_async(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_ASYNC_TEST(char, cl_char) DECLARE_ASYNC_TEST(uchar, cl_uchar) @@ -1077,12 +1091,14 @@ DECLARE_ASYNC_TEST(ulong, cl_ulong) DECLARE_ASYNC_TEST(float, cl_float) -#define DECLARE_BARRIER_TEST(type, realType) \ -int test_buffer_read_array_barrier_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read_array_barrier( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_BARRIER_TEST(type, realType) \ + REGISTER_TEST(buffer_read_array_barrier_##type) \ + { \ + return test_buffer_read_array_barrier( \ + device, context, queue, num_elements, sizeof(realType), \ + (char *)#type, 5, buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_BARRIER_TEST(int, cl_int) DECLARE_BARRIER_TEST(uint, cl_uint) @@ -1094,7 +1110,7 @@ DECLARE_BARRIER_TEST(char, cl_char) DECLARE_BARRIER_TEST(uchar, cl_uchar) DECLARE_BARRIER_TEST(float, cl_float) -int test_buffer_read_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_struct) { cl_mem buffers[1]; TestStruct *output_ptr; @@ -1305,7 +1321,7 @@ static int testRandomReadSize( cl_device_id deviceID, cl_context context, cl_com } // end testRandomReadSize() -int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_random_size) { int err = 0; int i; @@ -1317,7 +1333,8 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c for ( i = 0; i < 8; i++ ){ start = (cl_uint)get_random_float( 0.f, (float)(num_elements - 8), d ); size = (size_t)get_random_float( 8.f, (float)(num_elements - start), d ); - if (testRandomReadSize( deviceID, context, queue, num_elements, start, size )) + if (testRandomReadSize(device, context, queue, num_elements, start, + size)) err++; } @@ -1325,4 +1342,3 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c return err; } - diff --git a/test_conformance/buffers/test_buffer_write.cpp b/test_conformance/buffers/test_buffer_write.cpp index bf41e48c..36dcc963 100644 --- a/test_conformance/buffers/test_buffer_write.cpp +++ b/test_conformance/buffers/test_buffer_write.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" @@ -621,8 +621,11 @@ static int verify_write_struct( void *ptr1, void *ptr2, int n ) } -int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int), MTdata d ) +static int test_buffer_write(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, void *inptr[5], + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int), MTdata d) { void *outptr[5]; clProgramWrapper program[5]; @@ -787,9 +790,7 @@ int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_que } // end test_buffer_write() - - -int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_struct) { void *outptr[5]; @@ -966,8 +967,11 @@ int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_comm } // end test_buffer_struct_write() -int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) ) +static int test_buffer_write_array_async( + cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements, size_t size, char *type, int loops, void *inptr[5], + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int)) { cl_mem buffers[10]; void *outptr[5]; @@ -1098,7 +1102,7 @@ int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl } // end test_buffer_write_array_async() -int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_int) { int *inptr[5]; size_t ptrSizes[5]; @@ -1124,8 +1128,9 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command inptr[i][j] = (int)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - buffer_write_int_kernel_code, int_kernel_name, foo, d ); + err = test_buffer_write( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5, + (void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1137,7 +1142,7 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_int_write() -int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -1163,8 +1168,10 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - buffer_write_uint_kernel_code, uint_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_uint), (char *)"uint", 5, (void **)inptr, + buffer_write_uint_kernel_code, uint_kernel_name, + foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1176,7 +1183,7 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_uint_write() -int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_short) { short *inptr[5]; size_t ptrSizes[5]; @@ -1202,8 +1209,10 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (cl_short)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - buffer_write_short_kernel_code, short_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, buffer_write_short_kernel_code, + short_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1216,7 +1225,7 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_short_write() -int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -1242,8 +1251,10 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm inptr[i][j] = (cl_ushort)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - buffer_write_ushort_kernel_code, ushort_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, buffer_write_ushort_kernel_code, + ushort_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1256,7 +1267,7 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm } // end test_buffer_ushort_write() -int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_char) { char *inptr[5]; size_t ptrSizes[5]; @@ -1282,8 +1293,10 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = (char)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - buffer_write_char_kernel_code, char_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_char), (char *)"char", 5, (void **)inptr, + buffer_write_char_kernel_code, char_kernel_name, + foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1296,7 +1309,7 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_char_write() -int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_uchar) { uchar *inptr[5]; size_t ptrSizes[5]; @@ -1322,8 +1335,10 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (uchar)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - buffer_write_uchar_kernel_code, uchar_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, buffer_write_uchar_kernel_code, + uchar_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1336,7 +1351,7 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_uchar_write() -int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1362,8 +1377,10 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - buffer_write_float_kernel_code, float_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, buffer_write_float_kernel_code, + float_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1375,9 +1392,9 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_float_write() -int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_half) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID) + PASSIVE_REQUIRE_FP16_SUPPORT(device) float *inptr[5]; size_t ptrSizes[5]; int i, err; @@ -1402,7 +1419,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write(deviceID, context, queue, num_elements, + err = test_buffer_write(device, context, queue, num_elements, sizeof(cl_half), (char *)"half", 5, (void **)inptr, buffer_write_half_kernel_code, half_kernel_name, foo, d); @@ -1417,7 +1434,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_half_write() -int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1450,8 +1467,10 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = (cl_long) genrand_int32(d) ^ ((cl_long) genrand_int32(d) << 32); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr, - buffer_write_long_kernel_code, long_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_long), (char *)"cl_long", 5, + (void **)inptr, buffer_write_long_kernel_code, + long_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1463,7 +1482,7 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_long_write() -int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1495,8 +1514,10 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr, - buffer_write_ulong_kernel_code, ulong_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong long", 5, + (void **)inptr, buffer_write_ulong_kernel_code, + ulong_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1509,68 +1530,68 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_ulong_write() -int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_int) { gTestMap = 1; - return test_buffer_write_int(deviceID, context, queue, num_elements); + return test_buffer_write_int(device, context, queue, num_elements); } -int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_uint) { gTestMap = 1; - return test_buffer_write_uint(deviceID, context, queue, num_elements); + return test_buffer_write_uint(device, context, queue, num_elements); } -int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_long) { gTestMap = 1; - return test_buffer_write_long(deviceID, context, queue, num_elements); + return test_buffer_write_long(device, context, queue, num_elements); } -int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_ulong) { gTestMap = 1; - return test_buffer_write_ulong(deviceID, context, queue, num_elements); + return test_buffer_write_ulong(device, context, queue, num_elements); } -int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_short) { gTestMap = 1; - return test_buffer_write_short(deviceID, context, queue, num_elements); + return test_buffer_write_short(device, context, queue, num_elements); } -int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_ushort) { gTestMap = 1; - return test_buffer_write_ushort(deviceID, context, queue, num_elements); + return test_buffer_write_ushort(device, context, queue, num_elements); } -int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_char) { gTestMap = 1; - return test_buffer_write_char(deviceID, context, queue, num_elements); + return test_buffer_write_char(device, context, queue, num_elements); } -int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_uchar) { gTestMap = 1; - return test_buffer_write_uchar(deviceID, context, queue, num_elements); + return test_buffer_write_uchar(device, context, queue, num_elements); } -int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_float) { gTestMap = 1; - return test_buffer_write_float(deviceID, context, queue, num_elements); + return test_buffer_write_float(device, context, queue, num_elements); } -int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_struct) { gTestMap = 1; - return test_buffer_write_struct(deviceID, context, queue, num_elements); + return test_buffer_write_struct(device, context, queue, num_elements); } -int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_int) { int *inptr[5]; size_t ptrSizes[5]; @@ -1596,8 +1617,9 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c inptr[i][j] = (int)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - buffer_write_int_kernel_code, int_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5, + (void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1609,7 +1631,7 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c } // end test_buffer_int_write_array_async() -int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -1635,8 +1657,10 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = (cl_uint)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - buffer_write_uint_kernel_code, uint_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_uint), (char *)"uint", + 5, (void **)inptr, buffer_write_uint_kernel_code, uint_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1648,7 +1672,7 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_uint_write_array_async() -int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_short) { short *inptr[5]; size_t ptrSizes[5]; @@ -1674,8 +1698,10 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (short)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - buffer_write_short_kernel_code, short_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_short), (char *)"short", + 5, (void **)inptr, buffer_write_short_kernel_code, short_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1688,7 +1714,7 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl } // end test_buffer_short_write_array_async() -int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -1714,8 +1740,10 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c inptr[i][j] = (cl_ushort)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - buffer_write_ushort_kernel_code, ushort_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_ushort), + (char *)"ushort", 5, (void **)inptr, buffer_write_ushort_kernel_code, + ushort_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1728,7 +1756,7 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c } // end test_buffer_ushort_write_array_async() -int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_char) { char *inptr[5]; size_t ptrSizes[5]; @@ -1754,8 +1782,10 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = (char)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - buffer_write_char_kernel_code, char_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_char), (char *)"char", + 5, (void **)inptr, buffer_write_char_kernel_code, char_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1768,7 +1798,7 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_char_write_array_async() -int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_uchar) { uchar *inptr[5]; size_t ptrSizes[5]; @@ -1794,8 +1824,10 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (uchar)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - buffer_write_uchar_kernel_code, uchar_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_uchar), (char *)"uchar", + 5, (void **)inptr, buffer_write_uchar_kernel_code, uchar_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1808,7 +1840,7 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl } // end test_buffer_uchar_write_array_async() -int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1834,8 +1866,10 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - buffer_write_float_kernel_code, float_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_float), (char *)"float", + 5, (void **)inptr, buffer_write_float_kernel_code, float_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1847,7 +1881,7 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl } // end test_buffer_float_write_array_async() -int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1879,8 +1913,10 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = ((cl_long) genrand_int32(d)) ^ ((cl_long) genrand_int32(d) << 32); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr, - buffer_write_long_kernel_code, long_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"cl_long", 5, (void **)inptr, buffer_write_long_kernel_code, + long_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1892,7 +1928,7 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_long_write_array_async() -int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1924,8 +1960,10 @@ int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr, - buffer_write_ulong_kernel_code, ulong_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_ulong), + (char *)"ulong long", 5, (void **)inptr, buffer_write_ulong_kernel_code, + ulong_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); diff --git a/test_conformance/buffers/test_image_migrate.cpp b/test_conformance/buffers/test_image_migrate.cpp index 6c8acdce..2f232b8c 100644 --- a/test_conformance/buffers/test_image_migrate.cpp +++ b/test_conformance/buffers/test_image_migrate.cpp @@ -16,7 +16,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #define MAX_SUB_DEVICES 16 // Limit the sub-devices to ensure no out of resource errors. @@ -113,7 +113,7 @@ static cl_int restoreImage(cl_command_queue *queues, cl_mem *mem_objects, cl_uin return CL_SUCCESS; } -int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(image_migrate) { int failed = 0; cl_uint i, j; @@ -139,15 +139,19 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que const size_t wls[2] = {1, 1}; // Check for image support. - if(checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED) { - log_info("Device does not support images. Skipping test.\n"); - return 0; + if (checkForImageSupport(device) == CL_IMAGE_FORMAT_NOT_SUPPORTED) + { + log_info("Device does not support images. Skipping test.\n"); + return 0; } // Allocate arrays whose size varies according to the maximum number of sub-devices. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(max_sub_devices), &max_sub_devices, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); + return -1; } if (max_sub_devices < 1) { log_error("ERROR: Invalid number of compute units returned.\n"); @@ -188,9 +192,12 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que // Attempt to partition the device along each of the allowed affinity domain. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, + sizeof(domains), &domains, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); + return -1; } domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE | @@ -207,7 +214,9 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que // Determine the number of partitions for the device given the specific domain. if (domain) { property[1] = domain; - err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices); + err = clCreateSubDevices(device, + (const cl_device_partition_property *)property, + -1, NULL, &num_devices); if ((err != CL_SUCCESS) || (num_devices == 0)) { print_error(err, "Obtaining the number of partions by affinity failed."); failed = 1; @@ -219,10 +228,14 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que if (num_devices > 1) { // Create each of the sub-devices and a corresponding context. - if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) { - print_error(err, "Failed creating sub devices."); - failed = 1; - goto cleanup; + if ((err = clCreateSubDevices( + device, (const cl_device_partition_property *)property, + num_devices, devices, &num_devices)) + != CL_SUCCESS) + { + print_error(err, "Failed creating sub devices."); + failed = 1; + goto cleanup; } // Create a context containing all the sub-devices @@ -245,7 +258,7 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que } } else { // No partitioning available. Just exercise the APIs on a single device. - devices[0] = deviceID; + devices[0] = device; queues[0] = queue; ctx = context; } diff --git a/test_conformance/buffers/test_sub_buffers.cpp b/test_conformance/buffers/test_sub_buffers.cpp index 7b0a3ccd..5cf404f8 100644 --- a/test_conformance/buffers/test_sub_buffers.cpp +++ b/test_conformance/buffers/test_sub_buffers.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" +#include "testBase.h" #include #include @@ -232,7 +232,11 @@ size_t find_subbuffer_by_index( SubBufferWrapper * subBuffers, size_t numSubBuff // This tests the read/write capabilities of sub buffers (if we are read/write, the sub buffers // can't overlap) -int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queueA, cl_command_queue queueB, size_t mainSize, size_t addressAlign ) +static int test_sub_buffers_read_write_core(cl_context context, + cl_command_queue queueA, + cl_command_queue queueB, + size_t mainSize, + size_t addressAlign) { clMemWrapper mainBuffer; SubBufferWrapper subBuffers[ 8 ]; @@ -380,18 +384,19 @@ int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queue return numErrors; } -int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_read_write) { cl_int error; size_t mainSize; cl_uint addressAlignBits; // Get the size of the main buffer to use - error = get_reasonable_buffer_size( deviceID, mainSize ); + error = get_reasonable_buffer_size(device, mainSize); test_error( error, "Unable to get reasonable buffer size" ); // Determine the alignment of the device so we can make sure sub buffers are valid - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlignBits ), &addressAlignBits, NULL ); + error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlignBits), &addressAlignBits, NULL); test_error( error, "Unable to get device's address alignment" ); size_t addressAlign = addressAlignBits/8; @@ -402,19 +407,19 @@ int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_c // This test performs the same basic operations as sub_buffers_read_write, but instead of a single // device, it creates a context and buffer shared between two devices, then executes commands // on queues for each device to ensure that everything still operates as expected. -int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_read_write_dual_devices) { cl_int error; // First obtain the second device - cl_device_id otherDevice = GetOpposingDevice( deviceID ); + cl_device_id otherDevice = GetOpposingDevice(device); if ( otherDevice == NULL ) { log_error( "ERROR: Unable to obtain a second device for sub-buffer dual-device test.\n" ); return -1; } - if ( otherDevice == deviceID ) + if (otherDevice == device) { log_info( "Note: Unable to run dual-device sub-buffer test (only one device available). Skipping test (implicitly passing).\n" ); return 0; @@ -433,12 +438,13 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context device_name.data()); // Create a shared context for these two devices - cl_device_id devices[ 2 ] = { deviceID, otherDevice }; + cl_device_id devices[2] = { device, otherDevice }; clContextWrapper testingContext = clCreateContext( NULL, 2, devices, NULL, NULL, &error ); test_error( error, "Unable to create shared context" ); // Create two queues (can't use the existing one, because it's on the wrong context) - clCommandQueueWrapper queue1 = clCreateCommandQueue( testingContext, deviceID, 0, &error ); + clCommandQueueWrapper queue1 = + clCreateCommandQueue(testingContext, device, 0, &error); test_error( error, "Unable to create command queue on main device" ); clCommandQueueWrapper queue2 = clCreateCommandQueue( testingContext, otherDevice, 0, &error ); @@ -446,7 +452,7 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context // Determine the reasonable buffer size and address alignment that applies to BOTH devices size_t maxBuffer1, maxBuffer2; - error = get_reasonable_buffer_size( deviceID, maxBuffer1 ); + error = get_reasonable_buffer_size(device, maxBuffer1); test_error( error, "Unable to get buffer size for main device" ); error = get_reasonable_buffer_size( otherDevice, maxBuffer2 ); @@ -454,7 +460,9 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context maxBuffer1 = std::min(maxBuffer1, maxBuffer2); cl_uint addressAlign1Bits, addressAlign2Bits; - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign1Bits ), &addressAlign1Bits, NULL ); + error = + clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlign1Bits), &addressAlign1Bits, NULL); test_error( error, "Unable to get main device's address alignment" ); error = clGetDeviceInfo( otherDevice, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign2Bits ), &addressAlign2Bits, NULL ); @@ -503,7 +511,7 @@ cl_int read_buffer_via_kernel( cl_context context, cl_command_queue queue, cl_me } -int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_overlapping) { cl_int error; size_t mainSize; @@ -514,14 +522,15 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ // Create the main buffer to test against - error = get_reasonable_buffer_size( deviceID, mainSize ); + error = get_reasonable_buffer_size(device, mainSize); test_error( error, "Unable to get reasonable buffer size" ); mainBuffer = clCreateBuffer( context, CL_MEM_READ_WRITE, mainSize, NULL, &error ); test_error( error, "Unable to create test main buffer" ); // Determine the alignment of the device so we can make sure sub buffers are valid - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign ), &addressAlign, NULL ); + error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlign), &addressAlign, NULL); test_error( error, "Unable to get device's address alignment" ); // Create some sub-buffers to use. Note: they don't have to not overlap (we actually *want* them to overlap) @@ -638,4 +647,3 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ return numErrors; } - From 2d0fda0179649c2b898f8c1f74e498a793cb0459 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:55:24 +0000 Subject: [PATCH 35/36] Migrate c11_atomics suite the new test registration framework (#2318) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/c11_atomics/main.cpp | 82 +---- test_conformance/c11_atomics/test_atomics.cpp | 305 ++++++++---------- 2 files changed, 140 insertions(+), 247 deletions(-) diff --git a/test_conformance/c11_atomics/main.cpp b/test_conformance/c11_atomics/main.cpp index 3132c40d..4b37f745 100644 --- a/test_conformance/c11_atomics/main.cpp +++ b/test_conformance/c11_atomics/main.cpp @@ -29,84 +29,6 @@ int gMaxDeviceThreads = 1024; // maximum number of threads executed on OCL devic cl_device_atomic_capabilities gAtomicMemCap, gAtomicFenceCap; // atomic memory and fence capabilities for this device -extern int test_atomic_init(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_store(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_store_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_exchange(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_compare_exchange_strong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_add(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_sub(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_or(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_orand(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_xor(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_min(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fetch_max(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_flag(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_atomic_fence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_svm_atomic_init(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_store(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_store_load(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_exchange(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_compare_exchange_strong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_add(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_sub(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_or(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_orand(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_xor(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_min(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fetch_max(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_flag(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_svm_atomic_fence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -test_definition test_list[] = { - ADD_TEST( atomic_init ), - ADD_TEST( atomic_store ), - ADD_TEST( atomic_load ), - ADD_TEST( atomic_exchange ), - ADD_TEST( atomic_compare_exchange_weak ), - ADD_TEST( atomic_compare_exchange_strong ), - ADD_TEST( atomic_fetch_add ), - ADD_TEST( atomic_fetch_sub ), - ADD_TEST( atomic_fetch_and ), - ADD_TEST( atomic_fetch_or ), - ADD_TEST( atomic_fetch_orand ), - ADD_TEST( atomic_fetch_xor ), - ADD_TEST( atomic_fetch_xor2 ), - ADD_TEST( atomic_fetch_min ), - ADD_TEST( atomic_fetch_max ), - ADD_TEST( atomic_flag ), - ADD_TEST( atomic_fence ), - - ADD_TEST( svm_atomic_init ), - ADD_TEST( svm_atomic_store ), - ADD_TEST( svm_atomic_load ), - ADD_TEST( svm_atomic_exchange ), - ADD_TEST( svm_atomic_compare_exchange_weak ), - ADD_TEST( svm_atomic_compare_exchange_strong ), - ADD_TEST( svm_atomic_fetch_add ), - ADD_TEST( svm_atomic_fetch_sub ), - ADD_TEST( svm_atomic_fetch_and ), - ADD_TEST( svm_atomic_fetch_or ), - ADD_TEST( svm_atomic_fetch_orand ), - ADD_TEST( svm_atomic_fetch_xor ), - ADD_TEST( svm_atomic_fetch_xor2 ), - ADD_TEST( svm_atomic_fetch_min ), - ADD_TEST( svm_atomic_fetch_max ), - ADD_TEST( svm_atomic_flag ), - ADD_TEST( svm_atomic_fence ), -}; - -const int test_num = ARRAY_SIZE( test_list ); - test_status InitCL(cl_device_id device) { auto version = get_device_cl_version(device); auto expected_min_version = Version(2, 0); @@ -285,5 +207,7 @@ int main(int argc, const char *argv[]) log_info("*** Use of this mode is not sufficient to verify correctness. ***\n"); log_info("*** ***\n"); } - return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, false, InitCL); + return runTestHarnessWithCheck( + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, false, InitCL); } diff --git a/test_conformance/c11_atomics/test_atomics.cpp b/test_conformance/c11_atomics/test_atomics.cpp index 82438a74..95e0c13f 100644 --- a/test_conformance/c11_atomics/test_atomics.cpp +++ b/test_conformance/c11_atomics/test_atomics.cpp @@ -80,9 +80,9 @@ public: } }; -int test_atomic_store_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_store_generic(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + bool useSVM) { int error = 0; CBasicTestStore test_int(TYPE_ATOMIC_INT, @@ -156,17 +156,15 @@ int test_atomic_store_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_store(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_store) { - return test_atomic_store_generic(deviceID, context, queue, num_elements, + return test_atomic_store_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_store(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_store) { - return test_atomic_store_generic(deviceID, context, queue, num_elements, + return test_atomic_store_generic(device, context, queue, num_elements, true); } @@ -202,9 +200,9 @@ public: } }; -int test_atomic_init_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_init_generic(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + bool useSVM) { int error = 0; CBasicTestInit test_int(TYPE_ATOMIC_INT, useSVM); @@ -277,18 +275,15 @@ int test_atomic_init_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_init(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_init) { - return test_atomic_init_generic(deviceID, context, queue, num_elements, + return test_atomic_init_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_init(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_init) { - return test_atomic_init_generic(deviceID, context, queue, num_elements, - true); + return test_atomic_init_generic(device, context, queue, num_elements, true); } template @@ -377,9 +372,9 @@ public: } }; -int test_atomic_load_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_load_generic(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + bool useSVM) { int error = 0; CBasicTestLoad test_int(TYPE_ATOMIC_INT, useSVM); @@ -452,18 +447,15 @@ int test_atomic_load_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_load(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_load) { - return test_atomic_load_generic(deviceID, context, queue, num_elements, + return test_atomic_load_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_load(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_load) { - return test_atomic_load_generic(deviceID, context, queue, num_elements, - true); + return test_atomic_load_generic(device, context, queue, num_elements, true); } template @@ -568,9 +560,10 @@ public: } }; -int test_atomic_exchange_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_exchange_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestExchange test_int(TYPE_ATOMIC_INT, @@ -644,17 +637,15 @@ int test_atomic_exchange_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_exchange(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_exchange) { - return test_atomic_exchange_generic(deviceID, context, queue, num_elements, + return test_atomic_exchange_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_exchange(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_exchange) { - return test_atomic_exchange_generic(deviceID, context, queue, num_elements, + return test_atomic_exchange_generic(device, context, queue, num_elements, true); } @@ -830,10 +821,11 @@ public: } }; -int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements, bool useSVM) +static int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, + bool useSVM) { int error = 0; CBasicTestCompareStrong test_int(TYPE_ATOMIC_INT, @@ -899,21 +891,15 @@ int test_atomic_compare_exchange_strong_generic(cl_device_id deviceID, return error; } -int test_atomic_compare_exchange_strong(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(atomic_compare_exchange_strong) { - return test_atomic_compare_exchange_strong_generic(deviceID, context, queue, + return test_atomic_compare_exchange_strong_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_compare_exchange_strong(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(svm_atomic_compare_exchange_strong) { - return test_atomic_compare_exchange_strong_generic(deviceID, context, queue, + return test_atomic_compare_exchange_strong_generic(device, context, queue, num_elements, true); } @@ -966,10 +952,11 @@ public: } }; -int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements, bool useSVM) +static int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, + bool useSVM) { int error = 0; CBasicTestCompareWeak test_int(TYPE_ATOMIC_INT, @@ -1035,19 +1022,15 @@ int test_atomic_compare_exchange_weak_generic(cl_device_id deviceID, return error; } -int test_atomic_compare_exchange_weak(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_compare_exchange_weak) { - return test_atomic_compare_exchange_weak_generic(deviceID, context, queue, + return test_atomic_compare_exchange_weak_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_compare_exchange_weak(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(svm_atomic_compare_exchange_weak) { - return test_atomic_compare_exchange_weak_generic(deviceID, context, queue, + return test_atomic_compare_exchange_weak_generic(device, context, queue, num_elements, true); } @@ -1111,9 +1094,10 @@ public: } }; -int test_atomic_fetch_add_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_add_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchAdd test_int(TYPE_ATOMIC_INT, @@ -1179,17 +1163,15 @@ int test_atomic_fetch_add_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_add(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_add) { - return test_atomic_fetch_add_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_add_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_add(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_add) { - return test_atomic_fetch_add_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_add_generic(device, context, queue, num_elements, true); } @@ -1238,9 +1220,10 @@ public: } }; -int test_atomic_fetch_sub_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_sub_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchSub test_int(TYPE_ATOMIC_INT, @@ -1306,17 +1289,15 @@ int test_atomic_fetch_sub_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_sub(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_sub) { - return test_atomic_fetch_sub_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_sub_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_sub(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_sub) { - return test_atomic_fetch_sub_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_sub_generic(device, context, queue, num_elements, true); } @@ -1389,9 +1370,10 @@ public: } }; -int test_atomic_fetch_or_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_or_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchOr test_int(TYPE_ATOMIC_INT, @@ -1457,17 +1439,15 @@ int test_atomic_fetch_or_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_or(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_or) { - return test_atomic_fetch_or_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_or_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_or(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_or) { - return test_atomic_fetch_or_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_or_generic(device, context, queue, num_elements, true); } @@ -1524,9 +1504,10 @@ public: } }; -int test_atomic_fetch_xor_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_xor_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchXor test_int(TYPE_ATOMIC_INT, @@ -1592,17 +1573,15 @@ int test_atomic_fetch_xor_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_xor(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_xor) { - return test_atomic_fetch_xor_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_xor_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_xor(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_xor) { - return test_atomic_fetch_xor_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_xor_generic(device, context, queue, num_elements, true); } @@ -1675,9 +1654,10 @@ public: } }; -int test_atomic_fetch_and_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_and_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchAnd test_int(TYPE_ATOMIC_INT, @@ -1743,17 +1723,15 @@ int test_atomic_fetch_and_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_and(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_and) { - return test_atomic_fetch_and_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_and_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_and(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_and) { - return test_atomic_fetch_and_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_and_generic(device, context, queue, num_elements, true); } @@ -1855,9 +1833,10 @@ public: } }; -int test_atomic_fetch_orand_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_orand_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchOrAnd test_int(TYPE_ATOMIC_INT, @@ -1923,18 +1902,16 @@ int test_atomic_fetch_orand_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_orand(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_orand) { - return test_atomic_fetch_orand_generic(deviceID, context, queue, - num_elements, false); + return test_atomic_fetch_orand_generic(device, context, queue, num_elements, + false); } -int test_svm_atomic_fetch_orand(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_orand) { - return test_atomic_fetch_orand_generic(deviceID, context, queue, - num_elements, true); + return test_atomic_fetch_orand_generic(device, context, queue, num_elements, + true); } template @@ -2035,9 +2012,10 @@ public: } }; -int test_atomic_fetch_xor2_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_xor2_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchXor2 test_int(TYPE_ATOMIC_INT, @@ -2103,18 +2081,16 @@ int test_atomic_fetch_xor2_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_xor2) { - return test_atomic_fetch_xor2_generic(deviceID, context, queue, - num_elements, false); + return test_atomic_fetch_xor2_generic(device, context, queue, num_elements, + false); } -int test_svm_atomic_fetch_xor2(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_xor2) { - return test_atomic_fetch_xor2_generic(deviceID, context, queue, - num_elements, true); + return test_atomic_fetch_xor2_generic(device, context, queue, num_elements, + true); } template @@ -2170,9 +2146,10 @@ public: } }; -int test_atomic_fetch_min_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_min_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchMin test_int(TYPE_ATOMIC_INT, @@ -2238,17 +2215,15 @@ int test_atomic_fetch_min_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_min(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_min) { - return test_atomic_fetch_min_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_min_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_min(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_min) { - return test_atomic_fetch_min_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_min_generic(device, context, queue, num_elements, true); } @@ -2305,9 +2280,10 @@ public: } }; -int test_atomic_fetch_max_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fetch_max_generic(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements, bool useSVM) { int error = 0; CBasicTestFetchMax test_int(TYPE_ATOMIC_INT, @@ -2373,17 +2349,15 @@ int test_atomic_fetch_max_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fetch_max(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fetch_max) { - return test_atomic_fetch_max_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_max_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fetch_max(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fetch_max) { - return test_atomic_fetch_max_generic(deviceID, context, queue, num_elements, + return test_atomic_fetch_max_generic(device, context, queue, num_elements, true); } @@ -2597,9 +2571,9 @@ public: } }; -int test_atomic_flag_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_flag_generic(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + bool useSVM) { int error = 0; CBasicTestFlag test_flag(TYPE_ATOMIC_FLAG, @@ -2609,18 +2583,15 @@ int test_atomic_flag_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_flag(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_flag) { - return test_atomic_flag_generic(deviceID, context, queue, num_elements, + return test_atomic_flag_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_flag(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_flag) { - return test_atomic_flag_generic(deviceID, context, queue, num_elements, - true); + return test_atomic_flag_generic(device, context, queue, num_elements, true); } template @@ -3149,9 +3120,9 @@ private: struct TestDefinition _subCase; }; -int test_atomic_fence_generic(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements, - bool useSVM) +static int test_atomic_fence_generic(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + bool useSVM) { int error = 0; CBasicTestFence test_int(TYPE_ATOMIC_INT, @@ -3217,16 +3188,14 @@ int test_atomic_fence_generic(cl_device_id deviceID, cl_context context, return error; } -int test_atomic_fence(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_fence) { - return test_atomic_fence_generic(deviceID, context, queue, num_elements, + return test_atomic_fence_generic(device, context, queue, num_elements, false); } -int test_svm_atomic_fence(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(svm_atomic_fence) { - return test_atomic_fence_generic(deviceID, context, queue, num_elements, + return test_atomic_fence_generic(device, context, queue, num_elements, true); } From 30f9a5eb21304615a09b4a5e691bd0f26650c099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 11 Mar 2025 05:16:21 +0000 Subject: [PATCH 36/36] Remove .gitattributes (#2310) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't use git lfs. We have no .7z files in the repo. Signed-off-by: Kévin Petit --- .gitattributes | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 5299c47e..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.7z filter=lfs diff=lfs merge=lfs -text