aboutsummaryrefslogtreecommitdiff
path: root/test_common/harness/integer_ops_test_info.h
blob: ad7b303b47305058c4afc8e2c45b073ff61664b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Copyright (c) 2021 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 INTEGER_OPS_TEST_INFO_H
#define INTEGER_OPS_TEST_INFO_H

#include "conversions.h"
#include "testHarness.h"

// TODO: expand usage to other tests.

template <typename T> struct TestInfo
{
};
template <> struct TestInfo<cl_char>
{
    static const ExplicitType explicitType = kChar;
    static constexpr const char* deviceTypeName = "char";
    static constexpr const char* deviceTypeNameSigned = "char";
    static constexpr const char* deviceTypeNameUnsigned = "uchar";
};
template <> struct TestInfo<cl_uchar>
{
    static const ExplicitType explicitType = kUChar;
    static constexpr const char* deviceTypeName = "uchar";
    static constexpr const char* deviceTypeNameSigned = "char";
    static constexpr const char* deviceTypeNameUnsigned = "uchar";
};
template <> struct TestInfo<cl_short>
{
    static const ExplicitType explicitType = kShort;
    static constexpr const char* deviceTypeName = "short";
    static constexpr const char* deviceTypeNameSigned = "short";
    static constexpr const char* deviceTypeNameUnsigned = "ushort";
};
template <> struct TestInfo<cl_ushort>
{
    static const ExplicitType explicitType = kUShort;
    static constexpr const char* deviceTypeName = "ushort";
    static constexpr const char* deviceTypeNameSigned = "short";
    static constexpr const char* deviceTypeNameUnsigned = "ushort";
};
template <> struct TestInfo<cl_int>
{
    static const ExplicitType explicitType = kInt;
    static constexpr const char* deviceTypeName = "int";
    static constexpr const char* deviceTypeNameSigned = "int";
    static constexpr const char* deviceTypeNameUnsigned = "uint";
};
template <> struct TestInfo<cl_uint>
{
    static const ExplicitType explicitType = kUInt;
    static constexpr const char* deviceTypeName = "uint";
    static constexpr const char* deviceTypeNameSigned = "int";
    static constexpr const char* deviceTypeNameUnsigned = "uint";
};
template <> struct TestInfo<cl_long>
{
    static const ExplicitType explicitType = kLong;
    static constexpr const char* deviceTypeName = "long";
    static constexpr const char* deviceTypeNameSigned = "long";
    static constexpr const char* deviceTypeNameUnsigned = "ulong";
};
template <> struct TestInfo<cl_ulong>
{
    static const ExplicitType explicitType = kULong;
    static constexpr const char* deviceTypeName = "ulong";
    static constexpr const char* deviceTypeNameSigned = "long";
    static constexpr const char* deviceTypeNameUnsigned = "ulong";
};

template <typename T>
static void fill_vector_with_random_data(std::vector<T>& v)
{
    MTdataHolder d(gRandomSeed);
    generate_random_data(TestInfo<T>::explicitType, v.size(), d, v.data());
}

#endif /* INTEGER_OPS_TEST_INFO_H */