task-errors.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* GCC-StarPU
  2. Copyright (C) 2011, 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. /* Test error handling for the `task' and `task_implementation' attributes. */
  14. extern void my_external_task (int foo, char *bar) __attribute__ ((task));
  15. static void my_task (int foo, char *bar) __attribute__ ((task));
  16. static void my_task_cpu (int foo, float *bar) /* (error "type differs") */
  17. __attribute__ ((task_implementation ("cpu", my_task)));
  18. static void my_task_opencl (long foo, char *bar) /* (error "type differs") */
  19. __attribute__ ((task_implementation ("opencl", my_task)));
  20. static void my_task_nowhere (int foo, char *bar) /* (warning "unsupported target") */
  21. __attribute__ ((task_implementation ("does-not-exist", my_task)));
  22. static void my_task_not_quite (int foo, char *bar) /* (error "lacks the 'task' attribute") */
  23. __attribute__ ((task_implementation ("cpu", my_task_nowhere)));
  24. static int foo /* (error "only applies to function") */
  25. __attribute__ ((task_implementation ("cpu", my_task)));
  26. static int bar /* (error "only applies to function") */
  27. __attribute__ ((task, unused));
  28. static int not_a_task __attribute__ ((unused));
  29. static void my_task_almost (int foo, char *bar) /* (error "not a function") */
  30. __attribute__ ((task_implementation ("cpu", not_a_task)));
  31. static void my_task_wrong_task_arg (int foo, char *bar) /* (error "not a function") */
  32. __attribute__ ((task_implementation ("cpu", 123)));
  33. static void my_task_wrong_target_arg (int foo, char *bar) /* (error "string constant expected") */
  34. __attribute__ ((task_implementation (123, my_task)));
  35. static void my_task_with_a_body (int foo, char *bar)
  36. __attribute__ ((task, unused));
  37. extern int my_task_not_void (int foo) /* (error "return type") */
  38. __attribute__ ((task));
  39. void my_task_that_invokes_task (int x, char *y)
  40. __attribute__ ((task));
  41. void my_task_that_invokes_task_cpu (int x, char *y)
  42. __attribute__ ((task_implementation ("cpu", my_task_that_invokes_task)));
  43. /* XXX: The assumption behind this test is that STARPU_USE_GORDON is not
  44. defined. */
  45. void my_task_with_no_usable_implementation (int x) /* (error "none of the implementations") */
  46. __attribute__ ((task));
  47. static void my_task_with_no_usable_implementation_gordon (int x)
  48. __attribute__ ((task_implementation ("gordon",
  49. my_task_with_no_usable_implementation)));
  50. /* XXX: In practice this test fails for large values of `STARPU_NMAXBUFS'. */
  51. void my_task_with_too_many_pointer_params (/* (error "maximum .* exceeded") */
  52. char *x1, char *x2, char *x3,
  53. char *x4, char *x5, char *x6,
  54. char *x7, char *x8, char *x9,
  55. char *xa, char *xb, char *xc,
  56. char *xd, char *xe, char *xf,
  57. char *xg, char *xh, char *xi)
  58. __attribute__ ((task));
  59. static void
  60. my_task_cpu (int foo, float *bar)
  61. {
  62. }
  63. static void
  64. my_task_opencl (long foo, char *bar)
  65. {
  66. }
  67. static void
  68. my_task_nowhere (int foo, char *bar)
  69. {
  70. }
  71. static void
  72. my_task_not_quite (int foo, char *bar)
  73. {
  74. }
  75. static void
  76. my_task_almost (int foo, char *bar)
  77. {
  78. }
  79. static void
  80. my_task_wrong_task_arg (int foo, char *bar)
  81. {
  82. }
  83. static void
  84. my_task_wrong_target_arg (int foo, char *bar)
  85. {
  86. }
  87. static void
  88. my_task_with_a_body (int foo, char *bar) /* (error "must not have a body") */
  89. {
  90. }
  91. void
  92. my_task_that_invokes_task_cpu (int x, char *y)
  93. {
  94. my_external_task (x, y); /* (error "cannot be invoked from task implementation") */
  95. }
  96. static void
  97. my_task_with_no_usable_implementation_gordon (int x)
  98. {
  99. }