opencl-types.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* GCC-StarPU
  2. Copyright (C) 2012 INRIA
  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. #include <sys/types.h> /* for `uint' & co. */
  21. /* Make sure `size_t' is flagged. */
  22. static void my_task (size_t size, int x[size])
  23. __attribute__ ((task));
  24. static void my_task_cpu (size_t size, int x[size])
  25. __attribute__ ((task_implementation ("cpu", my_task)));
  26. static void my_task_opencl (size_t size, int x[size]) /* (warning "size_t.*not.*known OpenCL type") */
  27. __attribute__ ((task_implementation ("opencl", my_task)));
  28. static void
  29. my_task_cpu (size_t size, int x[size])
  30. {
  31. }
  32. static void
  33. my_task_opencl (size_t size, int x[size])
  34. {
  35. }
  36. /* Make sure types that have the same name in C and OpenCL but are actually
  37. different are flagged. We assume `sizeof (long) == 4' here. */
  38. static void my_long_task (unsigned long size, int x[size])
  39. __attribute__ ((task));
  40. static void my_long_task_cpu (unsigned long size, int x[size])
  41. __attribute__ ((task_implementation ("cpu", my_long_task)));
  42. static void my_long_task_opencl (unsigned long size, /* (warning "differs from the same-named OpenCL type") */
  43. int x[size])
  44. __attribute__ ((task_implementation ("opencl", my_long_task)));
  45. static void
  46. my_long_task_cpu (unsigned long size, int x[size])
  47. {
  48. }
  49. static void
  50. my_long_task_opencl (unsigned long size, int x[size])
  51. {
  52. }
  53. /* Same with a pointer-to-long. */
  54. static void my_long_ptr_task (unsigned long *p)
  55. __attribute__ ((task));
  56. static void my_long_ptr_task_cpu (unsigned long *p)
  57. __attribute__ ((task_implementation ("cpu", my_long_ptr_task)));
  58. static void my_long_ptr_task_opencl (unsigned long *p) /* (warning "differs from the same-named OpenCL type") */
  59. __attribute__ ((task_implementation ("opencl", my_long_ptr_task)));
  60. static void
  61. my_long_ptr_task_cpu (unsigned long *p)
  62. {
  63. }
  64. static void
  65. my_long_ptr_task_opencl (unsigned long *p)
  66. {
  67. }
  68. /* Same with an array of unsigned chars. */
  69. static void my_uchar_task (char c[])
  70. __attribute__ ((task));
  71. static void my_uchar_task_cpu (char c[])
  72. __attribute__ ((task_implementation ("cpu", my_uchar_task)));
  73. static void my_uchar_task_opencl (char c[]) /* (warning "differs in signedness from the same-named OpenCL type") */
  74. __attribute__ ((task_implementation ("opencl", my_uchar_task)));
  75. static void
  76. my_uchar_task_cpu (char c[])
  77. {
  78. }
  79. static void
  80. my_uchar_task_opencl (char c[])
  81. {
  82. }
  83. /* "unsigned int" is aka. "uint". */
  84. static void my_uint_task (const uint *c)
  85. __attribute__ ((task));
  86. static void my_uint_task_cpu (const uint *c)
  87. __attribute__ ((task_implementation ("cpu", my_uint_task)));
  88. static void my_uint_task_opencl (const uint *c) /* no warning */
  89. __attribute__ ((task_implementation ("opencl", my_uint_task)));
  90. static void
  91. my_uint_task_cpu (const uint *c)
  92. {
  93. }
  94. static void
  95. my_uint_task_opencl (const uint *c)
  96. {
  97. }
  98. /* "unsigned char" is aka. "uchar". */
  99. typedef float uchar; /* not a real `uchar'! */
  100. static void my_fake_uchar_task (const uchar *c)
  101. __attribute__ ((task));
  102. static void my_fake_uchar_task_cpu (const uchar *c)
  103. __attribute__ ((task_implementation ("cpu", my_fake_uchar_task)));
  104. static void my_fake_uchar_task_opencl (const uchar *c) /* (warning "differs from the same-named OpenCL type") */
  105. __attribute__ ((task_implementation ("opencl", my_fake_uchar_task)));
  106. static void
  107. my_fake_uchar_task_cpu (const uchar *c)
  108. {
  109. }
  110. static void
  111. my_fake_uchar_task_opencl (const uchar *c)
  112. {
  113. }
  114. /* No OpenCL, no problems. */
  115. static void my_cool_task (size_t size, long long x[size])
  116. __attribute__ ((task));
  117. static void my_cool_task_cpu (size_t size, long long x[size])
  118. __attribute__ ((task_implementation ("cpu", my_cool_task)));
  119. static void
  120. my_cool_task_cpu (size_t size, long long x[size])
  121. {
  122. }