task-errors.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. 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. /* XXX: The assumption behind this test is that STARPU_USE_GORDON is not
  43. defined. */
  44. void my_task_with_no_usable_implementation (int x) /* (error "none of the implementations") */
  45. __attribute__ ((task));
  46. static void my_task_with_no_usable_implementation_gordon (int x)
  47. __attribute__ ((task_implementation ("gordon",
  48. my_task_with_no_usable_implementation)));
  49. /* XXX: In practice this test fails for large values of `STARPU_NMAXBUFS'. */
  50. void my_task_with_too_many_pointer_params (/* (error "maximum .* exceeded") */
  51. char *x1, char *x2, char *x3,
  52. char *x4, char *x5, char *x6,
  53. char *x7, char *x8, char *x9,
  54. char *xa, char *xb, char *xc,
  55. char *xd, char *xe, char *xf,
  56. char *xg, char *xh, char *xi)
  57. __attribute__ ((task));
  58. static void
  59. my_task_cpu (int foo, float *bar)
  60. {
  61. }
  62. static void
  63. my_task_opencl (long foo, char *bar)
  64. {
  65. }
  66. static void
  67. my_task_nowhere (int foo, char *bar)
  68. {
  69. }
  70. static void
  71. my_task_not_quite (int foo, char *bar)
  72. {
  73. }
  74. static void
  75. my_task_almost (int foo, char *bar)
  76. {
  77. }
  78. static void
  79. my_task_wrong_task_arg (int foo, char *bar)
  80. {
  81. }
  82. static void
  83. my_task_wrong_target_arg (int foo, char *bar)
  84. {
  85. }
  86. void
  87. my_task_that_invokes_task_cpu (int x, char *y)
  88. {
  89. my_external_task (x, y); /* (error "cannot be invoked from task implementation") */
  90. }
  91. static void
  92. my_task_with_no_usable_implementation_gordon (int x)
  93. {
  94. }