output-pointer.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* GCC-StarPU
  2. Copyright (C) 2011 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. #undef NDEBUG
  14. #include <mocks.h>
  15. #define __output __attribute__ ((output))
  16. /* The tasks under test. */
  17. static void my_pointer_task (size_t size, __output int *x)
  18. __attribute__ ((task));
  19. static void my_pointer_task_cpu (size_t size, __output int *x)
  20. __attribute__ ((task_implementation ("cpu", my_pointer_task)));
  21. static void my_pointer_task_opencl (size_t size, __output int *x)
  22. __attribute__ ((task_implementation ("opencl", my_pointer_task)));
  23. static void
  24. my_pointer_task_cpu (size_t size, __output int *x)
  25. {
  26. printf ("%s: x = %p, size = %zi\n", __func__, x, size);
  27. }
  28. static void
  29. my_pointer_task_opencl (size_t size, int *x)
  30. {
  31. printf ("%s: x = %p, size = %zi\n", __func__, x, size);
  32. }
  33. static void my_array_task (size_t size, __output int x[size])
  34. __attribute__ ((task));
  35. static void my_array_task_cpu (size_t size, __output int x[size])
  36. __attribute__ ((task_implementation ("cpu", my_array_task)));
  37. static void my_array_task_opencl (size_t size, __output int x[size])
  38. __attribute__ ((task_implementation ("opencl", my_array_task)));
  39. static void
  40. my_array_task_cpu (size_t size, __output int x[size])
  41. {
  42. printf ("%s: x = %p, size = %zi\n", __func__, x, size);
  43. }
  44. static void
  45. my_array_task_opencl (size_t size, __output int x[size])
  46. {
  47. printf ("%s: x = %p, size = %zi\n", __func__, x, size);
  48. }
  49. int
  50. main (int argc, char *argv[])
  51. {
  52. #pragma starpu initialize
  53. size_t size = 42;
  54. int x[size];
  55. struct insert_task_argument expected[] =
  56. {
  57. { STARPU_VALUE, &size, sizeof size },
  58. { STARPU_W, x },
  59. { 0, 0, 0 }
  60. };
  61. expected_insert_task_arguments = expected;
  62. /* Invoke the task, which makes sure it gets called with EXPECTED. */
  63. my_pointer_task (size, x);
  64. assert (tasks_submitted == 1);
  65. /* Again. */
  66. my_array_task (size, x);
  67. assert (tasks_submitted == 2);
  68. return EXIT_SUCCESS;
  69. }