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] 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 ); } -