lib-user.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 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 signed char x[] __attribute__ ((aligned (8))) =
  25. { 0, 1, 2, 3, 4, 5 };
  26. float y[sizeof x];
  27. static const char forty_two = 42;
  28. static const int sizeof_x = sizeof x;
  29. struct insert_task_argument expected_pointer_task[] =
  30. {
  31. { STARPU_VALUE, &forty_two, sizeof forty_two },
  32. { STARPU_R, x },
  33. { STARPU_RW, y },
  34. { STARPU_VALUE, &sizeof_x, sizeof sizeof_x },
  35. { 0, 0, 0 }
  36. };
  37. expected_insert_task_arguments = expected_pointer_task;
  38. expected_register_arguments.pointer = (void *) x;
  39. expected_register_arguments.elements = sizeof x / sizeof x[0];
  40. expected_register_arguments.element_size = sizeof x[0];
  41. #pragma starpu register x
  42. expected_register_arguments.pointer = y;
  43. expected_register_arguments.elements = sizeof y / sizeof y[0];
  44. expected_register_arguments.element_size = sizeof y[0];
  45. #pragma starpu register y
  46. /* Invoke the task, which should make sure it gets called with
  47. EXPECTED. */
  48. my_task (42, x, y, sizeof x);
  49. assert (tasks_submitted == 1);
  50. #pragma starpu shutdown
  51. return EXIT_SUCCESS;
  52. }