• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //    http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #ifndef TEST_CONFORMANCE_CLCPP_FUNCS_TEST_UTILS_HPP
17 #define TEST_CONFORMANCE_CLCPP_FUNCS_TEST_UTILS_HPP
18 
19 // This file contains helper classes and functions for testing various unary, binary
20 // and ternary OpenCL functions (for example cl::abs(x) or cl::abs_diff(x, y)),
21 // as well as other helper functions/classes.
22 
23 #include "common.hpp"
24 
25 #define TEST_UNARY_FUNC_MACRO(TEST_CLASS) \
26     last_error = test_unary_func(  \
27         device, context, queue, n_elems, TEST_CLASS \
28     );  \
29     CHECK_ERROR(last_error) \
30     error |= last_error;
31 
32 #define TEST_BINARY_FUNC_MACRO(TEST_CLASS) \
33     last_error = test_binary_func(  \
34         device, context, queue, n_elems, TEST_CLASS \
35     );  \
36     CHECK_ERROR(last_error) \
37     error |= last_error;
38 
39 #define TEST_TERNARY_FUNC_MACRO(TEST_CLASS) \
40     last_error = test_ternary_func(  \
41         device, context, queue, n_elems, TEST_CLASS \
42     );  \
43     CHECK_ERROR(last_error) \
44     error |= last_error;
45 
46 #include "utils_test/compare.hpp"
47 #include "utils_test/generate_inputs.hpp"
48 
49 // HOWTO:
50 //
51 // unary_func, binary_func, ternary_func - base classes wrapping OpenCL functions that
52 // you want to test.
53 //
54 // To create a wrapper class for given function, you need to create a class derived from correct
55 // base class (unary_func, binary_func, ternary_func), and define:
56 //
57 // * std::string str() method which should return class name in OpenCL ("abs", "abs_diff"),
58 // * operator(x), operator(x, y) or operator(x,y,z) depending on arity of the function you wish
59 // to test, method should work exactly as the tested function works in OpenCL
60 // * if it's needed you can overload min1, max1, min2, max2, min3, max3 methods with returns min
61 // and max values that can be generated for given input (function argument) [required for vec
62 // arguments],
63 // * if you want to use vector arguments (for example: cl_int2, cl_ulong16), you should look at
64 // how int_func_clamp<> is implemented in integer_funcs/numeric_funcs.hpp.
65 //
66 // To see how you should use class you've just created see AUTO_TEST_CASE(test_int_numeric_funcs)
67 // in integer_funcs/numeric_funcs.hpp.
68 #include "utils_test/unary.hpp"
69 #include "utils_test/binary.hpp"
70 #include "utils_test/ternary.hpp"
71 
72 #endif // TEST_CONFORMANCE_CLCPP_FUNCS_TEST_UTILS_HPP
73