opencl-types.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* GCC-StarPU
  2. Copyright (C) 2012 Institut National de Recherche en Informatique et Automatique
  3. GCC-StarPU is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. GCC-StarPU is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with GCC-StarPU. If not, see <http://www.gnu.org/licenses/>. */
  13. /* Make sure use of `size_t' as a task argument type is flagged. */
  14. /* (instructions compile) */
  15. #undef NDEBUG
  16. /* Please gimme a broken `cl_long'! */
  17. #define BREAK_CL_LONG
  18. #include <mocks.h>
  19. #include <unistd.h>
  20. /* Make sure `size_t' is flagged. */
  21. static void my_task (size_t size, int x[size])
  22. __attribute__ ((task));
  23. static void my_task_cpu (size_t size, int x[size])
  24. __attribute__ ((task_implementation ("cpu", my_task)));
  25. static void my_task_opencl (size_t size, int x[size]) /* (warning "size_t.*not.*known OpenCL type") */
  26. __attribute__ ((task_implementation ("opencl", my_task)));
  27. static void
  28. my_task_cpu (size_t size, int x[size])
  29. {
  30. }
  31. static void
  32. my_task_opencl (size_t size, int x[size])
  33. {
  34. }
  35. /* Make sure types that have the same name in C and OpenCL but are actually
  36. different are flagged. We assume `sizeof (long) == 4' here. */
  37. static void my_long_task (unsigned long size, int x[size])
  38. __attribute__ ((task));
  39. static void my_long_task_cpu (unsigned long size, int x[size])
  40. __attribute__ ((task_implementation ("cpu", my_long_task)));
  41. static void my_long_task_opencl (unsigned long size, /* (warning "differs from the same-named OpenCL type") */
  42. int x[size])
  43. __attribute__ ((task_implementation ("opencl", my_long_task)));
  44. static void
  45. my_long_task_cpu (unsigned long size, int x[size])
  46. {
  47. }
  48. static void
  49. my_long_task_opencl (unsigned long size, int x[size])
  50. {
  51. }
  52. /* Same with a pointer-to-long. */
  53. static void my_long_ptr_task (unsigned long *p)
  54. __attribute__ ((task));
  55. static void my_long_ptr_task_cpu (unsigned long *p)
  56. __attribute__ ((task_implementation ("cpu", my_long_ptr_task)));
  57. static void my_long_ptr_task_opencl (unsigned long *p) /* (warning "differs from the same-named OpenCL type") */
  58. __attribute__ ((task_implementation ("opencl", my_long_ptr_task)));
  59. static void
  60. my_long_ptr_task_cpu (unsigned long *p)
  61. {
  62. }
  63. static void
  64. my_long_ptr_task_opencl (unsigned long *p)
  65. {
  66. }
  67. /* Same with an array of unsigned chars. */
  68. static void my_uchar_task (char c[])
  69. __attribute__ ((task));
  70. static void my_uchar_task_cpu (char c[])
  71. __attribute__ ((task_implementation ("cpu", my_uchar_task)));
  72. static void my_uchar_task_opencl (char c[]) /* (warning "differs in signedness from the same-named OpenCL type") */
  73. __attribute__ ((task_implementation ("opencl", my_uchar_task)));
  74. static void
  75. my_uchar_task_cpu (char c[])
  76. {
  77. }
  78. static void
  79. my_uchar_task_opencl (char c[])
  80. {
  81. }
  82. /* No OpenCL, no problems. */
  83. static void my_cool_task (size_t size, long long x[size])
  84. __attribute__ ((task));
  85. static void my_cool_task_cpu (size_t size, long long x[size])
  86. __attribute__ ((task_implementation ("cpu", my_cool_task)));
  87. static void
  88. my_cool_task_cpu (size_t size, long long x[size])
  89. {
  90. }