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>
27 from __future__
import print_function
, division
, absolute_import
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")
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"
51 def print_config(f
, type_name
, addr_space
):
52 f
.write(textwrap
.dedent(("""
54 name: Store {type_name}
55 program_source_file: store-kernels-{addr_space}.inc
56 build_options: -D TYPE={type_name}
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')
65 f
= open(fileName
, 'w')
66 print_config(f
, type_name
, addr_space
)
71 utils
.safe_makedirs(dirName
)
80 f
= begin_test(type_name
, 'global')
81 f
.write(textwrap
.dedent("""
83 name: global address space
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}
89 name: global address space work items
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
))))
98 f
= begin_test(type_name
, 'local')
99 f
.write(textwrap
.dedent("""
101 name: local address space
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
))))
112 if __name__
== '__main__':