empty_task_sync_point.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010 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. static starpu_tag_t tagA = 0x0042;
  23. static starpu_tag_t tagB = 0x1042;
  24. static starpu_tag_t tagC = 0x2042;
  25. static starpu_tag_t tagD = 0x3042;
  26. static starpu_tag_t tagE = 0x4042;
  27. static starpu_tag_t tagF = 0x5042;
  28. static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
  29. {
  30. }
  31. static starpu_codelet dummy_codelet =
  32. {
  33. .where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
  34. .cpu_func = dummy_func,
  35. .cuda_func = dummy_func,
  36. .opencl_func = dummy_func,
  37. .model = NULL,
  38. .nbuffers = 0
  39. };
  40. int main(int argc, char **argv)
  41. {
  42. starpu_init(NULL);
  43. /* {A,B,C} -> D -> {E,F}, D is empty */
  44. struct starpu_task *taskA = starpu_task_create();
  45. taskA->cl = &dummy_codelet;
  46. taskA->use_tag = 1;
  47. taskA->tag_id = tagA;
  48. struct starpu_task *taskB = starpu_task_create();
  49. taskB->cl = &dummy_codelet;
  50. taskB->use_tag = 1;
  51. taskB->tag_id = tagB;
  52. struct starpu_task *taskC = starpu_task_create();
  53. taskC->cl = &dummy_codelet;
  54. taskC->use_tag = 1;
  55. taskC->tag_id = tagC;
  56. struct starpu_task *taskD = starpu_task_create();
  57. taskD->cl = NULL;
  58. taskD->use_tag = 1;
  59. taskD->tag_id = tagD;
  60. starpu_tag_declare_deps(tagD, 3, tagA, tagB, tagC);
  61. struct starpu_task *taskE = starpu_task_create();
  62. taskE->cl = &dummy_codelet;
  63. taskE->use_tag = 1;
  64. taskE->tag_id = tagE;
  65. starpu_tag_declare_deps(tagE, 1, tagD);
  66. struct starpu_task *taskF = starpu_task_create();
  67. taskF->cl = &dummy_codelet;
  68. taskF->use_tag = 1;
  69. taskF->tag_id = tagF;
  70. starpu_tag_declare_deps(tagF, 1, tagD);
  71. starpu_task_submit(taskA);
  72. starpu_task_submit(taskB);
  73. starpu_task_submit(taskC);
  74. starpu_task_submit(taskD);
  75. starpu_task_submit(taskE);
  76. starpu_task_submit(taskF);
  77. starpu_tag_t tag_array[2] = {tagE, tagF};
  78. starpu_tag_wait_array(2, tag_array);
  79. starpu_shutdown();
  80. return 0;
  81. }