empty_task_sync_point.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 Centre National de la Recherche Scientifique
  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 <sys/time.h>
  18. #include <pthread.h>
  19. #include <stdio.h>
  20. #include <unistd.h>
  21. #include <starpu.h>
  22. #include "../common/helper.h"
  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. static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
  30. {
  31. }
  32. static starpu_codelet dummy_codelet =
  33. {
  34. .where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
  35. .cpu_func = dummy_func,
  36. .cuda_func = dummy_func,
  37. .opencl_func = dummy_func,
  38. .model = NULL,
  39. .nbuffers = 0
  40. };
  41. int main(int argc, char **argv)
  42. {
  43. int ret;
  44. ret = starpu_init(NULL);
  45. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  46. /* {A,B,C} -> D -> {E,F}, D is empty */
  47. struct starpu_task *taskA = starpu_task_create();
  48. taskA->cl = &dummy_codelet;
  49. taskA->use_tag = 1;
  50. taskA->tag_id = tagA;
  51. struct starpu_task *taskB = starpu_task_create();
  52. taskB->cl = &dummy_codelet;
  53. taskB->use_tag = 1;
  54. taskB->tag_id = tagB;
  55. struct starpu_task *taskC = starpu_task_create();
  56. taskC->cl = &dummy_codelet;
  57. taskC->use_tag = 1;
  58. taskC->tag_id = tagC;
  59. struct starpu_task *taskD = starpu_task_create();
  60. taskD->cl = NULL;
  61. taskD->use_tag = 1;
  62. taskD->tag_id = tagD;
  63. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  64. struct starpu_task *taskE = starpu_task_create();
  65. taskE->cl = &dummy_codelet;
  66. taskE->use_tag = 1;
  67. taskE->tag_id = tagE;
  68. starpu_tag_declare_deps(tagE, 1, tagD);
  69. struct starpu_task *taskF = starpu_task_create();
  70. taskF->cl = &dummy_codelet;
  71. taskF->use_tag = 1;
  72. taskF->tag_id = tagF;
  73. starpu_tag_declare_deps(tagF, 1, tagD);
  74. ret = starpu_task_submit(taskA); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  75. ret = starpu_task_submit(taskB); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  76. ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  77. ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  78. ret = starpu_task_submit(taskE); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  79. ret = starpu_task_submit(taskF); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  80. starpu_tag_t tag_array[2] = {tagE, tagF};
  81. ret = starpu_tag_wait_array(2, tag_array);
  82. STARPU_CHECK_RETURN_VALUE(ret, "starpu_tag_wait_array");
  83. starpu_shutdown();
  84. return EXIT_SUCCESS;
  85. }