deploop.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013,2015,2017 CNRS
  4. * Copyright (C) 2010-2011,2013-2016 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <starpu.h>
  20. #include "../helper.h"
  21. /*
  22. * Create task A and B such that
  23. * - B depends on A by tag dependency.
  24. * - A would depend on B by data dependency, but we disable that by disabling
  25. * sequential consistency.
  26. */
  27. void dummy_func(void *descr[], void *arg)
  28. {
  29. (void)descr;
  30. (void)arg;
  31. FPRINTF(stderr,"executing task %p\n", starpu_task_get_current());
  32. }
  33. static struct starpu_codelet dummy_codelet =
  34. {
  35. .cpu_funcs = {dummy_func},
  36. .cpu_funcs_name = {"dummy_func"},
  37. .cuda_funcs = {dummy_func},
  38. .opencl_funcs = {dummy_func},
  39. .model = NULL,
  40. .nbuffers = 1,
  41. .modes = { STARPU_RW }
  42. };
  43. int main(void)
  44. {
  45. int ret;
  46. starpu_data_handle_t handle;
  47. ret = starpu_init(NULL);
  48. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  49. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  50. starpu_void_data_register(&handle);
  51. struct starpu_task *taskA, *taskB;
  52. /* Make B depend on A */
  53. starpu_tag_declare_deps(1, 1, (starpu_tag_t) 0);
  54. taskA = starpu_task_create();
  55. taskA->cl = &dummy_codelet;
  56. taskA->tag_id = 0;
  57. taskA->use_tag = 1;
  58. taskA->handles[0] = handle;
  59. taskA->sequential_consistency = 0;
  60. FPRINTF(stderr,"A is %p\n", taskA);
  61. taskB = starpu_task_create();
  62. taskB->cl = &dummy_codelet;
  63. taskB->tag_id = 1;
  64. taskB->use_tag = 1;
  65. taskB->handles[0] = handle;
  66. FPRINTF(stderr,"B is %p\n", taskB);
  67. ret = starpu_task_submit(taskB);
  68. if (ret == -ENODEV)
  69. return STARPU_TEST_SKIPPED;
  70. ret = starpu_task_submit(taskA);
  71. if (ret == -ENODEV)
  72. return STARPU_TEST_SKIPPED;
  73. ret = starpu_task_wait_for_all();
  74. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  75. starpu_data_unregister(handle);
  76. starpu_shutdown();
  77. return EXIT_SUCCESS;
  78. }