ext_gpu_shader4: add compiler tests for everything
[piglit.git] / generated_tests / gen_cl_store_tests.py
blobfd515c3ac2628d5d2b46007d32c32dd50c0e62cc
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>
27 from __future__ import print_function, division, absolute_import
28 import os
29 import textwrap
31 from six.moves import range
33 from modules import utils
35 TYPES = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'float', 'double']
36 VEC_SIZES = ['', '2', '4', '8', '16']
38 dirName = os.path.join("cl", "store")
41 def gen_array(size):
42 return ' '.join([str(i) for i in range(size * 8)])
45 def ext_req(type_name):
46 if type_name[:6] == "double":
47 return "require_device_extensions: cl_khr_fp64"
48 return ""
51 def print_config(f, type_name, addr_space):
52 f.write(textwrap.dedent(("""
53 [config]
54 name: Store {type_name}
55 program_source_file: store-kernels-{addr_space}.inc
56 build_options: -D TYPE={type_name}
57 dimensions: 1
58 """ + ext_req(type_name))
59 .format(type_name=type_name, addr_space=addr_space)))
62 def begin_test(type_name, addr_space):
63 fileName = os.path.join(dirName, 'store-' + type_name + '-' + addr_space + '.program_test')
64 print(fileName)
65 f = open(fileName, 'w')
66 print_config(f, type_name, addr_space)
67 return f
70 def main():
71 utils.safe_makedirs(dirName)
73 for t in TYPES:
74 for s in VEC_SIZES:
75 if s == '':
76 size = 1
77 else:
78 size = int(s)
79 type_name = t + s
80 f = begin_test(type_name, 'global')
81 f.write(textwrap.dedent("""
82 [test]
83 name: global address space
84 global_size: 1 0 0
85 kernel_name: store_global
86 arg_out: 0 buffer {type_name}[8] {gen_array}
87 arg_in: 1 buffer {type_name}[8] {gen_array}
88 [test]
89 name: global address space work items
90 global_size: 8 0 0
91 kernel_name: store_global_wi
92 arg_out: 0 buffer {type_name}[8] {gen_array}
93 arg_in: 1 buffer {type_name}[8] {gen_array}
94 """.format(type_name=type_name, gen_array=gen_array(size))))
96 f.close()
98 f = begin_test(type_name, 'local')
99 f.write(textwrap.dedent("""
100 [test]
101 name: local address space
102 global_size: 8 0 0
103 local_size: 8 0 0
104 kernel_name: store_local
105 arg_out: 0 buffer {type_name}[8] {gen_array}
106 arg_in: 1 buffer {type_name}[8] {gen_array}
107 """.format(type_name=type_name, gen_array=gen_array(size))))
109 f.close()
112 if __name__ == '__main__':
113 main()