Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate commonfns suite to new test registration framework #2197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions test_conformance/commonfns/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <stdio.h>
#include <string.h>
#include "procs.h"
#include "test_base.h"
#include "harness/kernelHelpers.h"

Expand All @@ -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)
{
if (is_extension_available(device, "cl_khr_fp16"))
Expand Down Expand Up @@ -79,6 +67,7 @@ int main(int argc, const char *argv[])
BaseFunctionTest::type2name[sizeof(float)] = "float";
BaseFunctionTest::type2name[sizeof(double)] = "double";

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);
}
49 changes: 0 additions & 49 deletions test_conformance/commonfns/procs.h

This file was deleted.

8 changes: 8 additions & 0 deletions test_conformance/commonfns/test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
#include <CL/cl_half.h>
#include <CL/cl_ext.h>

#include "harness/conversions.h"
#include "harness/mt19937.h"
#include "harness/testHarness.h"
#include "harness/typeWrappers.h"

#define kVectorSizeCount 5
#define kStrangeVectorSizeCount 1
#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount)

extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];

template <typename T>
using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const,
const int num, const int vs, const int vp);
Expand Down
41 changes: 16 additions & 25 deletions test_conformance/commonfns/test_binary_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "harness/typeWrappers.h"
#include "harness/stringHelpers.h"

#include "procs.h"
#include "test_base.h"

const char *binary_fn_code_pattern =
Expand Down Expand Up @@ -319,58 +318,50 @@ cl_int MinTest::Run()
return error;
}

int test_min(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(min)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
true);
}

int test_minf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(minf)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
false);
}

int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmin)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
true);
}

int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fminf)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
false);
}

int test_max(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(max)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
true);
}

int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(maxf)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
false);
}

int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmax)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
true);
}

int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmaxf)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
false);
}
6 changes: 2 additions & 4 deletions test_conformance/commonfns/test_clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "harness/deviceInfo.h"
#include "harness/typeWrappers.h"

#include "procs.h"
#include "test_base.h"

#ifndef M_PI
Expand Down Expand Up @@ -308,8 +307,7 @@ cl_int ClampTest::Run()
return error;
}

int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(clamp)
{
return MakeAndRunTest<ClampTest>(device, context, queue, n_elems);
return MakeAndRunTest<ClampTest>(device, context, queue, num_elements);
}
11 changes: 4 additions & 7 deletions test_conformance/commonfns/test_mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "harness/stringHelpers.h"

#include "procs.h"
#include "test_base.h"


Expand Down Expand Up @@ -302,16 +301,14 @@ cl_int MixTest::Run()
return error;
}

int test_mix(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(mix)
{
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix",
return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
true);
}

int test_mixf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(mixf)
{
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix",
return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
false);
}
11 changes: 4 additions & 7 deletions test_conformance/commonfns/test_smoothstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "harness/stringHelpers.h"

#include "procs.h"
#include "test_base.h"

const char *smoothstep_fn_code_pattern =
Expand Down Expand Up @@ -317,16 +316,14 @@ cl_int SmoothstepTest::Run()
return error;
}

int test_smoothstep(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(smoothstep)
{
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems,
return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", true);
}

int test_smoothstepf(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(smoothstepf)
{
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems,
return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", false);
}
15 changes: 6 additions & 9 deletions test_conformance/commonfns/test_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "harness/stringHelpers.h"

#include "procs.h"
#include "test_base.h"

const char *step_fn_code_pattern = "%s\n" /* optional pragma */
Expand Down Expand Up @@ -268,16 +267,14 @@ cl_int StepTest::Run()
return error;
}

int test_step(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(step)
{
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step",
true);
return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
"step", true);
}

int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(stepf)
{
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step",
false);
return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
"step", false);
}
17 changes: 7 additions & 10 deletions test_conformance/commonfns/test_unary_fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "harness/stringHelpers.h"
#include "harness/typeWrappers.h"

#include "procs.h"
#include "test_base.h"

#ifndef M_PI
Expand Down Expand Up @@ -385,22 +384,20 @@ cl_int SignTest::Run()
return error;
}

int test_degrees(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(degrees)
{
return MakeAndRunTest<DegreesTest>(device, context, queue, n_elems,
return MakeAndRunTest<DegreesTest>(device, context, queue, num_elements,
"degrees");
}

int test_radians(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(radians)
{
return MakeAndRunTest<RadiansTest>(device, context, queue, n_elems,
return MakeAndRunTest<RadiansTest>(device, context, queue, num_elements,
"radians");
}

int test_sign(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(sign)
{
return MakeAndRunTest<SignTest>(device, context, queue, n_elems, "sign");
return MakeAndRunTest<SignTest>(device, context, queue, num_elements,
"sign");
}
Loading