[Piglit] [PATCH v2 1/2] cl: Generate aligned vstorea tests

Jan Vesely jan.vesely at rutgers.edu
Thu Oct 5 15:51:05 UTC 2017


Add type3 vectors and bump required CLC to 1.1.
Simplify test to use only 1-2 vstore calls.
Zero the output buffer (fixes undefined values in results of some vstore
tests).

v2: Add canary after the written values

Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 generated_tests/gen_cl_vstore_tests.py | 142 ++++++++++++++++++++-------------
 1 file changed, 86 insertions(+), 56 deletions(-)

diff --git a/generated_tests/gen_cl_vstore_tests.py b/generated_tests/gen_cl_vstore_tests.py
index 93038aded..22b64d94b 100644
--- a/generated_tests/gen_cl_vstore_tests.py
+++ b/generated_tests/gen_cl_vstore_tests.py
@@ -29,7 +29,7 @@ from six.moves import range
 from modules import utils
 
 TYPES = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'half', 'float', 'double']
-VEC_SIZES = ['2', '4', '8', '16']
+VEC_SIZES = ['2', '3', '4', '8', '16']
 
 DIR_NAME = os.path.join("cl", "vstore")
 
@@ -47,15 +47,15 @@ def ext_req(type_name):
     return ""
 
 
-def begin_test(suffix, type_name, mem_type, vec_sizes, addr_space):
+def begin_test(suffix, type_name, mem_type, vec_sizes, addr_space, aligned):
     file_name = os.path.join(DIR_NAME, "vstore{}-{}-{}.cl".format(suffix, type_name, addr_space))
     print(file_name)
     f = open(file_name, 'w')
     f.write(textwrap.dedent(("""\
     /*!
     [config]
-    name: Vector store{suffix} {addr_space} {type_name}2,4,8,16
-    clc_version_min: 10
+    name: Vector store{suffix} {addr_space} {type_name}2,3,4,8,16
+    clc_version_min: 11
 
     dimensions: 1
     global_size: 1 0 0
@@ -63,21 +63,30 @@ def begin_test(suffix, type_name, mem_type, vec_sizes, addr_space):
     .format(type_name=type_name, addr_space=addr_space, suffix=suffix)))
     for s in vec_sizes:
         size = int(s) if s != '' else 1
+        modsize = 4 if size == 3 and aligned else size
+        offset = modsize if aligned else 1
+
         ty_name = type_name + s
         f.write(textwrap.dedent("""
         [test]
         name: vector store{suffix} {addr_space} {type_name}
         kernel_name: vstore{suffix}{n}_{addr_space}
-        arg_out: 0 buffer {mem_type}[{size}] 0 {gen_array}
+        arg_out: 0 buffer {mem_type}[{size}] {offset_zeros}{gen_array} 0x1.deadp0
+        arg_in: 0 buffer {mem_type}[{size}] {offset_size_zeros} 0x1.deadp0
         arg_in:  1 buffer {type_name}[1] {gen_array}
 
         [test]
         name: vector store{suffix} {addr_space} offset {type_name}
         kernel_name: vstore{suffix}{n}_{addr_space}_offset
-        arg_out: 0 buffer {mem_type}[{offset_size}] {zeros} {gen_array}
-        arg_in:  1 buffer {type_name}[1] {gen_array}
-        """.format(type_name=ty_name, mem_type=mem_type, size=size + 1,
-                   zeros=("0 " * (size + 1)), offset_size=size * 2 + 1, n=s,
+        arg_out: 0 buffer {mem_type}[{offset_size}] {offset_zeros} {gen_array} {padd_zeros} {gen_array} 0x1.deadp0
+        arg_in: 0 buffer {mem_type}[{offset_size}] {offset_modsize_size_zeros} 0x1.deadp0
+        arg_in: 1 buffer {type_name}[1] {gen_array}
+        """.format(type_name=ty_name, mem_type=mem_type, size=size + offset + 1,
+                   offset_zeros = ("0 " * offset),
+                   offset_size_zeros = ("0 " * (offset + size)),
+                   padd_zeros = ("0 " * (modsize - size)),
+                   offset_modsize_size_zeros = ("0 " * (modsize + size + offset)),
+                   offset_size=modsize + size + offset + 1, n=s,
                    gen_array=gen_array(size), suffix=suffix, addr_space=addr_space)))
 
     f.write(textwrap.dedent("""
@@ -94,124 +103,145 @@ def begin_test(suffix, type_name, mem_type, vec_sizes, addr_space):
     return f
 
 
-def gen_test_global(suffix, t, mem_type, vec_sizes):
-    f = begin_test(suffix, t, mem_type, vec_sizes, 'global')
+def gen_test_global(suffix, t, mem_type, vec_sizes, aligned):
+    f = begin_test(suffix, t, mem_type, vec_sizes, 'global', aligned)
     for s in vec_sizes:
+        offset = int(s) if aligned else 1
+        offset = 4 if offset == 3 else offset
+
         type_name = t + s
         f.write(textwrap.dedent("""
         kernel void vstore{suffix}{n}_global(global {mem_type} *out,
                                      global {type_name} *in) {{
             {type_name} tmp = in[0];
-            vstore{suffix}{n}(({type_name})0, 0, out);
-            vstore{suffix}{n}(tmp, 0, out + 1);
+            vstore{suffix}{n}(tmp, 0, out + {offset});
         }}
 
         kernel void vstore{suffix}{n}_global_offset(global {mem_type} *out,
                                             global {type_name} *in) {{
-            {type_name} tmp = ({type_name})0;
-            vstore{suffix}{n}(tmp, 0, out);
-            vstore{suffix}{n}(tmp, 0, out + 1);
-            tmp = in[0];
-            vstore{suffix}{n}(tmp, 1, out + 1);
+            {type_name} tmp = in[0];
+            vstore{suffix}{n}(tmp, 0, out + {offset});
+            vstore{suffix}{n}(tmp, 1, out + {offset});
         }}
-        """.format(type_name=type_name, mem_type=mem_type, n=s, suffix=suffix)))
+        """.format(type_name=type_name, mem_type=mem_type, n=s, suffix=suffix,
+                   offset=offset)))
 
     f.close()
 
 
-def gen_test_local_private(suffix, t, mem_type, vec_sizes, addr_space):
-    f = begin_test(suffix, t, mem_type, vec_sizes, addr_space)
+def gen_test_local_private(suffix, t, mem_type, vec_sizes, addr_space, aligned):
+    f = begin_test(suffix, t, mem_type, vec_sizes, addr_space, aligned)
     for s in vec_sizes:
         size = int(s) if s != '' else 1
+        modsize = 4 if size == 3 and aligned else size
+        offset = modsize if aligned else 1
+
         type_name = t + s
         f.write(textwrap.dedent("""
         kernel void vstore{suffix}{n}_{addr_space}(global {mem_type} *out,
                                      global {type_name} *in) {{
             {type_name} tmp = in[0];
             volatile {addr_space} {mem_type} loc[{size}];
-            vstore{suffix}{n}(({type_name})0, 0, ({addr_space} {mem_type}*)loc);
-            vstore{suffix}{n}(tmp, 0, ({addr_space} {mem_type}*)loc + 1);
+            for (int i = 0; i < {size}; ++i)
+                loc[i] = ({mem_type})0;
+
+            vstore{suffix}{n}(tmp, 0, ({addr_space} {mem_type}*)loc + {offset});
             for (int i = 0; i < {size}; ++i)
                 out[i] = loc[i];
         }}
 
         kernel void vstore{suffix}{n}_{addr_space}_offset(global {mem_type} *out,
                                             global {type_name} *in) {{
-            {type_name} tmp = ({type_name})0;
+            {type_name} tmp = in[0];
             volatile {addr_space} {mem_type} loc[{offset_size}];
-            vstore{suffix}{n}(tmp, 0, ({addr_space} {mem_type}*)loc);
-            vstore{suffix}{n}(tmp, 0, ({addr_space} {mem_type}*)loc + 1);
-            tmp = in[0];
-            vstore{suffix}{n}(tmp, 1, ({addr_space} {mem_type}*)loc + 1);
+            for (int i = 0; i < {offset_size}; ++i)
+                loc[i] = ({mem_type})0;
+
+            vstore{suffix}{n}(tmp, 0, ({addr_space} {mem_type}*)loc + {offset});
+            vstore{suffix}{n}(tmp, 1, ({addr_space} {mem_type}*)loc + {offset});
             for (int i = 0; i < {offset_size}; ++i)
                 out[i] = loc[i];
         }}
         """.format(type_name=type_name, mem_type=mem_type, n=s, suffix=suffix,
-                   offset_size=size * 2 + 1, size=size + 1, addr_space=addr_space)))
+                   offset_size=size + modsize + offset, size=size + offset,
+                   addr_space=addr_space, offset=offset)))
 
     f.close()
 
 
-# vstore_half is special, becuase CLC won't allow us to use half type without
+# vstore_half is special, because CLC won't allow us to use half type without
 # cl_khr_fp16
-def gen_test_local_private_half(suffix, t, vec_sizes, addr_space):
-    f = begin_test(suffix, t, 'half', vec_sizes, addr_space)
+def gen_test_local_private_half(suffix, t, vec_sizes, addr_space, aligned):
+    f = begin_test(suffix, t, 'half', vec_sizes, addr_space, aligned)
     for s in vec_sizes:
         size = int(s) if s != '' else 1
+        modsize = 4 if size == 3 and aligned else size
+        offset = modsize if aligned else 1
+
         type_name = t + s
         f.write(textwrap.dedent("""
         kernel void vstore{suffix}{n}_{addr_space}(global half *out,
                                      global {type_name} *in) {{
             {type_name} tmp = in[0];
             volatile {addr_space} short loc[{size}];
-            vstore{suffix}{n}(({type_name})0, 0, ({addr_space} half*)loc);
-            vstore{suffix}{n}(tmp, 0, ({addr_space} half*)loc + 1);
+            for (int i = 0; i < {size}; ++i)
+                loc[i] = 0;
+
+            vstore{suffix}{n}(tmp, 0, ({addr_space} half*)loc + {offset});
+
             for (int i = 0; i < {size}; ++i)
                 ((global short *)out)[i] = loc[i];
         }}
 
         kernel void vstore{suffix}{n}_{addr_space}_offset(global half *out,
                                             global {type_name} *in) {{
-            {type_name} tmp = ({type_name})0;
+            {type_name} tmp = in[0];
             volatile {addr_space} short loc[{offset_size}];
-            vstore{suffix}{n}(tmp, 0, ({addr_space} half*)loc);
-            vstore{suffix}{n}(tmp, 0, ({addr_space} half*)loc + 1);
-            tmp = in[0];
-            vstore{suffix}{n}(tmp, 1, ({addr_space} half*)loc + 1);
+            for (int i = 0; i < {offset_size}; ++i)
+                loc[i] = 0;
+
+            vstore{suffix}{n}(tmp, 0, ({addr_space} half*)loc + {offset});
+            vstore{suffix}{n}(tmp, 1, ({addr_space} half*)loc + {offset});
+
             for (int i = 0; i < {offset_size}; ++i)
                 ((global short *)out)[i] = loc[i];
         }}
         """.format(type_name=type_name, n=s, suffix=suffix,
-                   offset_size=size * 2 + 1, size=size + 1, addr_space=addr_space)))
+                   offset_size=size + modsize + offset, size=size + offset,
+                   addr_space=addr_space, offset=offset)))
 
 
-def gen_test_local(suffix, t, mem_type, vec_sizes):
+def gen_test_local(suffix, t, mem_type, vec_sizes, aligned):
     if mem_type == 'half':
-        gen_test_local_private_half(suffix, t, vec_sizes, 'local')
+        gen_test_local_private_half(suffix, t, vec_sizes, 'local', aligned)
     else:
-        gen_test_local_private(suffix, t, mem_type, vec_sizes, 'local')
+        gen_test_local_private(suffix, t, mem_type, vec_sizes, 'local', aligned)
 
 
-def gen_test_private(suffix, t, mem_type, vec_sizes):
+def gen_test_private(suffix, t, mem_type, vec_sizes, aligned):
     if mem_type == 'half':
-        gen_test_local_private_half(suffix, t, vec_sizes, 'private')
+        gen_test_local_private_half(suffix, t, vec_sizes, 'private', aligned)
     else:
-        gen_test_local_private(suffix, t, mem_type, vec_sizes, 'private')
+        gen_test_local_private(suffix, t, mem_type, vec_sizes, 'private', aligned)
 
 
 def main():
     utils.safe_makedirs(DIR_NAME)
     for t in TYPES:
-        gen_test_global('', t, t, VEC_SIZES);
-        gen_test_local('', t, t, VEC_SIZES);
-        gen_test_private('', t, t, VEC_SIZES);
-
-    gen_test_global('_half', 'float',  'half', [''] + VEC_SIZES);
-    gen_test_global('_half', 'double', 'half', [''] + VEC_SIZES);
-    gen_test_local('_half', 'float',  'half', [''] + VEC_SIZES);
-    gen_test_local('_half', 'double', 'half', [''] + VEC_SIZES);
-    gen_test_private('_half', 'float',  'half', [''] + VEC_SIZES);
-    gen_test_private('_half', 'double', 'half', [''] + VEC_SIZES);
+        gen_test_global('', t, t, VEC_SIZES, False);
+        gen_test_local('', t, t, VEC_SIZES, False);
+        gen_test_private('', t, t, VEC_SIZES, False);
+
+    for aligned in False, True:
+        suffix = "a_half" if aligned else "_half"
+        vec_sizes = VEC_SIZES if aligned else [''] + VEC_SIZES
+
+        gen_test_global(suffix, 'float',  'half', vec_sizes, aligned);
+        gen_test_global(suffix, 'double', 'half', vec_sizes, aligned);
+        gen_test_local(suffix, 'float',  'half', vec_sizes, aligned);
+        gen_test_local(suffix, 'double', 'half', vec_sizes, aligned);
+        gen_test_private(suffix, 'float',  'half', vec_sizes, aligned);
+        gen_test_private(suffix, 'double', 'half', vec_sizes, aligned);
 
 
 if __name__ == '__main__':
-- 
2.13.6



More information about the Piglit mailing list