diff --git a/test_conformance/commonfns/main.cpp b/test_conformance/commonfns/main.cpp index 645d3f703c..8b16bf96b1 100644 --- a/test_conformance/commonfns/main.cpp +++ b/test_conformance/commonfns/main.cpp @@ -16,7 +16,6 @@ #include #include -#include "procs.h" #include "test_base.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) { 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(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); } diff --git a/test_conformance/commonfns/procs.h b/test_conformance/commonfns/procs.h deleted file mode 100644 index c1115ee7cd..0000000000 --- a/test_conformance/commonfns/procs.h +++ /dev/null @@ -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); - - diff --git a/test_conformance/commonfns/test_base.h b/test_conformance/commonfns/test_base.h index c7286a92f5..bcce3ba408 100644 --- a/test_conformance/commonfns/test_base.h +++ b/test_conformance/commonfns/test_base.h @@ -24,9 +24,17 @@ #include #include +#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 using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const, const int num, const int vs, const int vp); diff --git a/test_conformance/commonfns/test_binary_fn.cpp b/test_conformance/commonfns/test_binary_fn.cpp index a6c75647d0..8ad347aafb 100644 --- a/test_conformance/commonfns/test_binary_fn.cpp +++ b/test_conformance/commonfns/test_binary_fn.cpp @@ -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 = @@ -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(device, context, queue, n_elems, "min", + return MakeAndRunTest(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(device, context, queue, n_elems, "min", + return MakeAndRunTest(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(device, context, queue, n_elems, "fmin", + return MakeAndRunTest(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(device, context, queue, n_elems, "fmin", + return MakeAndRunTest(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(device, context, queue, n_elems, "max", + return MakeAndRunTest(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(device, context, queue, n_elems, "max", + return MakeAndRunTest(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(device, context, queue, n_elems, "fmax", + return MakeAndRunTest(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(device, context, queue, n_elems, "fmax", + return MakeAndRunTest(device, context, queue, num_elements, "fmax", false); } diff --git a/test_conformance/commonfns/test_clamp.cpp b/test_conformance/commonfns/test_clamp.cpp index 1bf4067705..298811e245 100644 --- a/test_conformance/commonfns/test_clamp.cpp +++ b/test_conformance/commonfns/test_clamp.cpp @@ -23,7 +23,6 @@ #include "harness/deviceInfo.h" #include "harness/typeWrappers.h" -#include "procs.h" #include "test_base.h" #ifndef M_PI @@ -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(device, context, queue, n_elems); + return MakeAndRunTest(device, context, queue, num_elements); } diff --git a/test_conformance/commonfns/test_mix.cpp b/test_conformance/commonfns/test_mix.cpp index 2a06e43df6..ae543d0d89 100644 --- a/test_conformance/commonfns/test_mix.cpp +++ b/test_conformance/commonfns/test_mix.cpp @@ -20,7 +20,6 @@ #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" @@ -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(device, context, queue, n_elems, "mix", + return MakeAndRunTest(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(device, context, queue, n_elems, "mix", + return MakeAndRunTest(device, context, queue, num_elements, "mix", false); } diff --git a/test_conformance/commonfns/test_smoothstep.cpp b/test_conformance/commonfns/test_smoothstep.cpp index 5afc2d0f22..6aaa800dfb 100644 --- a/test_conformance/commonfns/test_smoothstep.cpp +++ b/test_conformance/commonfns/test_smoothstep.cpp @@ -20,7 +20,6 @@ #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" const char *smoothstep_fn_code_pattern = @@ -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(device, context, queue, n_elems, + return MakeAndRunTest(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(device, context, queue, n_elems, + return MakeAndRunTest(device, context, queue, num_elements, "smoothstep", false); } diff --git a/test_conformance/commonfns/test_step.cpp b/test_conformance/commonfns/test_step.cpp index 1cfa96eabd..e3a6fdf695 100644 --- a/test_conformance/commonfns/test_step.cpp +++ b/test_conformance/commonfns/test_step.cpp @@ -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 */ @@ -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(device, context, queue, n_elems, "step", - true); + return MakeAndRunTest(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(device, context, queue, n_elems, "step", - false); + return MakeAndRunTest(device, context, queue, num_elements, + "step", false); } diff --git a/test_conformance/commonfns/test_unary_fn.cpp b/test_conformance/commonfns/test_unary_fn.cpp index 91b5c215bf..23b665a45f 100644 --- a/test_conformance/commonfns/test_unary_fn.cpp +++ b/test_conformance/commonfns/test_unary_fn.cpp @@ -24,7 +24,6 @@ #include "harness/stringHelpers.h" #include "harness/typeWrappers.h" -#include "procs.h" #include "test_base.h" #ifndef M_PI @@ -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(device, context, queue, n_elems, + return MakeAndRunTest(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(device, context, queue, n_elems, + return MakeAndRunTest(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(device, context, queue, n_elems, "sign"); + return MakeAndRunTest(device, context, queue, num_elements, + "sign"); }