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 FUNCTION_LIST_H 17 #define FUNCTION_LIST_H 18 19 #include "harness/compat.h" 20 21 #ifndef WIN32 22 #include <unistd.h> 23 #endif 24 25 #if defined(__APPLE__) 26 #include <OpenCL/opencl.h> 27 #else 28 #include <CL/cl.h> 29 #endif 30 31 #include "harness/mt19937.h" 32 33 union fptr { 34 void *p; 35 double (*f_f)(double); 36 double (*f_u)(cl_uint); 37 int (*i_f)(double); 38 int (*i_f_f)(float); 39 float (*f_ff_f)(float, float); 40 double (*f_ff)(double, double); 41 int (*i_ff)(double, double); 42 double (*f_fi)(double, int); 43 double (*f_fpf)(double, double *); 44 double (*f_fpI)(double, int *); 45 double (*f_ffpI)(double, double, int *); 46 double (*f_fff)(double, double, double); 47 float (*f_fma)(float, float, float, int); 48 }; 49 50 union dptr { 51 void *p; 52 long double (*f_f)(long double); 53 long double (*f_u)(cl_ulong); 54 int (*i_f)(long double); 55 long double (*f_ff)(long double, long double); 56 int (*i_ff)(long double, long double); 57 long double (*f_fi)(long double, int); 58 long double (*f_fpf)(long double, long double *); 59 long double (*f_fpI)(long double, int *); 60 long double (*f_ffpI)(long double, long double, int *); 61 long double (*f_fff)(long double, long double, long double); 62 }; 63 64 struct Func; 65 66 struct vtbl 67 { 68 const char *type_name; 69 int (*TestFunc)(const struct Func *, MTdata, bool); 70 int (*DoubleTestFunc)( 71 const struct Func *, MTdata, 72 bool); // may be NULL if function is single precision only 73 }; 74 75 struct Func 76 { 77 const char *name; // common name, to be used as an argument in the shell 78 const char *nameInCode; // name as it appears in the __kernel, usually the 79 // same as name, but different for multiplication 80 fptr func; 81 dptr dfunc; 82 fptr rfunc; 83 float float_ulps; 84 float double_ulps; 85 float float_embedded_ulps; 86 float relaxed_error; 87 float relaxed_embedded_error; 88 int ftz; 89 int relaxed; 90 const vtbl *vtbl_ptr; 91 }; 92 93 94 extern const Func functionList[]; 95 96 extern const size_t functionListCount; 97 98 #endif 99