[PATCH 62/90] add test test_ucharn.cl
authorAndreas Beckmann <anbe@debian.org>
Thu, 2 Dec 2021 15:02:44 +0000 (16:02 +0100)
committerAndreas Beckmann <anbe@debian.org>
Fri, 7 Jan 2022 23:55:22 +0000 (23:55 +0000)
this is primarily intended for inspecting the disassembled kernel
to debug parameter passing issues

Gbp-Pq: Name 0062-add-test-test_ucharn.cl.patch

tests/kernel/CMakeLists.txt
tests/kernel/test_ucharn.cl [new file with mode: 0644]
tests/kernel/test_ucharn_expout.txt [new file with mode: 0644]

index 5bbe48ae18266998eea9210ffe6442cb9d671fe6..e6d5b8998d40c9a0cf392edfd769a40d17b9d6f4 100644 (file)
@@ -218,6 +218,10 @@ add_test_pocl(NAME "kernel/test_shuffle_ulong"
 
 ######################################################################
 
+add_test_pocl(NAME "kernel/test_ucharn"
+              EXPECTED_OUTPUT "test_ucharn_expout.txt"
+              COMMAND "kernel" "test_ucharn")
+
 add_test_pocl(NAME "kernel/test_printf"
               EXPECTED_OUTPUT "test_printf_expout.txt"
               COMMAND "kernel" "test_printf")
diff --git a/tests/kernel/test_ucharn.cl b/tests/kernel/test_ucharn.cl
new file mode 100644 (file)
index 0000000..c1a2173
--- /dev/null
@@ -0,0 +1,84 @@
+int f2(uchar2 uc2, int z) __attribute__((noinline));
+int f2(uchar2 uc2, int z)
+{
+int s = uc2.x + uc2.y;
+return s ^ z;
+}
+
+int g2() __attribute__((noinline));
+int g2()
+{
+uchar2 uc2 = (uchar2)(0x18, 0x29);
+return f2(uc2, 0x12345678) ^ 0x12345678;
+}
+
+int f3(uchar3 uc3, int z) __attribute__((noinline));
+int f3(uchar3 uc3, int z)
+{
+int s = uc3.x + uc3.y + uc3.z;
+return s ^ z;
+}
+
+int g3() __attribute__((noinline));
+int g3()
+{
+uchar3 uc3 = (uchar3)(0x18, 0x29, 0x3a);
+return f3(uc3, 0x12345678) ^ 0x12345678;
+}
+
+int f4(uchar4 uc4, int z) __attribute__((noinline));
+int f4(uchar4 uc4, int z)
+{
+int s = uc4.x + uc4.y + uc4.z + uc4.w;
+return s ^ z;
+}
+
+int g4() __attribute__((noinline));
+int g4()
+{
+uchar4 uc4 = (uchar4)(0x18, 0x29, 0x3a, 0x4b);
+return f4(uc4, 0x12345678) ^ 0x12345678;
+}
+
+int f8(uchar8 uc8, int z) __attribute__((noinline));
+int f8(uchar8 uc8, int z)
+{
+int s = uc8.s0 + uc8.s1 + uc8.s2 + uc8.s3 + uc8.s4 + uc8.s5 + uc8.s6 + uc8.s7;
+return s ^ z;
+}
+
+int g8() __attribute__((noinline));
+int g8()
+{
+uchar8 uc8 = (uchar8)(0x18, 0x29, 0x3a, 0x4b, 0x5c, 0x6d, 0x7e, 0x8f);
+return f8(uc8, 0x12345678) ^ 0x12345678;
+}
+
+int f16(uchar16 uc16, int z) __attribute__((noinline));
+int f16(uchar16 uc16, int z)
+{
+int s = uc16.s0 + uc16.s1 + uc16.s2 + uc16.s3 + uc16.s4 + uc16.s5 + uc16.s6 + uc16.s7 + uc16.s8 + uc16.s9 + uc16.sa + uc16.sb + uc16.sc + uc16.sd + uc16.se + uc16.sf;
+return s ^ z;
+}
+
+int g16() __attribute__((noinline));
+int g16()
+{
+uchar16 uc16 = (uchar16)(0x18, 0x29, 0x3a, 0x4b, 0x5c, 0x6d, 0x7e, 0x8f, 0xa1, 0xb2, 0xc3, 0xd4, 0xe5, 0xf6, 0x17, 0x28);
+return f16(uc16, 0x12345678) ^ 0x12345678;
+}
+
+kernel void test_ucharn()
+{
+  printf("uchar2  %8x\n", f2((uchar2)(0), 0));
+  printf("uchar3  %8x\n", f3((uchar3)(0), 0));
+  printf("uchar4  %8x\n", f4((uchar4)(0), 0));
+  printf("uchar8  %8x\n", f8((uchar8)(0), 0));
+  printf("uchar16 %8x\n", f16((uchar16)(0), 0));
+
+  printf("uchar2  %8x\n", g2());
+  printf("uchar3  %8x\n", g3());
+  printf("uchar4  %8x\n", g4());
+  printf("uchar8  %8x\n", g8());
+  printf("uchar16 %8x\n", g16());
+}
diff --git a/tests/kernel/test_ucharn_expout.txt b/tests/kernel/test_ucharn_expout.txt
new file mode 100644 (file)
index 0000000..15152ff
--- /dev/null
@@ -0,0 +1,12 @@
+Running test test_ucharn...
+uchar2         0
+uchar3         0
+uchar4         0
+uchar8         0
+uchar16        0
+uchar2        41
+uchar3        7b
+uchar4        c6
+uchar8       29c
+uchar16      7a0
+OK