lib-user.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /* Test whether tasks defined in another compilation unit can actually be
  14. used. */
  15. /* (instructions run (dependencies "my-lib.c")) */
  16. #include <mocks.h>
  17. #include <my-lib.h>
  18. int
  19. main (int argc, char *argv[])
  20. {
  21. #pragma starpu initialize
  22. /* Align X so that the assumptions behind `dummy_pointer_to_handle'
  23. hold. */
  24. static const char x[] __attribute__ ((aligned (8))) = { 0, 1, 2, 3, 4, 5 };
  25. float y[sizeof x];
  26. static const char forty_two = 42;
  27. static const int sizeof_x = sizeof x;
  28. struct insert_task_argument expected_pointer_task[] =
  29. {
  30. { STARPU_VALUE, &forty_two, sizeof forty_two },
  31. { STARPU_R, x },
  32. { STARPU_RW, y },
  33. { STARPU_VALUE, &sizeof_x, sizeof sizeof_x },
  34. { 0, 0, 0 }
  35. };
  36. expected_insert_task_arguments = expected_pointer_task;
  37. expected_register_arguments.pointer = (void *) x;
  38. expected_register_arguments.elements = sizeof x / sizeof x[0];
  39. expected_register_arguments.element_size = sizeof x[0];
  40. #pragma starpu register x
  41. expected_register_arguments.pointer = y;
  42. expected_register_arguments.elements = sizeof y / sizeof y[0];
  43. expected_register_arguments.element_size = sizeof y[0];
  44. #pragma starpu register y
  45. /* Invoke the task, which should make sure it gets called with
  46. EXPECTED. */
  47. my_task (42, x, y, sizeof x);
  48. assert (tasks_submitted == 1);
  49. #pragma starpu shutdown
  50. return EXIT_SUCCESS;
  51. }