1 // 2 // Copyright (c) 2021 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 17 #ifndef INTEGER_OPS_TEST_INFO_H 18 #define INTEGER_OPS_TEST_INFO_H 19 20 #include "conversions.h" 21 #include "testHarness.h" 22 23 // TODO: expand usage to other tests. 24 25 template <typename T> struct TestInfo 26 { 27 }; 28 template <> struct TestInfo<cl_char> 29 { 30 static const ExplicitType explicitType = kChar; 31 static constexpr const char* deviceTypeName = "char"; 32 static constexpr const char* deviceTypeNameSigned = "char"; 33 static constexpr const char* deviceTypeNameUnsigned = "uchar"; 34 }; 35 template <> struct TestInfo<cl_uchar> 36 { 37 static const ExplicitType explicitType = kUChar; 38 static constexpr const char* deviceTypeName = "uchar"; 39 static constexpr const char* deviceTypeNameSigned = "char"; 40 static constexpr const char* deviceTypeNameUnsigned = "uchar"; 41 }; 42 template <> struct TestInfo<cl_short> 43 { 44 static const ExplicitType explicitType = kShort; 45 static constexpr const char* deviceTypeName = "short"; 46 static constexpr const char* deviceTypeNameSigned = "short"; 47 static constexpr const char* deviceTypeNameUnsigned = "ushort"; 48 }; 49 template <> struct TestInfo<cl_ushort> 50 { 51 static const ExplicitType explicitType = kUShort; 52 static constexpr const char* deviceTypeName = "ushort"; 53 static constexpr const char* deviceTypeNameSigned = "short"; 54 static constexpr const char* deviceTypeNameUnsigned = "ushort"; 55 }; 56 template <> struct TestInfo<cl_int> 57 { 58 static const ExplicitType explicitType = kInt; 59 static constexpr const char* deviceTypeName = "int"; 60 static constexpr const char* deviceTypeNameSigned = "int"; 61 static constexpr const char* deviceTypeNameUnsigned = "uint"; 62 }; 63 template <> struct TestInfo<cl_uint> 64 { 65 static const ExplicitType explicitType = kUInt; 66 static constexpr const char* deviceTypeName = "uint"; 67 static constexpr const char* deviceTypeNameSigned = "int"; 68 static constexpr const char* deviceTypeNameUnsigned = "uint"; 69 }; 70 template <> struct TestInfo<cl_long> 71 { 72 static const ExplicitType explicitType = kLong; 73 static constexpr const char* deviceTypeName = "long"; 74 static constexpr const char* deviceTypeNameSigned = "long"; 75 static constexpr const char* deviceTypeNameUnsigned = "ulong"; 76 }; 77 template <> struct TestInfo<cl_ulong> 78 { 79 static const ExplicitType explicitType = kULong; 80 static constexpr const char* deviceTypeName = "ulong"; 81 static constexpr const char* deviceTypeNameSigned = "long"; 82 static constexpr const char* deviceTypeNameUnsigned = "ulong"; 83 }; 84 85 template <typename T> 86 static void fill_vector_with_random_data(std::vector<T>& v) 87 { 88 MTdataHolder d(gRandomSeed); 89 generate_random_data(TestInfo<T>::explicitType, v.size(), d, v.data()); 90 } 91 92 #endif /* INTEGER_OPS_TEST_INFO_H */ 93