empty_task_sync_point.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (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|STARPU_OPENCL,
  33. .cpu_func = dummy_func,
  34. .cuda_func = dummy_func,
  35. .opencl_func = dummy_func,
  36. .model = NULL,
  37. .nbuffers = 0
  38. };
  39. int main(int argc, char **argv)
  40. {
  41. starpu_init(NULL);
  42. /* {A,B,C} -> D -> {E,F}, D is empty */
  43. struct starpu_task *taskA = starpu_task_create();
  44. taskA->cl = &dummy_codelet;
  45. taskA->use_tag = 1;
  46. taskA->tag_id = tagA;
  47. struct starpu_task *taskB = starpu_task_create();
  48. taskB->cl = &dummy_codelet;
  49. taskB->use_tag = 1;
  50. taskB->tag_id = tagB;
  51. struct starpu_task *taskC = starpu_task_create();
  52. taskC->cl = &dummy_codelet;
  53. taskC->use_tag = 1;
  54. taskC->tag_id = tagC;
  55. struct starpu_task *taskD = starpu_task_create();
  56. taskD->cl = NULL;
  57. taskD->use_tag = 1;
  58. taskD->tag_id = tagD;
  59. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  60. struct starpu_task *taskE = starpu_task_create();
  61. taskE->cl = &dummy_codelet;
  62. taskE->use_tag = 1;
  63. taskE->tag_id = tagE;
  64. starpu_tag_declare_deps(tagE, 1, tagD);
  65. struct starpu_task *taskF = starpu_task_create();
  66. taskF->cl = &dummy_codelet;
  67. taskF->use_tag = 1;
  68. taskF->tag_id = tagF;
  69. starpu_tag_declare_deps(tagF, 1, tagD);
  70. starpu_task_submit(taskA);
  71. starpu_task_submit(taskB);
  72. starpu_task_submit(taskC);
  73. starpu_task_submit(taskD);
  74. starpu_task_submit(taskE);
  75. starpu_task_submit(taskF);
  76. starpu_tag_t tag_array[2] = {tagE, tagF};
  77. starpu_tag_wait_array(2, tag_array);
  78. starpu_shutdown();
  79. return 0;
  80. }