framework: move atexit call closer to init
[piglit.git] / generated_tests / gen_cl_common_builtins.py
blob33c8890786accc1279da51b61fd2fbae277c0d8f
1 # coding=utf-8
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
13 # Software.
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
21 # SOFTWARE.
23 # Authors: Tom Stellard <thomas.stellard@amd.com>
24 # Aaron Watry <awatry@gmail.com>
27 import os
29 from genclbuiltins import gen, NEGNAN
30 from math import radians, degrees, pi
32 CLC_VERSION_MIN = {
33 'clamp' : 10,
34 'degrees' : 10,
35 'max' : 10,
36 'min' : 10,
37 'mix' : 10,
38 'radians' : 10,
39 'step' : 10,
40 'smoothstep' : 10,
41 'sign' : 10
44 DATA_TYPES = ['float']
46 F = {
47 'float' : 'float'
50 I = {
51 'float' : 'int'
54 tests = {
55 'clamp' : {
56 'arg_types': [F, F, F, F],
57 'function_type': 'tss',
58 'values': [
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
65 'degrees' : {
66 'arg_types': [F, F],
67 'function_type': 'ttt',
68 'values': [
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
72 'tolerance' : 2
74 'max' : {
75 'arg_types': [F, F, F],
76 'function_type': 'tss',
77 'values': [
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
83 'min' : {
84 'arg_types': [F, F, F],
85 'function_type': 'tss',
86 'values': [
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',
95 'values': [
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
102 'radians' : {
103 'arg_types': [F, F],
104 'function_type': 'ttt',
105 'values': [
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?)
111 'step' : {
112 'arg_types': [F, F, F],
113 'function_type': 'ttt',
114 'values': [
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?)
121 'smoothstep' : {
122 'arg_types': [F, F, F, F],
123 'function_type': 'ttt',
124 'values': [
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
131 'sign' : {
132 'arg_types': [F, F],
133 'function_type': 'ttt',
134 'values': [
135 [1.0, -1.0, 0.0, -0.0, 0.0], #Result
136 [0.5, -0.5, 0.0, -0.0, float("nan")] #Arg0
142 def main():
143 dirName = os.path.join("cl", "builtin", "common")
145 testDefs = {}
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__':
155 main()