Commit b1bce973 authored by Dylan Baker's avatar Dylan Baker

generators: use if __name__ == __main__ pattern in cl generators

This means that they only generate tests if they are called as the main
script, but not if they are imported as modules. This is important for
testing purposes.
Signed-off-by: default avatarDylan Baker <dylanx.c.baker@intel.com>
Reviewed-by: Jordan Justen's avatarJordan Justen <jordan.l.justen@intel.com>
parent 104171cf
......@@ -560,4 +560,6 @@ def main():
gen(DATA_TYPES, CLC_VERSION_MIN, functions, testDefs, dirName)
main()
if __name__ == '__main__':
main()
......@@ -402,4 +402,5 @@ def main():
gen(DATA_TYPES, CLC_VERSION_MIN, functions, testDefs, dirName)
main()
if __name__ == '__main__':
main()
......@@ -191,4 +191,5 @@ def main():
gen(DATA_TYPES, CLC_VERSION_MIN, functions, testDefs, dirName)
main()
if __name__ == '__main__':
main()
......@@ -63,40 +63,45 @@ def begin_test(type_name, addr_space):
return f
for t in TYPES:
for s in VEC_SIZES:
if s == '':
size = 1
else:
size = int(s)
type_name = t + s
f = begin_test(type_name, 'global')
f.write(textwrap.dedent("""
[test]
name: global address space
global_size: 1 0 0
kernel_name: store_global
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
[test]
name: global address space work items
global_size: 8 0 0
kernel_name: store_global_wi
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
""".format(type_name=type_name, gen_array=gen_array(size))))
f.close()
f = begin_test(type_name, 'local')
f.write(textwrap.dedent("""
[test]
name: local address space
global_size: 8 0 0
local_size: 8 0 0
kernel_name: store_local
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
""".format(type_name=type_name, gen_array=gen_array(size))))
f.close()
def main():
for t in TYPES:
for s in VEC_SIZES:
if s == '':
size = 1
else:
size = int(s)
type_name = t + s
f = begin_test(type_name, 'global')
f.write(textwrap.dedent("""
[test]
name: global address space
global_size: 1 0 0
kernel_name: store_global
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
[test]
name: global address space work items
global_size: 8 0 0
kernel_name: store_global_wi
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
""".format(type_name=type_name, gen_array=gen_array(size))))
f.close()
f = begin_test(type_name, 'local')
f.write(textwrap.dedent("""
[test]
name: local address space
global_size: 8 0 0
local_size: 8 0 0
kernel_name: store_local
arg_out: 0 buffer {type_name}[8] {gen_array}
arg_in: 1 buffer {type_name}[8] {gen_array}
""".format(type_name=type_name, gen_array=gen_array(size))))
f.close()
if __name__ == '__main__':
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment