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
74 'arg_types': [F
, F
, F
],
75 'function_type': 'tss',
77 [1.0, 0.0, 0.0, 0.0 ], #Result
78 [1.0, -0.5, 0.0, 0.0 ], #Arg0
79 [0.0, 0.0, 0.0, -0.5 ] #Arg1
83 'arg_types': [F
, F
, F
],
84 'function_type': 'tss',
86 [0.0, -0.5, 0.0, -0.5 ], #Result
87 [1.0, -0.5, 0.0, 0.0 ], #Arg0
88 [0.0, 0.0, 0.0, -0.5 ] #Arg1
91 'mix' : { #x + (y - x) * a
92 'arg_types': [F
, F
, F
, F
],
93 'function_type': 'tts',
95 [0.5, -0.25, 0.0, -0.5, 1.0, 3.0, 10.0, float("nan"), float("nan"), float("nan")], #Result
96 [1.0, -0.5, 0.0, 0.0, 1.0, 4.0, 15.0, 5.0, 4.0, float("nan")], #Arg0
97 [0.0, 0.0, 0.0, -0.5, 2.0, 2.0, 10.0, -0.2, float("nan"), 1.5], #Arg1
98 [0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 1.0, float("nan"), 1.0, 0.0], #Arg2
103 'function_type': 'ttt',
105 [0.5, -0.5, pi
, 0.0, 2*pi
, 10*pi
, 100*pi
, pi
/2], #Result
106 [degrees(0.5), degrees(-0.5), 180.0, 0.0, 360, 1800.0, 18000, 90] #Arg0
109 #TODO Add scalar combination (tst?)
111 'arg_types': [F
, F
, F
],
112 'function_type': 'ttt',
114 [0.0, 1.0, 1.0, 0.0, 1.0, 1.0], #Result
115 [1.0, -0.5, 0.0, 0.0, 1.0, float("nan")], #Arg0
116 [0.0, 0.0, 0.0, -0.5, float("nan"), 1.0] #Arg1
119 #TODO Add scalar combination (tst?)
121 'arg_types': [F
, F
, F
, F
],
122 'function_type': 'ttt',
124 [0.0, 0.0, 1.0, 1.0, 0.5, 0.896], #Result
125 [0.0, 0.0, 0.0, -0.5, 0.0, 0.0], #Arg0
126 [1.0, 1.0, 0.5, 0.0, 0.5, 0.5], #Arg1
127 [-0.5, 0.0, 0.5, 1.0, 0.25, 0.4] #Arg2
132 'function_type': 'ttt',
134 [1.0, -1.0, 0.0, -0.0, 0.0], #Result
135 [0.5, -0.5, 0.0, -0.0, float("nan")] #Arg0
142 dirName
= os
.path
.join("cl", "builtin", "common")
145 functions
= sorted(tests
.keys())
146 for dataType
in DATA_TYPES
:
147 for fnName
in functions
:
148 testDefs
[(dataType
, fnName
)] = tests
[fnName
]
150 gen(DATA_TYPES
, CLC_VERSION_MIN
, functions
, testDefs
, dirName
)
153 if __name__
== '__main__':