• 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 BASIC_TEST_CONVERSIONS_H
17 #define BASIC_TEST_CONVERSIONS_H
18 
19 #include "harness/compat.h"
20 
21 #if !defined(_WIN32)
22 #include <unistd.h>
23 #endif
24 
25 #include "harness/errorHelpers.h"
26 #include "harness/rounding_mode.h"
27 
28 #include <stdio.h>
29 #if defined( __APPLE__ )
30     #include <OpenCL/opencl.h>
31 #else
32     #include <CL/opencl.h>
33 #endif
34 
35 #include "harness/mt19937.h"
36 
37 typedef void (*Convert)( void *dest, void *src, size_t );
38 
39 #define kVectorSizeCount    6
40 #define kMaxVectorSize      16
41 
42 typedef enum
43 {
44     kUnsaturated = 0,
45     kSaturated,
46 
47     kSaturationModeCount
48 }SaturationMode;
49 
50 extern Convert gConversions[kTypeCount][kTypeCount];                // [dest format][source format]
51 extern Convert gSaturatedConversions[kTypeCount][kTypeCount];       // [dest format][source format]
52 extern const char *gTypeNames[ kTypeCount ];
53 extern const char *gRoundingModeNames[ kRoundingModeCount ];        // { "", "_rte", "_rtp", "_rtn", "_rtz" }
54 extern const char *gSaturationNames[ kSaturationModeCount ];        // { "", "_sat" }
55 extern const char *gVectorSizeNames[kVectorSizeCount];              // { "", "2", "4", "8", "16" }
56 extern size_t gTypeSizes[ kTypeCount ];
57 extern int gIsEmbedded;
58 
59 //Functions for clamping floating point numbers into the representable range for the type
60 typedef float (*clampf)( float );
61 typedef double (*clampd)( double );
62 
63 extern clampf gClampFloat[ kTypeCount ][kRoundingModeCount];
64 extern clampd gClampDouble[ kTypeCount ][kRoundingModeCount];
65 
66 typedef void (*InitDataFunc)( void *dest, SaturationMode, RoundingMode, Type destType, uint64_t start, int count, MTdata d );
67 extern InitDataFunc gInitFunctions[ kTypeCount ];
68 
69 typedef int (*CheckResults)( void *out1, void *out2, void *allowZ, uint32_t count, int vectorSize );
70 extern CheckResults gCheckResults[ kTypeCount ];
71 
72 #endif /* BASIC_TEST_CONVERSIONS_H */
73 
74