Migrate commonfns suite to new test registration framework (#2197)

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kévin Petit
2025-01-14 17:11:31 +00:00
committed by GitHub
parent a2d6cadec1
commit f6611ec912
9 changed files with 50 additions and 125 deletions

View File

@@ -16,7 +16,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "procs.h"
#include "test_base.h" #include "test_base.h"
#include "harness/kernelHelpers.h" #include "harness/kernelHelpers.h"
@@ -36,17 +35,6 @@ static void initVecSizes() {
} }
} }
test_definition test_list[] = {
ADD_TEST(clamp), ADD_TEST(degrees), ADD_TEST(fmax),
ADD_TEST(fmaxf), ADD_TEST(fmin), ADD_TEST(fminf),
ADD_TEST(max), ADD_TEST(maxf), ADD_TEST(min),
ADD_TEST(minf), ADD_TEST(mix), ADD_TEST(mixf),
ADD_TEST(radians), ADD_TEST(step), ADD_TEST(stepf),
ADD_TEST(smoothstep), ADD_TEST(smoothstepf), ADD_TEST(sign),
};
const int test_num = ARRAY_SIZE( test_list );
test_status InitCL(cl_device_id device) test_status InitCL(cl_device_id device)
{ {
if (is_extension_available(device, "cl_khr_fp16")) if (is_extension_available(device, "cl_khr_fp16"))
@@ -79,6 +67,7 @@ int main(int argc, const char *argv[])
BaseFunctionTest::type2name[sizeof(float)] = "float"; BaseFunctionTest::type2name[sizeof(float)] = "float";
BaseFunctionTest::type2name[sizeof(double)] = "double"; BaseFunctionTest::type2name[sizeof(double)] = "double";
return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, return runTestHarnessWithCheck(
InitCL); argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0, InitCL);
} }

View File

@@ -1,49 +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/testHarness.h"
#include "harness/kernelHelpers.h"
#include "harness/errorHelpers.h"
#include "harness/conversions.h"
#include "harness/mt19937.h"
#define kVectorSizeCount 5
#define kStrangeVectorSizeCount 1
#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount)
extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];
// int g_arrStrangeVectorSizes[kStrangeVectorSizeCount] = {3};
extern int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_degrees(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_max(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_minf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_mix(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_mixf(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_radians(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_step(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_smoothstep(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_smoothstepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_sign(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);

View File

@@ -24,9 +24,17 @@
#include <CL/cl_half.h> #include <CL/cl_half.h>
#include <CL/cl_ext.h> #include <CL/cl_ext.h>
#include "harness/conversions.h"
#include "harness/mt19937.h"
#include "harness/testHarness.h" #include "harness/testHarness.h"
#include "harness/typeWrappers.h" #include "harness/typeWrappers.h"
#define kVectorSizeCount 5
#define kStrangeVectorSizeCount 1
#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount)
extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];
template <typename T> template <typename T>
using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const, using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const,
const int num, const int vs, const int vp); const int num, const int vs, const int vp);

View File

@@ -24,7 +24,6 @@
#include "harness/typeWrappers.h" #include "harness/typeWrappers.h"
#include "harness/stringHelpers.h" #include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
const char *binary_fn_code_pattern = const char *binary_fn_code_pattern =
@@ -319,58 +318,50 @@ cl_int MinTest::Run()
return error; return error;
} }
int test_min(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(min)
int n_elems)
{ {
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min", return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
true); true);
} }
int test_minf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(minf)
int n_elems)
{ {
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min", return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
false); false);
} }
int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(fmin)
int n_elems)
{ {
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin", return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
true); true);
} }
int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(fminf)
int n_elems)
{ {
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin", return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
false); false);
} }
int test_max(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(max)
int n_elems)
{ {
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max", return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
true); true);
} }
int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(maxf)
int n_elems)
{ {
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max", return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
false); false);
} }
int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(fmax)
int n_elems)
{ {
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax", return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
true); true);
} }
int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(fmaxf)
int n_elems)
{ {
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax", return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
false); false);
} }

View File

@@ -23,7 +23,6 @@
#include "harness/deviceInfo.h" #include "harness/deviceInfo.h"
#include "harness/typeWrappers.h" #include "harness/typeWrappers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
#ifndef M_PI #ifndef M_PI
@@ -308,8 +307,7 @@ cl_int ClampTest::Run()
return error; return error;
} }
int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(clamp)
int n_elems)
{ {
return MakeAndRunTest<ClampTest>(device, context, queue, n_elems); return MakeAndRunTest<ClampTest>(device, context, queue, num_elements);
} }

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h" #include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
@@ -302,16 +301,14 @@ cl_int MixTest::Run()
return error; return error;
} }
int test_mix(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(mix)
int n_elems)
{ {
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix", return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
true); true);
} }
int test_mixf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(mixf)
int n_elems)
{ {
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix", return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
false); false);
} }

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h" #include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
const char *smoothstep_fn_code_pattern = const char *smoothstep_fn_code_pattern =
@@ -317,16 +316,14 @@ cl_int SmoothstepTest::Run()
return error; return error;
} }
int test_smoothstep(cl_device_id device, cl_context context, REGISTER_TEST(smoothstep)
cl_command_queue queue, int n_elems)
{ {
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems, return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", true); "smoothstep", true);
} }
int test_smoothstepf(cl_device_id device, cl_context context, REGISTER_TEST(smoothstepf)
cl_command_queue queue, int n_elems)
{ {
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems, return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", false); "smoothstep", false);
} }

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h" #include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
const char *step_fn_code_pattern = "%s\n" /* optional pragma */ const char *step_fn_code_pattern = "%s\n" /* optional pragma */
@@ -268,16 +267,14 @@ cl_int StepTest::Run()
return error; return error;
} }
int test_step(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(step)
int n_elems)
{ {
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step", return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
true); "step", true);
} }
int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(stepf)
int n_elems)
{ {
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step", return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
false); "step", false);
} }

View File

@@ -24,7 +24,6 @@
#include "harness/stringHelpers.h" #include "harness/stringHelpers.h"
#include "harness/typeWrappers.h" #include "harness/typeWrappers.h"
#include "procs.h"
#include "test_base.h" #include "test_base.h"
#ifndef M_PI #ifndef M_PI
@@ -385,22 +384,20 @@ cl_int SignTest::Run()
return error; return error;
} }
int test_degrees(cl_device_id device, cl_context context, REGISTER_TEST(degrees)
cl_command_queue queue, int n_elems)
{ {
return MakeAndRunTest<DegreesTest>(device, context, queue, n_elems, return MakeAndRunTest<DegreesTest>(device, context, queue, num_elements,
"degrees"); "degrees");
} }
int test_radians(cl_device_id device, cl_context context, REGISTER_TEST(radians)
cl_command_queue queue, int n_elems)
{ {
return MakeAndRunTest<RadiansTest>(device, context, queue, n_elems, return MakeAndRunTest<RadiansTest>(device, context, queue, num_elements,
"radians"); "radians");
} }
int test_sign(cl_device_id device, cl_context context, cl_command_queue queue, REGISTER_TEST(sign)
int n_elems)
{ {
return MakeAndRunTest<SignTest>(device, context, queue, n_elems, "sign"); return MakeAndRunTest<SignTest>(device, context, queue, num_elements,
"sign");
} }