From 641ffeaa672bea66e785eddf6d9ad2ffde45f34e Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:00:23 +0000 Subject: [PATCH] Migrate half suite to the new test registration framework (#2329) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/half/Test_roundTrip.cpp | 4 +- test_conformance/half/Test_vLoadHalf.cpp | 11 +---- test_conformance/half/Test_vStoreHalf.cpp | 58 ++++++++++------------- test_conformance/half/main.cpp | 26 ++-------- 4 files changed, 32 insertions(+), 67 deletions(-) diff --git a/test_conformance/half/Test_roundTrip.cpp b/test_conformance/half/Test_roundTrip.cpp index 66c9ee0f..756e41e4 100644 --- a/test_conformance/half/Test_roundTrip.cpp +++ b/test_conformance/half/Test_roundTrip.cpp @@ -22,7 +22,7 @@ #include "tests.h" #include "harness/testHarness.h" -int test_roundTrip( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(roundTrip) { int vectorSize, error; uint64_t i, j; @@ -400,5 +400,3 @@ exit: return error; } - - diff --git a/test_conformance/half/Test_vLoadHalf.cpp b/test_conformance/half/Test_vLoadHalf.cpp index ea28045e..a4d5a6fa 100644 --- a/test_conformance/half/Test_vLoadHalf.cpp +++ b/test_conformance/half/Test_vLoadHalf.cpp @@ -604,13 +604,6 @@ exit: return error; } -int test_vload_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) -{ - return Test_vLoadHalf_private( device, false ); -} - -int test_vloada_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) -{ - return Test_vLoadHalf_private( device, true ); -} +REGISTER_TEST(vload_half) { return Test_vLoadHalf_private(device, false); } +REGISTER_TEST(vloada_half) { return Test_vLoadHalf_private(device, true); } diff --git a/test_conformance/half/Test_vStoreHalf.cpp b/test_conformance/half/Test_vStoreHalf.cpp index cf914a9a..ab7fe257 100644 --- a/test_conformance/half/Test_vStoreHalf.cpp +++ b/test_conformance/half/Test_vStoreHalf.cpp @@ -247,89 +247,79 @@ static cl_half double2half_rtn(double f) return cl_half_from_double(f, CL_HALF_RTN); } -int test_vstore_half(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstore_half) { - switch (get_default_rounding_mode(deviceID)) + switch (get_default_rounding_mode(device)) { case CL_FP_ROUND_TO_ZERO: - return Test_vStoreHalf_private(deviceID, float2half_rtz, + return Test_vStoreHalf_private(device, float2half_rtz, double2half_rte, ""); case 0: return -1; default: - return Test_vStoreHalf_private(deviceID, float2half_rte, + return Test_vStoreHalf_private(device, float2half_rte, double2half_rte, ""); } } -int test_vstore_half_rte(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstore_half_rte) { - return Test_vStoreHalf_private(deviceID, float2half_rte, double2half_rte, + return Test_vStoreHalf_private(device, float2half_rte, double2half_rte, "_rte"); } -int test_vstore_half_rtz(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstore_half_rtz) { - return Test_vStoreHalf_private(deviceID, float2half_rtz, double2half_rtz, + return Test_vStoreHalf_private(device, float2half_rtz, double2half_rtz, "_rtz"); } -int test_vstore_half_rtp(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstore_half_rtp) { - return Test_vStoreHalf_private(deviceID, float2half_rtp, double2half_rtp, + return Test_vStoreHalf_private(device, float2half_rtp, double2half_rtp, "_rtp"); } -int test_vstore_half_rtn(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstore_half_rtn) { - return Test_vStoreHalf_private(deviceID, float2half_rtn, double2half_rtn, + return Test_vStoreHalf_private(device, float2half_rtn, double2half_rtn, "_rtn"); } -int test_vstorea_half(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstorea_half) { - switch (get_default_rounding_mode(deviceID)) + switch (get_default_rounding_mode(device)) { case CL_FP_ROUND_TO_ZERO: - return Test_vStoreaHalf_private(deviceID, float2half_rtz, + return Test_vStoreaHalf_private(device, float2half_rtz, double2half_rte, ""); case 0: return -1; default: - return Test_vStoreaHalf_private(deviceID, float2half_rte, + return Test_vStoreaHalf_private(device, float2half_rte, double2half_rte, ""); } } -int test_vstorea_half_rte(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstorea_half_rte) { - return Test_vStoreaHalf_private(deviceID, float2half_rte, double2half_rte, + return Test_vStoreaHalf_private(device, float2half_rte, double2half_rte, "_rte"); } -int test_vstorea_half_rtz(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstorea_half_rtz) { - return Test_vStoreaHalf_private(deviceID, float2half_rtz, double2half_rtz, + return Test_vStoreaHalf_private(device, float2half_rtz, double2half_rtz, "_rtz"); } -int test_vstorea_half_rtp(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstorea_half_rtp) { - return Test_vStoreaHalf_private(deviceID, float2half_rtp, double2half_rtp, + return Test_vStoreaHalf_private(device, float2half_rtp, double2half_rtp, "_rtp"); } -int test_vstorea_half_rtn(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vstorea_half_rtn) { - return Test_vStoreaHalf_private(deviceID, float2half_rtn, double2half_rtn, + return Test_vStoreaHalf_private(device, float2half_rtn, double2half_rtn, "_rtn"); } diff --git a/test_conformance/half/main.cpp b/test_conformance/half/main.cpp index 82b2d769..743bc45c 100644 --- a/test_conformance/half/main.cpp +++ b/test_conformance/half/main.cpp @@ -53,24 +53,6 @@ int g_arrVecSizes[kVectorSizeCount+kStrangeVectorSizeCount]; int g_arrVecAligns[kLargestVectorSize+1]; static int arrStrangeVecSizes[kStrangeVectorSizeCount] = {3}; -test_definition test_list[] = { - ADD_TEST( vload_half ), - ADD_TEST( vloada_half ), - ADD_TEST( vstore_half ), - ADD_TEST( vstorea_half ), - ADD_TEST( vstore_half_rte ), - ADD_TEST( vstorea_half_rte ), - ADD_TEST( vstore_half_rtz ), - ADD_TEST( vstorea_half_rtz ), - ADD_TEST( vstore_half_rtp ), - ADD_TEST( vstorea_half_rtp ), - ADD_TEST( vstore_half_rtn ), - ADD_TEST( vstorea_half_rtn ), - ADD_TEST( roundTrip ), -}; - -const int test_num = ARRAY_SIZE( test_list ); - int main (int argc, const char **argv ) { int error; @@ -109,7 +91,9 @@ int main (int argc, const char **argv ) } fflush( stdout ); - error = runTestHarnessWithCheck( argCount, argList, test_num, test_list, true, 0, InitCL ); + error = runTestHarnessWithCheck( + argCount, argList, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), true, 0, InitCL); exit: if(gQueue) @@ -248,8 +232,8 @@ static void PrintUsage( void ) "1-12, default factor(%u)\n", gWimpyReductionFactor); vlog("\t\t-h\tHelp\n"); - for (int i = 0; i < test_num; i++) + for (size_t i = 0; i < test_registry::getInstance().num_tests(); i++) { - vlog("\t\t%s\n", test_list[i].name ); + vlog("\t\t%s\n", test_registry::getInstance().definitions()[i].name); } }