2 # Copyright 2013 Advanced Micro Devices, Inc.
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 # Authors: Tom Stellard <thomas.stellard@amd.com>
24 # Aaron Watry <awatry@gmail.com>
29 from genclbuiltins
import gen
, NEGNAN
30 from math
import radians
, degrees
, pi
44 DATA_TYPES
= ['float']
56 'arg_types': [F
, F
, F
, F
],
57 'function_type': 'tss',
59 [0.5, 0.0, 0.0, 0.0, float("nan")], #Result
60 [1.0, -0.5, 0.0, 0.0, float("nan")], #Arg0
61 [0.0, 0.0, 0.0, -0.5, float("nan")], #Arg1
62 [0.5, 0.5, 0.0, 0.5, float("nan")], #Arg2
67 'function_type': 'ttt',
69 [degrees(0.5), degrees(-0.5), 180.0, 0.0, 360, 1800.0, 18000, 90], #Result
70 [0.5, -0.5, pi
, 0.0, 2*pi
, 10*pi
, 100*pi
, pi
/2] #Arg0
75 'arg_types': [F
, F
, F
],
76 'function_type': 'tss',
78 [1.0, 0.0, 0.0, 0.0 ], #Result
79 [1.0, -0.5, 0.0, 0.0 ], #Arg0
80 [0.0, 0.0, 0.0, -0.5 ] #Arg1
84 'arg_types': [F
, F
, F
],
85 'function_type': 'tss',
87 [0.0, -0.5, 0.0, -0.5 ], #Result
88 [1.0, -0.5, 0.0, 0.0 ], #Arg0
89 [0.0, 0.0, 0.0, -0.5 ] #Arg1
92 'mix' : { #x + (y - x) * a
93 'arg_types': [F
, F
, F
, F
],
94 'function_type': 'tts',
96 [0.5, -0.25, 0.0, -0.5, 1.0, 3.0, 10.0, float("nan"), float("nan"), float("nan")], #Result
97 [1.0, -0.5, 0.0, 0.0, 1.0, 4.0, 15.0, 5.0, 4.0, float("nan")], #Arg0
98 [0.0, 0.0, 0.0, -0.5, 2.0, 2.0, 10.0, -0.2, float("nan"), 1.5], #Arg1
99 [0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 1.0, float("nan"), 1.0, 0.0], #Arg2
104 'function_type': 'ttt',
106 [0.5, -0.5, pi
, 0.0, 2*pi
, 10*pi
, 100*pi
, pi
/2], #Result
107 [degrees(0.5), degrees(-0.5), 180.0, 0.0, 360, 1800.0, 18000, 90] #Arg0
110 #TODO Add scalar combination (tst?)
112 'arg_types': [F
, F
, F
],
113 'function_type': 'ttt',
115 [0.0, 1.0, 1.0, 0.0, 1.0, 1.0], #Result
116 [1.0, -0.5, 0.0, 0.0, 1.0, float("nan")], #Arg0
117 [0.0, 0.0, 0.0, -0.5, float("nan"), 1.0] #Arg1
120 #TODO Add scalar combination (tst?)
122 'arg_types': [F
, F
, F
, F
],
123 'function_type': 'ttt',
125 [0.0, 0.0, 1.0, 1.0, 0.5, 0.896], #Result
126 [0.0, 0.0, 0.0, -0.5, 0.0, 0.0], #Arg0
127 [1.0, 1.0, 0.5, 0.0, 0.5, 0.5], #Arg1
128 [-0.5, 0.0, 0.5, 1.0, 0.25, 0.4] #Arg2
133 'function_type': 'ttt',
135 [1.0, -1.0, 0.0, -0.0, 0.0], #Result
136 [0.5, -0.5, 0.0, -0.0, float("nan")] #Arg0
143 dirName
= os
.path
.join("cl", "builtin", "common")
146 functions
= sorted(tests
.keys())
147 for dataType
in DATA_TYPES
:
148 for fnName
in functions
:
149 testDefs
[(dataType
, fnName
)] = tests
[fnName
]
151 gen(DATA_TYPES
, CLC_VERSION_MIN
, functions
, testDefs
, dirName
)
154 if __name__
== '__main__':