tests: add ext_image_dma_buf_import-tex-modifier
[piglit.git] / generated_tests / gen_cl_store_tests.py
blob2121f19198a530828dd02d0ac88b41090e8918a4
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 import os
28 import textwrap
30 from modules import utils
32 TYPES = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'float', 'double']
33 VEC_SIZES = ['', '2', '4', '8', '16']
35 dirName = os.path.join("cl", "store")
38 def gen_array(size):
39 return ' '.join([str(i) for i in range(size * 8)])
42 def ext_req(type_name):
43 if type_name[:6] == "double":
44 return "require_device_extensions: cl_khr_fp64"
45 return ""
48 def print_config(f, type_name, addr_space):
49 f.write(textwrap.dedent(("""
50 [config]
51 name: Store {type_name}
52 program_source_file: store-kernels-{addr_space}.inc
53 build_options: -D TYPE={type_name}
54 dimensions: 1
55 """ + ext_req(type_name))
56 .format(type_name=type_name, addr_space=addr_space)))
59 def begin_test(type_name, addr_space):
60 fileName = os.path.join(dirName, 'store-' + type_name + '-' + addr_space + '.program_test')
61 print(fileName)
62 f = open(fileName, 'w')
63 print_config(f, type_name, addr_space)
64 return f
67 def main():
68 utils.safe_makedirs(dirName)
70 for t in TYPES:
71 for s in VEC_SIZES:
72 if s == '':
73 size = 1
74 else:
75 size = int(s)
76 type_name = t + s
77 f = begin_test(type_name, 'global')
78 f.write(textwrap.dedent("""
79 [test]
80 name: global address space
81 global_size: 1 0 0
82 kernel_name: store_global
83 arg_out: 0 buffer {type_name}[8] {gen_array}
84 arg_in: 1 buffer {type_name}[8] {gen_array}
85 [test]
86 name: global address space work items
87 global_size: 8 0 0
88 kernel_name: store_global_wi
89 arg_out: 0 buffer {type_name}[8] {gen_array}
90 arg_in: 1 buffer {type_name}[8] {gen_array}
91 """.format(type_name=type_name, gen_array=gen_array(size))))
93 f.close()
95 f = begin_test(type_name, 'local')
96 f.write(textwrap.dedent("""
97 [test]
98 name: local address space
99 global_size: 8 0 0
100 local_size: 8 0 0
101 kernel_name: store_local
102 arg_out: 0 buffer {type_name}[8] {gen_array}
103 arg_in: 1 buffer {type_name}[8] {gen_array}
104 """.format(type_name=type_name, gen_array=gen_array(size))))
106 f.close()
109 if __name__ == '__main__':
110 main()