base.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <stdlib.h>
  15. #include <assert.h>
  16. #ifndef STARPU_GCC_PLUGIN
  17. # error barf!
  18. #endif
  19. #ifndef STARPU_USE_CPU
  20. # error damn it!
  21. #endif
  22. /* The task under test. */
  23. static void my_scalar_task (int x, int y) __attribute__ ((task));
  24. static void my_scalar_task_cpu (int, int)
  25. __attribute__ ((task_implementation ("cpu", my_scalar_task)));
  26. static void my_scalar_task_opencl (int, int)
  27. __attribute__ ((task_implementation ("opencl", my_scalar_task)));
  28. static void
  29. my_scalar_task_cpu (int x, int y)
  30. {
  31. printf ("%s: x = %i, y = %i\n", __func__, x, y);
  32. }
  33. static void
  34. my_scalar_task_opencl (int x, int y)
  35. {
  36. printf ("%s: x = %i, y = %i\n", __func__, x, y);
  37. }
  38. /* Stub used for testing purposes. */
  39. static unsigned int tasks_submitted;
  40. void
  41. starpu_insert_task (starpu_codelet *cl, ...)
  42. {
  43. assert (cl->where == (STARPU_CPU | STARPU_OPENCL));
  44. /* XXX: Eventually the `_func' field will point to a wrapper instead of
  45. pointing directly to the task implementation. */
  46. assert (cl->cpu_func == (void *) my_scalar_task_cpu);
  47. assert (cl->opencl_func == (void *) my_scalar_task_opencl);
  48. assert (cl->cuda_func == NULL);
  49. tasks_submitted++;
  50. }
  51. int
  52. main (int argc, char *argv[])
  53. {
  54. #pragma starpu hello
  55. int x = 42, y = 77;
  56. my_scalar_task (x, y);
  57. assert (tasks_submitted == 1);
  58. return EXIT_SUCCESS;
  59. }