[PATCH 3/4] fix test_structs_as_args on i386
authorAndreas Beckmann <anbe@debian.org>
Wed, 24 Nov 2021 13:14:17 +0000 (14:14 +0100)
committerAndreas Beckmann <anbe@debian.org>
Tue, 12 Dec 2023 15:33:19 +0000 (16:33 +0100)
 141/143 Test  #85: regression/struct_kernel_arguments ..................................................***Failed  Error regular expression found in output. Regex=[FAIL]  4.58 sec
 CMake Error at /build/pocl-1.4/cmake/run_test.cmake:34 (message):
  FAIL: Test exited with nonzero code (1):
  /build/pocl-1.4/obj-i686-linux-gnu/tests/regression/test_structs_as_args

  STDOUT:

  F(4: 0 != 5) F(5: -2147483648 != 6) F(6: 0 != 7) F(7: 0 != 8)

  STDERR:

 -- OK

on i386, the default alignment is 4 for 64-bit types, too

the OpenCL standard is only explicit about alignment requirements for
OpenCL types, but not for the corresponding cl_* types in C
https://github.com/KhronosGroup/OpenCL-Headers/issues/149

fixes: #801

Gbp-Pq: Name 0003-fix-test_structs_as_args-on-i386.patch

tests/regression/test_structs_as_args.cpp

index 36985fec89c7e63d9d0c18ee32e4854e2c90654c..6688052aef562e46ab73204e221710b2dd15b0ab 100644 (file)
@@ -54,17 +54,26 @@ struct int_pair {
     cl_long b;\r
 };\r
 \r
+// i386 has a default alignment of 4 even for 64-bit types\r
+#ifdef __i386__\r
+#define CL_LONG_ALIGNMENT __attribute__((aligned(8)))\r
+#else\r
+#define CL_LONG_ALIGNMENT\r
+#endif\r
+\r
 struct test_struct {\r
     cl_int elementA;\r
     cl_int elementB;\r
-    cl_long elementC;\r
+    cl_long elementC CL_LONG_ALIGNMENT;\r
     cl_char elementD;\r
-    cl_long elementE;\r
+    cl_long elementE CL_LONG_ALIGNMENT;\r
     cl_float elementF;\r
     cl_short elementG;\r
-    cl_long elementH;\r
+    cl_long elementH CL_LONG_ALIGNMENT;\r
 };\r
 \r
+#undef CL_LONG_ALIGNMENT\r
+\r
 static char\r
 kernelSourceCode[] = \r
 "typedef struct int_single {\n"\r