empty_task_sync_point.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <stdio.h>
  17. #include <unistd.h>
  18. #include <starpu.h>
  19. #include "../helper.h"
  20. /*
  21. * Test using a task with NULL codelet as a synchronization task through tag dependencies
  22. */
  23. static starpu_tag_t tagA = 0x0042;
  24. static starpu_tag_t tagB = 0x1042;
  25. static starpu_tag_t tagC = 0x2042;
  26. static starpu_tag_t tagD = 0x3042;
  27. static starpu_tag_t tagE = 0x4042;
  28. static starpu_tag_t tagF = 0x5042;
  29. void dummy_func(void *descr[], void *arg)
  30. {
  31. (void)descr;
  32. (void)arg;
  33. }
  34. static struct starpu_codelet dummy_codelet =
  35. {
  36. .cpu_funcs = {dummy_func},
  37. .cuda_funcs = {dummy_func},
  38. .opencl_funcs = {dummy_func},
  39. .cpu_funcs_name = {"dummy_func"},
  40. .model = NULL,
  41. .nbuffers = 0
  42. };
  43. int main(int argc, char **argv)
  44. {
  45. int ret;
  46. ret = starpu_initialize(NULL, &argc, &argv);
  47. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  49. /* {A,B,C} -> D -> {E,F}, D is empty */
  50. struct starpu_task *taskA = starpu_task_create();
  51. taskA->cl = &dummy_codelet;
  52. taskA->use_tag = 1;
  53. taskA->tag_id = tagA;
  54. struct starpu_task *taskB = starpu_task_create();
  55. taskB->cl = &dummy_codelet;
  56. taskB->use_tag = 1;
  57. taskB->tag_id = tagB;
  58. struct starpu_task *taskC = starpu_task_create();
  59. taskC->cl = &dummy_codelet;
  60. taskC->use_tag = 1;
  61. taskC->tag_id = tagC;
  62. struct starpu_task *taskD = starpu_task_create();
  63. taskD->cl = NULL;
  64. taskD->use_tag = 1;
  65. taskD->tag_id = tagD;
  66. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  67. struct starpu_task *taskE = starpu_task_create();
  68. taskE->cl = &dummy_codelet;
  69. taskE->use_tag = 1;
  70. taskE->tag_id = tagE;
  71. starpu_tag_declare_deps(tagE, 1, tagD);
  72. struct starpu_task *taskF = starpu_task_create();
  73. taskF->cl = &dummy_codelet;
  74. taskF->use_tag = 1;
  75. taskF->tag_id = tagF;
  76. starpu_tag_declare_deps(tagF, 1, tagD);
  77. ret = starpu_task_submit(taskA); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  78. ret = starpu_task_submit(taskB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  79. ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  80. ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  81. ret = starpu_task_submit(taskE); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  82. ret = starpu_task_submit(taskF); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  83. starpu_tag_t tag_array[2] = {tagE, tagF};
  84. ret = starpu_tag_wait_array(2, tag_array);
  85. STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait_array");
  86. starpu_shutdown();
  87. return EXIT_SUCCESS;
  88. }