mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
[RFC] Move logic for test registration to the test harness (#2151)
And use in device_timer suite. Signed-off-by: Kévin Petit <kpet@free.fr>
This commit is contained in:
@@ -62,6 +62,27 @@ bool gCoreILProgram = true;
|
||||
|
||||
#define DEFAULT_NUM_ELEMENTS 0x4000
|
||||
|
||||
test_definition *test_registry::definitions() { return &m_definitions[0]; }
|
||||
|
||||
size_t test_registry::num_tests() { return m_definitions.size(); }
|
||||
|
||||
void test_registry::add_test(test *t, const char *name, Version version)
|
||||
{
|
||||
|
||||
m_tests.push_back(t);
|
||||
test_definition testDef;
|
||||
testDef.func = t->getFunction();
|
||||
testDef.name = name;
|
||||
testDef.min_version = version;
|
||||
m_definitions.push_back(testDef);
|
||||
}
|
||||
|
||||
test_registry &test_registry::getInstance()
|
||||
{
|
||||
static test_registry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static int saveResultsToJson(const char *suiteName, test_definition testList[],
|
||||
unsigned char selectedTestList[],
|
||||
test_status resultTestList[], int testNum)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Version {
|
||||
public:
|
||||
@@ -99,6 +100,53 @@ struct test_harness_config
|
||||
unsigned numWorkerThreads;
|
||||
};
|
||||
|
||||
|
||||
struct test
|
||||
{
|
||||
virtual test_function_pointer getFunction() = 0;
|
||||
};
|
||||
|
||||
class test_registry {
|
||||
private:
|
||||
std::vector<test *> m_tests;
|
||||
std::vector<test_definition> m_definitions;
|
||||
|
||||
public:
|
||||
static test_registry &getInstance();
|
||||
|
||||
test_definition *definitions();
|
||||
|
||||
size_t num_tests();
|
||||
|
||||
void add_test(test *t, const char *name, Version version);
|
||||
test_registry() {}
|
||||
};
|
||||
|
||||
template <typename T> T *register_test(const char *name, Version version)
|
||||
{
|
||||
T *t = new T();
|
||||
test_registry::getInstance().add_test((test *)t, name, version);
|
||||
return t;
|
||||
}
|
||||
|
||||
#define REGISTER_TEST_VERSION(name, version) \
|
||||
extern int test_##name(cl_device_id deviceID, cl_context context, \
|
||||
cl_command_queue queue, int num_elements); \
|
||||
class test_##name##_class : public test { \
|
||||
private: \
|
||||
test_function_pointer fn; \
|
||||
\
|
||||
public: \
|
||||
test_##name##_class(): fn(test_##name) {} \
|
||||
test_function_pointer getFunction() { return fn; } \
|
||||
}; \
|
||||
test_##name##_class *var_##name = \
|
||||
register_test<test_##name##_class>(#name, version); \
|
||||
int test_##name(cl_device_id deviceID, cl_context context, \
|
||||
cl_command_queue queue, int num_elements)
|
||||
|
||||
#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
|
||||
|
||||
extern int gFailCount;
|
||||
extern int gTestCount;
|
||||
extern cl_uint gReSeed;
|
||||
|
||||
@@ -23,13 +23,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "procs.h"
|
||||
|
||||
test_definition test_list[] = {
|
||||
ADD_TEST( timer_resolution_queries ),
|
||||
ADD_TEST( device_and_host_timers ),
|
||||
};
|
||||
|
||||
test_status InitCL(cl_device_id device)
|
||||
{
|
||||
auto version = get_device_cl_version(device);
|
||||
@@ -70,11 +63,10 @@ test_status InitCL(cl_device_id device)
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
|
||||
const int test_num = ARRAY_SIZE( test_list );
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +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.
|
||||
//
|
||||
#ifndef __PROCS_H__
|
||||
#define __PROCS_H__
|
||||
|
||||
extern int test_device_and_host_timers(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
|
||||
extern int test_timer_resolution_queries(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements);
|
||||
#endif // #ifndef __PROCS_H__
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <CL/cl.h>
|
||||
#include "harness/errorHelpers.h"
|
||||
#include "harness/compat.h"
|
||||
#include "harness/testHarness.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include "unistd.h" // For "sleep"
|
||||
@@ -24,7 +25,7 @@
|
||||
|
||||
#define ALLOWED_ERROR 0.005f
|
||||
|
||||
int test_device_and_host_timers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(device_and_host_timers)
|
||||
{
|
||||
int errors = 0;
|
||||
cl_int result = CL_SUCCESS;
|
||||
@@ -124,7 +125,7 @@ End:
|
||||
return errors;
|
||||
}
|
||||
|
||||
int test_timer_resolution_queries(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(timer_resolution_queries)
|
||||
{
|
||||
int errors = 0;
|
||||
cl_int result = CL_SUCCESS;
|
||||
|
||||
@@ -69,34 +69,6 @@ std::vector<unsigned char> readSPIRV(const char *file_name)
|
||||
return readBinary(full_name_str.c_str());
|
||||
}
|
||||
|
||||
test_definition *spirvTestsRegistry::getTestDefinitions()
|
||||
{
|
||||
return &testDefinitions[0];
|
||||
}
|
||||
|
||||
size_t spirvTestsRegistry::getNumTests()
|
||||
{
|
||||
return testDefinitions.size();
|
||||
}
|
||||
|
||||
void spirvTestsRegistry::addTestClass(baseTestClass *test, const char *testName,
|
||||
Version version)
|
||||
{
|
||||
|
||||
testClasses.push_back(test);
|
||||
test_definition testDef;
|
||||
testDef.func = test->getFunction();
|
||||
testDef.name = testName;
|
||||
testDef.min_version = version;
|
||||
testDefinitions.push_back(testDef);
|
||||
}
|
||||
|
||||
spirvTestsRegistry& spirvTestsRegistry::getInstance()
|
||||
{
|
||||
static spirvTestsRegistry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static int offline_get_program_with_il(clProgramWrapper &prog,
|
||||
const cl_device_id deviceID,
|
||||
const cl_context context,
|
||||
@@ -270,7 +242,6 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
return runTestHarnessWithCheck(
|
||||
argc, argv, spirvTestsRegistry::getInstance().getNumTests(),
|
||||
spirvTestsRegistry::getInstance().getTestDefinitions(), false, 0,
|
||||
InitCL);
|
||||
argc, argv, test_registry::getInstance().num_tests(),
|
||||
test_registry::getInstance().definitions(), false, 0, InitCL);
|
||||
}
|
||||
|
||||
@@ -36,56 +36,6 @@
|
||||
return -1; \
|
||||
} while (0)
|
||||
|
||||
|
||||
class baseTestClass {
|
||||
public:
|
||||
baseTestClass() {}
|
||||
virtual test_function_pointer getFunction() = 0;
|
||||
};
|
||||
|
||||
class spirvTestsRegistry {
|
||||
private:
|
||||
std::vector<baseTestClass *> testClasses;
|
||||
std::vector<test_definition> testDefinitions;
|
||||
|
||||
public:
|
||||
static spirvTestsRegistry &getInstance();
|
||||
|
||||
test_definition *getTestDefinitions();
|
||||
|
||||
size_t getNumTests();
|
||||
|
||||
void addTestClass(baseTestClass *test, const char *testName,
|
||||
Version version);
|
||||
spirvTestsRegistry() {}
|
||||
};
|
||||
|
||||
template <typename T> T *createAndRegister(const char *name, Version version)
|
||||
{
|
||||
T *testClass = new T();
|
||||
spirvTestsRegistry::getInstance().addTestClass((baseTestClass *)testClass,
|
||||
name, version);
|
||||
return testClass;
|
||||
}
|
||||
|
||||
#define TEST_SPIRV_FUNC_VERSION(name, version) \
|
||||
extern int test_##name(cl_device_id deviceID, cl_context context, \
|
||||
cl_command_queue queue, int num_elements); \
|
||||
class test_##name##_class : public baseTestClass { \
|
||||
private: \
|
||||
test_function_pointer fn; \
|
||||
\
|
||||
public: \
|
||||
test_##name##_class(): fn(test_##name) {} \
|
||||
test_function_pointer getFunction() { return fn; } \
|
||||
}; \
|
||||
test_##name##_class *var_##name = \
|
||||
createAndRegister<test_##name##_class>(#name, version); \
|
||||
int test_##name(cl_device_id deviceID, cl_context context, \
|
||||
cl_command_queue queue, int num_elements)
|
||||
|
||||
#define TEST_SPIRV_FUNC(name) TEST_SPIRV_FUNC_VERSION(name, Version(1, 2))
|
||||
|
||||
struct spec_const
|
||||
{
|
||||
spec_const(cl_int id = 0, size_t sizet = 0, const void *value = NULL)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
extern bool gVersionSkip;
|
||||
|
||||
TEST_SPIRV_FUNC(basic_versions)
|
||||
REGISTER_TEST(basic_versions)
|
||||
{
|
||||
cl_int error = CL_SUCCESS;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ static int test_expect_type(cl_device_id device, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_expect)
|
||||
REGISTER_TEST(op_expect)
|
||||
{
|
||||
if (!is_extension_available(deviceID, "cl_khr_expect_assume"))
|
||||
{
|
||||
@@ -139,7 +139,7 @@ TEST_SPIRV_FUNC(op_expect)
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_assume)
|
||||
REGISTER_TEST(op_assume)
|
||||
{
|
||||
if (!is_extension_available(deviceID, "cl_khr_expect_assume"))
|
||||
{
|
||||
|
||||
@@ -110,29 +110,29 @@ int test_decorate_full(cl_device_id deviceID,
|
||||
return verify_results(deviceID, context, queue, name, prog);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(decorate_restrict)
|
||||
REGISTER_TEST(decorate_restrict)
|
||||
{
|
||||
return test_decorate_full(deviceID, context, queue, "decorate_restrict");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(decorate_aliased)
|
||||
REGISTER_TEST(decorate_aliased)
|
||||
{
|
||||
return test_decorate_full(deviceID, context, queue, "decorate_aliased");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(decorate_alignment)
|
||||
REGISTER_TEST(decorate_alignment)
|
||||
{
|
||||
//TODO: Check for results ? How to ensure buffers are aligned
|
||||
clProgramWrapper prog;
|
||||
return get_program_with_il(prog, deviceID, context, "decorate_alignment");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(decorate_constant)
|
||||
REGISTER_TEST(decorate_constant)
|
||||
{
|
||||
return test_decorate_full(deviceID, context, queue, "decorate_constant");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(decorate_cpacked)
|
||||
REGISTER_TEST(decorate_cpacked)
|
||||
{
|
||||
PACKED(struct packed_struct_t {
|
||||
cl_int ival;
|
||||
@@ -382,7 +382,7 @@ int test_saturate_full(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
#define TEST_SATURATED_CONVERSION(Ti, Tl, To) \
|
||||
TEST_SPIRV_FUNC(decorate_saturated_conversion_##Ti##_to_##To) \
|
||||
REGISTER_TEST(decorate_saturated_conversion_##Ti##_to_##To) \
|
||||
{ \
|
||||
typedef cl_##Ti cl_Ti; \
|
||||
typedef cl_##Tl cl_Tl; \
|
||||
@@ -532,7 +532,7 @@ static inline Ti generate_fprounding_input(RandomSeed &seed)
|
||||
}
|
||||
|
||||
#define TEST_SPIRV_FP_ROUNDING_DECORATE(name, func, Ti, To) \
|
||||
TEST_SPIRV_FUNC(decorate_fp_rounding_mode_##name##_##Ti##_##To) \
|
||||
REGISTER_TEST(decorate_fp_rounding_mode_##name##_##Ti##_##To) \
|
||||
{ \
|
||||
typedef cl_##Ti clTi; \
|
||||
typedef cl_##To clTo; \
|
||||
|
||||
@@ -26,7 +26,7 @@ const char *sample_kernel_code_single_line[] = {
|
||||
"}\n"
|
||||
};
|
||||
|
||||
TEST_SPIRV_FUNC(get_program_il)
|
||||
REGISTER_TEST(get_program_il)
|
||||
{
|
||||
clProgramWrapper source_program;
|
||||
size_t il_size = -1;
|
||||
|
||||
@@ -77,19 +77,19 @@ static int test_linkage_compile(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(linkage_export_function_compile)
|
||||
REGISTER_TEST(linkage_export_function_compile)
|
||||
{
|
||||
clProgramWrapper prog;
|
||||
return test_linkage_compile(deviceID, context, queue, "linkage_export", prog);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(linkage_import_function_compile)
|
||||
REGISTER_TEST(linkage_import_function_compile)
|
||||
{
|
||||
clProgramWrapper prog;
|
||||
return test_linkage_compile(deviceID, context, queue, "linkage_import", prog);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(linkage_import_function_link)
|
||||
REGISTER_TEST(linkage_import_function_link)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -212,7 +212,7 @@ static int test_linkonce_odr_helper(cl_device_id deviceID, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(linkage_linkonce_odr)
|
||||
REGISTER_TEST(linkage_linkonce_odr)
|
||||
{
|
||||
if (!is_extension_available(deviceID, "cl_khr_spirv_linkonce_odr"))
|
||||
{
|
||||
|
||||
@@ -226,8 +226,7 @@ int test_no_integer_wrap_decoration(cl_device_id deviceID, cl_context context,
|
||||
}
|
||||
|
||||
#define TEST_FMATH_FUNC_KHR(TYPE, FUNC) \
|
||||
TEST_SPIRV_FUNC( \
|
||||
ext_cl_khr_spirv_no_integer_wrap_decoration_##FUNC##_##TYPE) \
|
||||
REGISTER_TEST(ext_cl_khr_spirv_no_integer_wrap_decoration_##FUNC##_##TYPE) \
|
||||
{ \
|
||||
if (!is_extension_available( \
|
||||
deviceID, "cl_khr_spirv_no_integer_wrap_decoration")) \
|
||||
@@ -253,7 +252,7 @@ TEST_FMATH_FUNC_KHR(uint, fmul)
|
||||
TEST_FMATH_FUNC_KHR(uint, fshiftleft)
|
||||
|
||||
#define TEST_FMATH_FUNC_14(TYPE, FUNC) \
|
||||
TEST_SPIRV_FUNC(spirv14_no_integer_wrap_decoration_##FUNC##_##TYPE) \
|
||||
REGISTER_TEST(spirv14_no_integer_wrap_decoration_##FUNC##_##TYPE) \
|
||||
{ \
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) \
|
||||
{ \
|
||||
|
||||
@@ -87,14 +87,14 @@ int test_atomic(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_atomic_inc_global)
|
||||
REGISTER_TEST(op_atomic_inc_global)
|
||||
{
|
||||
int num = 1 << 16;
|
||||
return test_atomic<cl_int>(deviceID, context, queue,
|
||||
"atomic_inc_global", num, true);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_atomic_dec_global)
|
||||
REGISTER_TEST(op_atomic_dec_global)
|
||||
{
|
||||
int num = 1 << 16;
|
||||
return test_atomic<cl_int>(deviceID, context, queue,
|
||||
|
||||
@@ -65,19 +65,19 @@ int test_branch_simple(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_BRANCH_SIMPLE(NAME) \
|
||||
TEST_SPIRV_FUNC(op_##NAME##_simple) \
|
||||
{ \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
int num = 1 << 10; \
|
||||
std::vector<cl_int> results(num); \
|
||||
for (int i = 0; i < num; i++) { \
|
||||
results[i] = genrand<cl_int>(seed); \
|
||||
} \
|
||||
return test_branch_simple(deviceID, context, queue, \
|
||||
#NAME "_simple", \
|
||||
results); \
|
||||
} \
|
||||
#define TEST_BRANCH_SIMPLE(NAME) \
|
||||
REGISTER_TEST(op_##NAME##_simple) \
|
||||
{ \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
int num = 1 << 10; \
|
||||
std::vector<cl_int> results(num); \
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
results[i] = genrand<cl_int>(seed); \
|
||||
} \
|
||||
return test_branch_simple(deviceID, context, queue, #NAME "_simple", \
|
||||
results); \
|
||||
}
|
||||
|
||||
|
||||
TEST_BRANCH_SIMPLE(label)
|
||||
|
||||
@@ -84,7 +84,7 @@ int test_branch_conditional(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
#define TEST_BRANCH_CONDITIONAL(name) \
|
||||
TEST_SPIRV_FUNC(op_##name) \
|
||||
REGISTER_TEST(op_##name) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
|
||||
@@ -56,14 +56,14 @@ int test_composite_construct(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_composite_construct_int4)
|
||||
REGISTER_TEST(op_composite_construct_int4)
|
||||
{
|
||||
cl_int4 value = { { 123, 122, 121, 119 } };
|
||||
std::vector<cl_int4> results(256, value);
|
||||
return test_composite_construct(deviceID, context, queue, "composite_construct_int4", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_composite_construct_struct)
|
||||
REGISTER_TEST(op_composite_construct_struct)
|
||||
{
|
||||
typedef AbstractStruct2<int, char> CustomType1;
|
||||
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;
|
||||
|
||||
@@ -64,14 +64,13 @@ int test_constant(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_CONSTANT(NAME, type, value) \
|
||||
TEST_SPIRV_FUNC(op_constant_##NAME##_simple) \
|
||||
{ \
|
||||
std::vector<type> results(1024, (type)value); \
|
||||
return test_constant(deviceID, context, queue, \
|
||||
"constant_" #NAME "_simple", \
|
||||
results); \
|
||||
} \
|
||||
#define TEST_CONSTANT(NAME, type, value) \
|
||||
REGISTER_TEST(op_constant_##NAME##_simple) \
|
||||
{ \
|
||||
std::vector<type> results(1024, (type)value); \
|
||||
return test_constant(deviceID, context, queue, \
|
||||
"constant_" #NAME "_simple", results); \
|
||||
}
|
||||
|
||||
// Boolean tests
|
||||
TEST_CONSTANT(true , cl_int , 1 )
|
||||
@@ -98,14 +97,14 @@ TEST_CONSTANT(short , cl_short , 32000 )
|
||||
TEST_CONSTANT(float , cl_float , 3.1415927 )
|
||||
TEST_CONSTANT(double , cl_double , 3.141592653589793)
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_int4_simple)
|
||||
REGISTER_TEST(op_constant_int4_simple)
|
||||
{
|
||||
cl_int4 value = { { 123, 122, 121, 119 } };
|
||||
std::vector<cl_int4> results(256, value);
|
||||
return test_constant(deviceID, context, queue, "constant_int4_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_int3_simple)
|
||||
REGISTER_TEST(op_constant_int3_simple)
|
||||
{
|
||||
cl_int3 value = { { 123, 122, 121, 0 } };
|
||||
std::vector<cl_int3> results(256, value);
|
||||
@@ -113,21 +112,21 @@ TEST_SPIRV_FUNC(op_constant_int3_simple)
|
||||
results, isVectorNotEqual<cl_int3, 3>);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_struct_int_float_simple)
|
||||
REGISTER_TEST(op_constant_struct_int_float_simple)
|
||||
{
|
||||
AbstractStruct2<int, float> value = {1024, 3.1415};
|
||||
std::vector<AbstractStruct2<int, float> > results(256, value);
|
||||
return test_constant(deviceID, context, queue, "constant_struct_int_float_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_struct_int_char_simple)
|
||||
REGISTER_TEST(op_constant_struct_int_char_simple)
|
||||
{
|
||||
AbstractStruct2<int, char> value = { 2100483600, (char)128 };
|
||||
std::vector<AbstractStruct2<int, char> > results(256, value);
|
||||
return test_constant(deviceID, context, queue, "constant_struct_int_char_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_struct_struct_simple)
|
||||
REGISTER_TEST(op_constant_struct_struct_simple)
|
||||
{
|
||||
typedef AbstractStruct2<int, char> CustomType1;
|
||||
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;
|
||||
@@ -140,7 +139,7 @@ TEST_SPIRV_FUNC(op_constant_struct_struct_simple)
|
||||
return test_constant(deviceID, context, queue, "constant_struct_struct_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_constant_half_simple)
|
||||
REGISTER_TEST(op_constant_half_simple)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID);
|
||||
std::vector<cl_float> results(1024, 3.25);
|
||||
|
||||
@@ -64,14 +64,13 @@ int test_copy(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_COPY(NAME, type, value) \
|
||||
TEST_SPIRV_FUNC(op_copy_##NAME##_simple) \
|
||||
{ \
|
||||
std::vector<type> results(1024, (type)value); \
|
||||
return test_copy(deviceID, context, queue, \
|
||||
"copy_" #NAME "_simple", \
|
||||
results); \
|
||||
} \
|
||||
#define TEST_COPY(NAME, type, value) \
|
||||
REGISTER_TEST(op_copy_##NAME##_simple) \
|
||||
{ \
|
||||
std::vector<type> results(1024, (type)value); \
|
||||
return test_copy(deviceID, context, queue, "copy_" #NAME "_simple", \
|
||||
results); \
|
||||
}
|
||||
|
||||
// Integer tests
|
||||
TEST_COPY(int , cl_int , 123 )
|
||||
@@ -94,14 +93,14 @@ TEST_COPY(short , cl_short , 32000 )
|
||||
TEST_COPY(float , cl_float , 3.1415927 )
|
||||
TEST_COPY(double , cl_double , 3.141592653589793)
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_int4_simple)
|
||||
REGISTER_TEST(op_copy_int4_simple)
|
||||
{
|
||||
cl_int4 value = { { 123, 122, 121, 119 } };
|
||||
std::vector<cl_int4> results(256, value);
|
||||
return test_copy(deviceID, context, queue, "copy_int4_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_int3_simple)
|
||||
REGISTER_TEST(op_copy_int3_simple)
|
||||
{
|
||||
cl_int3 value = { { 123, 122, 121, 0 } };
|
||||
std::vector<cl_int3> results(256, value);
|
||||
@@ -109,21 +108,21 @@ TEST_SPIRV_FUNC(op_copy_int3_simple)
|
||||
results, isVectorNotEqual<cl_int3, 3>);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_struct_int_float_simple)
|
||||
REGISTER_TEST(op_copy_struct_int_float_simple)
|
||||
{
|
||||
AbstractStruct2<int, float> value = {1024, 3.1415};
|
||||
std::vector<AbstractStruct2<int, float> > results(256, value);
|
||||
return test_copy(deviceID, context, queue, "copy_struct_int_float_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_struct_int_char_simple)
|
||||
REGISTER_TEST(op_copy_struct_int_char_simple)
|
||||
{
|
||||
AbstractStruct2<int, char> value = { 2100483600, (char)128 };
|
||||
std::vector<AbstractStruct2<int, char> > results(256, value);
|
||||
return test_copy(deviceID, context, queue, "copy_struct_int_char_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_struct_struct_simple)
|
||||
REGISTER_TEST(op_copy_struct_struct_simple)
|
||||
{
|
||||
typedef AbstractStruct2<int, char> CustomType1;
|
||||
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;
|
||||
@@ -136,7 +135,7 @@ TEST_SPIRV_FUNC(op_copy_struct_struct_simple)
|
||||
return test_copy(deviceID, context, queue, "copy_struct_struct_simple", results);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_copy_half_simple)
|
||||
REGISTER_TEST(op_copy_half_simple)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID);
|
||||
std::vector<cl_float> results(1024, 3.25);
|
||||
|
||||
@@ -150,30 +150,28 @@ int test_fmath(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_FMATH_FUNC(TYPE, FUNC, MODE) \
|
||||
TEST_SPIRV_FUNC(op_##FUNC##_##TYPE##_##MODE) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) { \
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \
|
||||
} \
|
||||
const int num = 1 << 20; \
|
||||
std::vector<cl_##TYPE> lhs(num); \
|
||||
std::vector<cl_##TYPE> rhs(num); \
|
||||
\
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) { \
|
||||
lhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
rhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
} \
|
||||
\
|
||||
const char *mode = #MODE; \
|
||||
return test_fmath(deviceID, context, queue, \
|
||||
#FUNC "_" #TYPE, \
|
||||
#FUNC, \
|
||||
#TYPE, \
|
||||
mode[0] == 'f', \
|
||||
lhs, rhs); \
|
||||
#define TEST_FMATH_FUNC(TYPE, FUNC, MODE) \
|
||||
REGISTER_TEST(op_##FUNC##_##TYPE##_##MODE) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) \
|
||||
{ \
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \
|
||||
} \
|
||||
const int num = 1 << 20; \
|
||||
std::vector<cl_##TYPE> lhs(num); \
|
||||
std::vector<cl_##TYPE> rhs(num); \
|
||||
\
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
lhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
rhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
} \
|
||||
\
|
||||
const char *mode = #MODE; \
|
||||
return test_fmath(deviceID, context, queue, #FUNC "_" #TYPE, #FUNC, \
|
||||
#TYPE, mode[0] == 'f', lhs, rhs); \
|
||||
}
|
||||
|
||||
#define TEST_FMATH_MODE(TYPE, MODE) \
|
||||
|
||||
@@ -67,21 +67,18 @@ int test_function(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
|
||||
#define TEST_FUNCTION(TYPE) \
|
||||
TEST_SPIRV_FUNC(function_##TYPE) \
|
||||
{ \
|
||||
int num = 1 << 20; \
|
||||
std::vector<cl_float> in(num); \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
for (int i = 0; i < num; i++) { \
|
||||
in[i] = genrand<cl_float>(seed); \
|
||||
} \
|
||||
return test_function(deviceID, \
|
||||
context, \
|
||||
queue, \
|
||||
#TYPE, \
|
||||
in); \
|
||||
} \
|
||||
#define TEST_FUNCTION(TYPE) \
|
||||
REGISTER_TEST(function_##TYPE) \
|
||||
{ \
|
||||
int num = 1 << 20; \
|
||||
std::vector<cl_float> in(num); \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
in[i] = genrand<cl_float>(seed); \
|
||||
} \
|
||||
return test_function(deviceID, context, queue, #TYPE, in); \
|
||||
}
|
||||
|
||||
TEST_FUNCTION(none)
|
||||
TEST_FUNCTION(inline)
|
||||
|
||||
@@ -83,25 +83,25 @@ int test_op_lifetime(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_LIFETIME(name) \
|
||||
TEST_SPIRV_FUNC(op_##name) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
std::vector<cl_int> lhs(num); \
|
||||
std::vector<cl_int> rhs(num); \
|
||||
std::vector<cl_int> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) { \
|
||||
lhs[i] = genrand<int>(seed); \
|
||||
rhs[i] = genrand<int>(seed); \
|
||||
out[i] = lhs[i] - rhs[i]; \
|
||||
} \
|
||||
\
|
||||
return test_op_lifetime(deviceID, context, queue, \
|
||||
#name, \
|
||||
lhs, rhs, out); \
|
||||
} \
|
||||
#define TEST_LIFETIME(name) \
|
||||
REGISTER_TEST(op_##name) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
std::vector<cl_int> lhs(num); \
|
||||
std::vector<cl_int> rhs(num); \
|
||||
std::vector<cl_int> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
lhs[i] = genrand<int>(seed); \
|
||||
rhs[i] = genrand<int>(seed); \
|
||||
out[i] = lhs[i] - rhs[i]; \
|
||||
} \
|
||||
\
|
||||
return test_op_lifetime(deviceID, context, queue, #name, lhs, rhs, \
|
||||
out); \
|
||||
}
|
||||
|
||||
TEST_LIFETIME(lifetime_simple)
|
||||
|
||||
@@ -81,30 +81,32 @@ int test_selection_merge(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_LOOP_BRANCH(control) \
|
||||
TEST_SPIRV_FUNC(op_loop_merge_branch_##control) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
int rep = 4; \
|
||||
std::vector<cl_int> in(rep * num); \
|
||||
std::vector<cl_int> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) { \
|
||||
int res = 0; \
|
||||
for (int j = 0; j < rep; j++) { \
|
||||
cl_int val = genrand<cl_int>(seed) % 1024; \
|
||||
res += val; \
|
||||
in[j * num + i] = val; \
|
||||
} \
|
||||
out[i] = res; \
|
||||
} \
|
||||
\
|
||||
return test_selection_merge(deviceID, context, queue, \
|
||||
"loop_merge_branch_" #control, \
|
||||
in, out, rep); \
|
||||
} \
|
||||
#define TEST_LOOP_BRANCH(control) \
|
||||
REGISTER_TEST(op_loop_merge_branch_##control) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
int rep = 4; \
|
||||
std::vector<cl_int> in(rep *num); \
|
||||
std::vector<cl_int> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
int res = 0; \
|
||||
for (int j = 0; j < rep; j++) \
|
||||
{ \
|
||||
cl_int val = genrand<cl_int>(seed) % 1024; \
|
||||
res += val; \
|
||||
in[j * num + i] = val; \
|
||||
} \
|
||||
out[i] = res; \
|
||||
} \
|
||||
\
|
||||
return test_selection_merge(deviceID, context, queue, \
|
||||
"loop_merge_branch_" #control, in, out, \
|
||||
rep); \
|
||||
}
|
||||
|
||||
TEST_LOOP_BRANCH(none)
|
||||
TEST_LOOP_BRANCH(unroll)
|
||||
|
||||
@@ -86,7 +86,7 @@ int test_negation(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
#define TEST_NEGATION(TYPE, Tv, OP, FUNC) \
|
||||
TEST_SPIRV_FUNC(OP##_##TYPE) \
|
||||
REGISTER_TEST(OP##_##TYPE) \
|
||||
{ \
|
||||
int num = 1 << 20; \
|
||||
std::vector<Tv> in(num); \
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "testBase.h"
|
||||
#include "types.hpp"
|
||||
|
||||
TEST_SPIRV_FUNC(op_type_opaque_simple)
|
||||
REGISTER_TEST(op_type_opaque_simple)
|
||||
{
|
||||
const char *name = "opaque";
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
@@ -83,7 +83,7 @@ int test_phi(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_phi_2_blocks)
|
||||
REGISTER_TEST(op_phi_2_blocks)
|
||||
{
|
||||
const int num = 1 << 10;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
@@ -101,7 +101,7 @@ TEST_SPIRV_FUNC(op_phi_2_blocks)
|
||||
return test_phi(deviceID, context, queue, "phi_2", lhs, rhs, out);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_phi_3_blocks)
|
||||
REGISTER_TEST(op_phi_3_blocks)
|
||||
{
|
||||
const int num = 1 << 10;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
@@ -123,7 +123,7 @@ TEST_SPIRV_FUNC(op_phi_3_blocks)
|
||||
return test_phi(deviceID, context, queue, "phi_3", lhs, rhs, out);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_phi_4_blocks)
|
||||
REGISTER_TEST(op_phi_4_blocks)
|
||||
{
|
||||
const int num = 1 << 10;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
@@ -84,7 +84,7 @@ int test_selection_merge(cl_device_id deviceID,
|
||||
}
|
||||
|
||||
#define TEST_SELECT_IF(control) \
|
||||
TEST_SPIRV_FUNC(op_selection_merge_if_##control) \
|
||||
REGISTER_TEST(op_selection_merge_if_##control) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
@@ -108,26 +108,26 @@ TEST_SELECT_IF(none)
|
||||
TEST_SELECT_IF(flatten)
|
||||
TEST_SELECT_IF(dont_flatten)
|
||||
|
||||
#define TEST_SELECT_SWITCH(control) \
|
||||
TEST_SPIRV_FUNC(op_selection_merge_swith_##control) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
std::vector<cl_uint> lhs(num); \
|
||||
std::vector<cl_uint> rhs(num); \
|
||||
std::vector<cl_uint> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) { \
|
||||
lhs[i] = genrand<cl_uint>(seed); \
|
||||
rhs[i] = genrand<cl_uint>(seed); \
|
||||
out[i] = (lhs[i] + rhs[i]) % 4; \
|
||||
} \
|
||||
\
|
||||
return test_selection_merge(deviceID, context, queue, \
|
||||
"select_switch_" #control, \
|
||||
lhs, rhs, out); \
|
||||
} \
|
||||
#define TEST_SELECT_SWITCH(control) \
|
||||
REGISTER_TEST(op_selection_merge_swith_##control) \
|
||||
{ \
|
||||
const int num = 1 << 10; \
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
std::vector<cl_uint> lhs(num); \
|
||||
std::vector<cl_uint> rhs(num); \
|
||||
std::vector<cl_uint> out(num); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
lhs[i] = genrand<cl_uint>(seed); \
|
||||
rhs[i] = genrand<cl_uint>(seed); \
|
||||
out[i] = (lhs[i] + rhs[i]) % 4; \
|
||||
} \
|
||||
\
|
||||
return test_selection_merge(deviceID, context, queue, \
|
||||
"select_switch_" #control, lhs, rhs, out); \
|
||||
}
|
||||
|
||||
TEST_SELECT_SWITCH(none)
|
||||
TEST_SELECT_SWITCH(flatten)
|
||||
|
||||
@@ -115,7 +115,7 @@ int test_spec_constant(cl_device_id deviceID, cl_context context,
|
||||
|
||||
|
||||
#define TEST_SPEC_CONSTANT(NAME, type, init_buffer, spec_constant_value) \
|
||||
TEST_SPIRV_FUNC_VERSION(op_spec_constant_##NAME##_simple, Version(2, 2)) \
|
||||
REGISTER_TEST_VERSION(op_spec_constant_##NAME##_simple, Version(2, 2)) \
|
||||
{ \
|
||||
type init_value = init_buffer; \
|
||||
type final_value = init_value + spec_constant_value; \
|
||||
@@ -137,7 +137,7 @@ TEST_SPEC_CONSTANT(double, cl_double, 14534.53453, 1.53453)
|
||||
// documenation: 'If a specialization constant is a boolean
|
||||
// constant, spec_value should be a pointer to a cl_uchar value'
|
||||
|
||||
TEST_SPIRV_FUNC_VERSION(op_spec_constant_true_simple, Version(2, 2))
|
||||
REGISTER_TEST_VERSION(op_spec_constant_true_simple, Version(2, 2))
|
||||
{
|
||||
// 1-st ndrange init_value is expected value (no change)
|
||||
// 2-nd ndrange sets spec const to 'false' so value = value + 1
|
||||
@@ -149,7 +149,7 @@ TEST_SPIRV_FUNC_VERSION(op_spec_constant_true_simple, Version(2, 2))
|
||||
init_value, 0, final_value);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC_VERSION(op_spec_constant_false_simple, Version(2, 2))
|
||||
REGISTER_TEST_VERSION(op_spec_constant_false_simple, Version(2, 2))
|
||||
{
|
||||
// 1-st ndrange init_value is expected value (no change)
|
||||
// 2-nd ndrange sets spec const to 'true' so value = value + 1
|
||||
|
||||
@@ -57,12 +57,12 @@ int test_undef(cl_device_id deviceID, cl_context context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_UNDEF(NAME, TYPE) \
|
||||
TEST_SPIRV_FUNC(op_undef_##NAME##_simple) \
|
||||
{ \
|
||||
return test_undef<TYPE>(deviceID, context, queue, \
|
||||
"undef_" #NAME "_simple"); \
|
||||
} \
|
||||
#define TEST_UNDEF(NAME, TYPE) \
|
||||
REGISTER_TEST(op_undef_##NAME##_simple) \
|
||||
{ \
|
||||
return test_undef<TYPE>(deviceID, context, queue, \
|
||||
"undef_" #NAME "_simple"); \
|
||||
}
|
||||
|
||||
// Boolean tests
|
||||
TEST_UNDEF(true , cl_int )
|
||||
@@ -92,26 +92,26 @@ TEST_UNDEF(int4 , cl_int4)
|
||||
TEST_UNDEF(int3 , cl_int3)
|
||||
|
||||
|
||||
TEST_SPIRV_FUNC(op_undef_struct_int_float_simple)
|
||||
REGISTER_TEST(op_undef_struct_int_float_simple)
|
||||
{
|
||||
typedef AbstractStruct2<cl_int, cl_float> CustomType;
|
||||
return test_undef<CustomType>(deviceID, context, queue, "undef_struct_int_float_simple");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_undef_struct_int_char_simple)
|
||||
REGISTER_TEST(op_undef_struct_int_char_simple)
|
||||
{
|
||||
typedef AbstractStruct2<cl_int, cl_char> CustomType;
|
||||
return test_undef<CustomType>(deviceID, context, queue, "undef_struct_int_char_simple");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_undef_struct_struct_simple)
|
||||
REGISTER_TEST(op_undef_struct_struct_simple)
|
||||
{
|
||||
typedef AbstractStruct2<cl_int, cl_char> CustomType1;
|
||||
typedef AbstractStruct2<cl_int2, CustomType1> CustomType2;
|
||||
return test_undef<CustomType2>(deviceID, context, queue, "undef_struct_struct_simple");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(op_undef_half_simple)
|
||||
REGISTER_TEST(op_undef_half_simple)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID);
|
||||
return test_undef<cl_float>(deviceID, context, queue,
|
||||
|
||||
@@ -91,7 +91,7 @@ int test_extract(cl_device_id deviceID, cl_context context,
|
||||
}
|
||||
|
||||
#define TEST_VECTOR_EXTRACT(TYPE, N) \
|
||||
TEST_SPIRV_FUNC(op_vector_##TYPE##N##_extract) \
|
||||
REGISTER_TEST(op_vector_##TYPE##N##_extract) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) \
|
||||
{ \
|
||||
|
||||
@@ -109,7 +109,7 @@ int test_insert(cl_device_id deviceID, cl_context context,
|
||||
}
|
||||
|
||||
#define TEST_VECTOR_INSERT(TYPE, N) \
|
||||
TEST_SPIRV_FUNC(op_vector_##TYPE##N##_insert) \
|
||||
REGISTER_TEST(op_vector_##TYPE##N##_insert) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) \
|
||||
{ \
|
||||
|
||||
@@ -161,29 +161,29 @@ int test_vector_times_scalar(cl_device_id deviceID,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST_VECTOR_TIMES_SCALAR(TYPE, N) \
|
||||
TEST_SPIRV_FUNC(op_vector_times_scalar_##TYPE) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) { \
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \
|
||||
} \
|
||||
typedef cl_##TYPE##N Tv; \
|
||||
typedef cl_##TYPE Ts; \
|
||||
const int num = 1 << 20; \
|
||||
std::vector<Tv> lhs(num); \
|
||||
std::vector<Ts> rhs(num); \
|
||||
\
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) { \
|
||||
lhs[i] = genrandReal<cl_##TYPE##N>(seed); \
|
||||
rhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
} \
|
||||
\
|
||||
return test_vector_times_scalar<Tv, Ts>(deviceID, \
|
||||
context, queue, \
|
||||
#TYPE, \
|
||||
lhs, rhs); \
|
||||
#define TEST_VECTOR_TIMES_SCALAR(TYPE, N) \
|
||||
REGISTER_TEST(op_vector_times_scalar_##TYPE) \
|
||||
{ \
|
||||
if (sizeof(cl_##TYPE) == 2) \
|
||||
{ \
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \
|
||||
} \
|
||||
typedef cl_##TYPE##N Tv; \
|
||||
typedef cl_##TYPE Ts; \
|
||||
const int num = 1 << 20; \
|
||||
std::vector<Tv> lhs(num); \
|
||||
std::vector<Ts> rhs(num); \
|
||||
\
|
||||
RandomSeed seed(gRandomSeed); \
|
||||
\
|
||||
for (int i = 0; i < num; i++) \
|
||||
{ \
|
||||
lhs[i] = genrandReal<cl_##TYPE##N>(seed); \
|
||||
rhs[i] = genrandReal<cl_##TYPE>(seed); \
|
||||
} \
|
||||
\
|
||||
return test_vector_times_scalar<Tv, Ts>(deviceID, context, queue, \
|
||||
#TYPE, lhs, rhs); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ static int test_image_operand_helper(cl_device_id deviceID, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_image_operand_signextend)
|
||||
REGISTER_TEST(spirv14_image_operand_signextend)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -100,7 +100,7 @@ TEST_SPIRV_FUNC(spirv14_image_operand_signextend)
|
||||
return test_image_operand_helper(deviceID, context, queue, true);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_image_operand_zeroextend)
|
||||
REGISTER_TEST(spirv14_image_operand_zeroextend)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -155,7 +155,7 @@ static int test_loop_control_helper(cl_device_id deviceID, cl_context context,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_loop_control_miniterations)
|
||||
REGISTER_TEST(spirv14_loop_control_miniterations)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -166,7 +166,7 @@ TEST_SPIRV_FUNC(spirv14_loop_control_miniterations)
|
||||
"loop_control_miniterations");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_loop_control_maxiterations)
|
||||
REGISTER_TEST(spirv14_loop_control_maxiterations)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -177,7 +177,7 @@ TEST_SPIRV_FUNC(spirv14_loop_control_maxiterations)
|
||||
"loop_control_maxiterations");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_loop_control_iterationmultiple)
|
||||
REGISTER_TEST(spirv14_loop_control_iterationmultiple)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -188,7 +188,7 @@ TEST_SPIRV_FUNC(spirv14_loop_control_iterationmultiple)
|
||||
"loop_control_iterationmultiple");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_loop_control_peelcount)
|
||||
REGISTER_TEST(spirv14_loop_control_peelcount)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -199,7 +199,7 @@ TEST_SPIRV_FUNC(spirv14_loop_control_peelcount)
|
||||
"loop_control_peelcount");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_loop_control_partialcount)
|
||||
REGISTER_TEST(spirv14_loop_control_partialcount)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -210,7 +210,7 @@ TEST_SPIRV_FUNC(spirv14_loop_control_partialcount)
|
||||
"loop_control_partialcount");
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_ptrops)
|
||||
REGISTER_TEST(spirv14_ptrops)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -331,7 +331,7 @@ static int test_usersemantic_decoration(cl_device_id deviceID,
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_usersemantic_decoratestring)
|
||||
REGISTER_TEST(spirv14_usersemantic_decoratestring)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -342,7 +342,7 @@ TEST_SPIRV_FUNC(spirv14_usersemantic_decoratestring)
|
||||
return test_usersemantic_decoration(deviceID, context, queue, false);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_usersemantic_memberdecoratestring)
|
||||
REGISTER_TEST(spirv14_usersemantic_memberdecoratestring)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -353,7 +353,7 @@ TEST_SPIRV_FUNC(spirv14_usersemantic_memberdecoratestring)
|
||||
return test_usersemantic_decoration(deviceID, context, queue, true);
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_nonwriteable_decoration)
|
||||
REGISTER_TEST(spirv14_nonwriteable_decoration)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -399,7 +399,7 @@ TEST_SPIRV_FUNC(spirv14_nonwriteable_decoration)
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_copymemory_memory_operands)
|
||||
REGISTER_TEST(spirv14_copymemory_memory_operands)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
@@ -450,7 +450,7 @@ TEST_SPIRV_FUNC(spirv14_copymemory_memory_operands)
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_select_composite)
|
||||
REGISTER_TEST(spirv14_select_composite)
|
||||
{
|
||||
constexpr size_t global_size = 16;
|
||||
|
||||
@@ -512,7 +512,7 @@ TEST_SPIRV_FUNC(spirv14_select_composite)
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
TEST_SPIRV_FUNC(spirv14_copylogical)
|
||||
REGISTER_TEST(spirv14_copylogical)
|
||||
{
|
||||
if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4"))
|
||||
{
|
||||
|
||||
@@ -1447,7 +1447,7 @@ public:
|
||||
};
|
||||
|
||||
// Driver for testing a single built in function
|
||||
template <typename Ty, typename Fns, size_t TSIZE = 0> struct test
|
||||
template <typename Ty, typename Fns, size_t TSIZE = 0> struct subgroup_test
|
||||
{
|
||||
static test_status run(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
@@ -1688,9 +1688,9 @@ struct RunTestForType
|
||||
std::regex_replace(test_params_.get_kernel_source(function_name),
|
||||
std::regex("\\%s"), function_name);
|
||||
std::string kernel_name = "test_" + function_name;
|
||||
error =
|
||||
test<T, U>::run(device_, context_, queue_, num_elements_,
|
||||
kernel_name.c_str(), source.c_str(), test_params_);
|
||||
error = subgroup_test<T, U>::run(device_, context_, queue_,
|
||||
num_elements_, kernel_name.c_str(),
|
||||
source.c_str(), test_params_);
|
||||
|
||||
// If we return TEST_SKIPPED_ITSELF here, then an entire suite may be
|
||||
// reported as having been skipped even if some tests within it
|
||||
|
||||
@@ -164,9 +164,10 @@ int test_barrier_functions(cl_device_id device, cl_context context,
|
||||
constexpr size_t local_work_size = 200;
|
||||
WorkGroupParams test_params(global_work_size, local_work_size);
|
||||
test_params.use_core_subgroups = useCoreSubgroups;
|
||||
error = test<cl_int, BAR<0>>::run(device, context, queue, num_elements,
|
||||
"test_lbar", lbar_source, test_params);
|
||||
error |= test<cl_int, BAR<1>, global_work_size>::run(
|
||||
error = subgroup_test<cl_int, BAR<0>>::run(device, context, queue,
|
||||
num_elements, "test_lbar",
|
||||
lbar_source, test_params);
|
||||
error |= subgroup_test<cl_int, BAR<1>, global_work_size>::run(
|
||||
device, context, queue, num_elements, "test_gbar", gbar_source,
|
||||
test_params);
|
||||
|
||||
|
||||
@@ -297,8 +297,9 @@ int test_ifp(cl_device_id device, cl_context context, cl_command_queue queue,
|
||||
WorkGroupParams test_params(global_work_size, local_work_size);
|
||||
test_params.use_core_subgroups = useCoreSubgroups;
|
||||
test_params.dynsc = NUM_LOC + 1;
|
||||
error = test<cl_int, IFP>::run(device, context, queue, num_elements,
|
||||
"test_ifp", ifp_source, test_params);
|
||||
error =
|
||||
subgroup_test<cl_int, IFP>::run(device, context, queue, num_elements,
|
||||
"test_ifp", ifp_source, test_params);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user