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>
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")
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"
48 def print_config(f
, type_name
, addr_space
):
49 f
.write(textwrap
.dedent(("""
51 name: Store {type_name}
52 program_source_file: store-kernels-{addr_space}.inc
53 build_options: -D TYPE={type_name}
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')
62 f
= open(fileName
, 'w')
63 print_config(f
, type_name
, addr_space
)
68 utils
.safe_makedirs(dirName
)
77 f
= begin_test(type_name
, 'global')
78 f
.write(textwrap
.dedent("""
80 name: global address space
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}
86 name: global address space work items
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
))))
95 f
= begin_test(type_name
, 'local')
96 f
.write(textwrap
.dedent("""
98 name: local address space
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
))))
109 if __name__
== '__main__':