empty_task_sync_point.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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 <sys/time.h>
  17. #include <pthread.h>
  18. #include <stdio.h>
  19. #include <unistd.h>
  20. #include <starpu.h>
  21. static starpu_tag_t tagA = 0x0042;
  22. static starpu_tag_t tagB = 0x1042;
  23. static starpu_tag_t tagC = 0x2042;
  24. static starpu_tag_t tagD = 0x3042;
  25. static starpu_tag_t tagE = 0x4042;
  26. static starpu_tag_t tagF = 0x5042;
  27. static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
  28. {
  29. }
  30. static starpu_codelet dummy_codelet =
  31. {
  32. .where = STARPU_CPU|STARPU_CUDA,
  33. .cpu_func = dummy_func,
  34. .cuda_func = dummy_func,
  35. .model = NULL,
  36. .nbuffers = 0
  37. };
  38. int main(int argc, char **argv)
  39. {
  40. starpu_init(NULL);
  41. /* {A,B,C} -> D -> {E,F}, D is empty */
  42. struct starpu_task *taskA = starpu_task_create();
  43. taskA->cl = &dummy_codelet;
  44. taskA->use_tag = 1;
  45. taskA->tag_id = tagA;
  46. struct starpu_task *taskB = starpu_task_create();
  47. taskB->cl = &dummy_codelet;
  48. taskB->use_tag = 1;
  49. taskB->tag_id = tagB;
  50. struct starpu_task *taskC = starpu_task_create();
  51. taskC->cl = &dummy_codelet;
  52. taskC->use_tag = 1;
  53. taskC->tag_id = tagC;
  54. struct starpu_task *taskD = starpu_task_create();
  55. taskD->cl = NULL;
  56. taskD->use_tag = 1;
  57. taskD->tag_id = tagD;
  58. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  59. struct starpu_task *taskE = starpu_task_create();
  60. taskE->cl = &dummy_codelet;
  61. taskE->use_tag = 1;
  62. taskE->tag_id = tagE;
  63. starpu_tag_declare_deps(tagE, 1, tagD);
  64. struct starpu_task *taskF = starpu_task_create();
  65. taskF->cl = &dummy_codelet;
  66. taskF->use_tag = 1;
  67. taskF->tag_id = tagF;
  68. starpu_tag_declare_deps(tagF, 1, tagD);
  69. starpu_submit_task(taskA);
  70. starpu_submit_task(taskB);
  71. starpu_submit_task(taskC);
  72. starpu_submit_task(taskD);
  73. starpu_submit_task(taskE);
  74. starpu_submit_task(taskF);
  75. starpu_tag_t tag_array[2] = {tagE, tagF};
  76. starpu_tag_wait_array(2, tag_array);
  77. starpu_shutdown();
  78. return 0;
  79. }