Quellcode durchsuchen

gcc: Recognize `uchar', `uint', and `ulong' as valid OpenCL types.

* gcc-plugin/src/starpu.c (validate_opencl_argument_type)[type_map]: Add
  `uchar', `uint', and `ulong'.

* gcc-plugin/tests/opencl-types.c (my_uint_task, my_uint_task_cpu,
  my_uint_task_opencl, my_fake_uchar_task, my_fake_uchar_task_cpu,
  my_fake_uchar_task_opencl): New functions.
  (uchar): New typedef.
Ludovic Courtès vor 13 Jahren
Ursprung
Commit
6bb7dcd767
2 geänderte Dateien mit 49 neuen und 0 gelöschten Zeilen
  1. 5 0
      gcc-plugin/src/starpu.c
  2. 44 0
      gcc-plugin/tests/opencl-types.c

+ 5 - 0
gcc-plugin/src/starpu.c

@@ -1027,14 +1027,19 @@ validate_opencl_argument_type (location_t loc, const_tree type)
 	  static const struct { const char *c; const char *cl; }
 	  type_map[] =
 	    {
+	      /* Scalar types defined in OpenCL 1.2.  See
+		 <http://www.khronos.org/files/opencl-1-2-quick-reference-card.pdf>.  */
 	      { "char", "cl_char" },
 	      { "unsigned char", "cl_uchar" },
+	      { "uchar", "cl_uchar" },
 	      { "short int", "cl_short" },
 	      { "unsigned short", "cl_ushort" },
 	      { "int", "cl_int" },
 	      { "unsigned int", "cl_uint" },
+	      { "uint", "cl_uint" },
 	      { "long int", "cl_long" },
 	      { "long unsigned int", "cl_ulong" },
+	      { "ulong", "cl_ulong" },
 	      { "float", "cl_float" },
 	      { "double", "cl_double" },
 	      { NULL, NULL }

+ 44 - 0
gcc-plugin/tests/opencl-types.c

@@ -25,6 +25,7 @@
 
 #include <mocks.h>
 #include <unistd.h>
+#include <sys/types.h>				  /* for `uint' & co. */
 
 
 /* Make sure `size_t' is flagged.  */
@@ -113,6 +114,49 @@ my_uchar_task_opencl (char c[])
 }
 
 
+/* "unsigned int" is aka. "uint".  */
+
+static void my_uint_task (const uint *c)
+  __attribute__ ((task));
+static void my_uint_task_cpu (const uint *c)
+  __attribute__ ((task_implementation ("cpu", my_uint_task)));
+static void my_uint_task_opencl (const uint *c)	  /* no warning */
+  __attribute__ ((task_implementation ("opencl", my_uint_task)));
+
+static void
+my_uint_task_cpu (const uint *c)
+{
+}
+
+static void
+my_uint_task_opencl (const uint *c)
+{
+}
+
+
+/* "unsigned char" is aka. "uchar".  */
+
+typedef float uchar;				  /* not a real `uchar'! */
+
+static void my_fake_uchar_task (const uchar *c)
+  __attribute__ ((task));
+static void my_fake_uchar_task_cpu (const uchar *c)
+  __attribute__ ((task_implementation ("cpu", my_fake_uchar_task)));
+static void my_fake_uchar_task_opencl (const uchar *c) /* (warning "differs from the same-named OpenCL type") */
+  __attribute__ ((task_implementation ("opencl", my_fake_uchar_task)));
+
+static void
+my_fake_uchar_task_cpu (const uchar *c)
+{
+}
+
+static void
+my_fake_uchar_task_opencl (const uchar *c)
+{
+}
+
+
+
 /* No OpenCL, no problems.  */
 
 static void my_cool_task (size_t size, long long x[size])