empty_task_sync_point.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010, 2016 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013 CNRS
  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. * Test using a task with NULL codelet as a synchronization task through tag dependencies
  23. */
  24. static starpu_tag_t tagA = 0x0042;
  25. static starpu_tag_t tagB = 0x1042;
  26. static starpu_tag_t tagC = 0x2042;
  27. static starpu_tag_t tagD = 0x3042;
  28. static starpu_tag_t tagE = 0x4042;
  29. static starpu_tag_t tagF = 0x5042;
  30. void dummy_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg STARPU_ATTRIBUTE_UNUSED)
  31. {
  32. }
  33. static struct starpu_codelet dummy_codelet =
  34. {
  35. .cpu_funcs = {dummy_func},
  36. .cuda_funcs = {dummy_func},
  37. .opencl_funcs = {dummy_func},
  38. .cpu_funcs_name = {"dummy_func"},
  39. .model = NULL,
  40. .nbuffers = 0
  41. };
  42. int main(int argc, char **argv)
  43. {
  44. int ret;
  45. ret = starpu_initialize(NULL, &argc, &argv);
  46. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  48. /* {A,B,C} -> D -> {E,F}, D is empty */
  49. struct starpu_task *taskA = starpu_task_create();
  50. taskA->cl = &dummy_codelet;
  51. taskA->use_tag = 1;
  52. taskA->tag_id = tagA;
  53. struct starpu_task *taskB = starpu_task_create();
  54. taskB->cl = &dummy_codelet;
  55. taskB->use_tag = 1;
  56. taskB->tag_id = tagB;
  57. struct starpu_task *taskC = starpu_task_create();
  58. taskC->cl = &dummy_codelet;
  59. taskC->use_tag = 1;
  60. taskC->tag_id = tagC;
  61. struct starpu_task *taskD = starpu_task_create();
  62. taskD->cl = NULL;
  63. taskD->use_tag = 1;
  64. taskD->tag_id = tagD;
  65. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  66. struct starpu_task *taskE = starpu_task_create();
  67. taskE->cl = &dummy_codelet;
  68. taskE->use_tag = 1;
  69. taskE->tag_id = tagE;
  70. starpu_tag_declare_deps(tagE, 1, tagD);
  71. struct starpu_task *taskF = starpu_task_create();
  72. taskF->cl = &dummy_codelet;
  73. taskF->use_tag = 1;
  74. taskF->tag_id = tagF;
  75. starpu_tag_declare_deps(tagF, 1, tagD);
  76. ret = starpu_task_submit(taskA); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  77. ret = starpu_task_submit(taskB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  78. ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  79. ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  80. ret = starpu_task_submit(taskE); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  81. ret = starpu_task_submit(taskF); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  82. starpu_tag_t tag_array[2] = {tagE, tagF};
  83. ret = starpu_tag_wait_array(2, tag_array);
  84. STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait_array");
  85. starpu_shutdown();
  86. return EXIT_SUCCESS;
  87. }