task-errors.c 4.2 KB

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