explicit_dependencies.doxy 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2017 CNRS
  5. * Copyright (C) 2011, 2012 INRIA
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup API_Explicit_Dependencies Explicit Dependencies
  9. \fn void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
  10. \ingroup API_Explicit_Dependencies
  11. Declare task dependencies between a \p task and an array of
  12. tasks of length \p ndeps. This function must be called prior to the
  13. submission of the task, but it may called after the submission or the
  14. execution of the tasks in the array, provided the tasks are still
  15. valid (i.e. they were not automatically destroyed). Calling this
  16. function on a task that was already submitted or with an entry of
  17. \p task_array that is no longer a valid task results in an undefined
  18. behaviour. If \p ndeps is 0, no dependency is added. It is possible to
  19. call starpu_task_declare_deps_array() several times on the same task,
  20. in this case, the dependencies are added. It is possible to have
  21. redundancy in the task dependencies.
  22. \fn int starpu_task_get_task_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
  23. \ingroup API_Explicit_Dependencies
  24. Fill \p task_array with the list of tasks which are direct children of \p task.
  25. \p ndeps is the size of \p task_array. This function returns the number of
  26. direct children. \p task_array can be set to <c>NULL</c> if \p ndeps is 0, which allows
  27. to compute the number of children before allocating an array to store them.
  28. This function can only be called if \p task has not completed yet, otherwise
  29. the results are undefined. The result may also be outdated if some additional
  30. dependency has been added in the meanwhile.
  31. \fn int starpu_task_get_task_scheduled_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
  32. \ingroup API_Explicit_Dependencies
  33. Behave like starpu_task_get_task_succs(), except that it only reports
  34. tasks which will go through the scheduler, thus avoiding tasks with not codelet,
  35. or with explicit placement.
  36. \typedef starpu_tag_t
  37. \ingroup API_Explicit_Dependencies
  38. Define a task logical identifer. It is possible to
  39. associate a task with a unique <em>tag</em> chosen by the application,
  40. and to express dependencies between tasks by the means of those tags.
  41. To do so, fill the field starpu_task::tag_id with a tag number (can be
  42. arbitrary) and set the field starpu_task::use_tag to 1. If
  43. starpu_tag_declare_deps() is called with this tag number, the task
  44. will not be started until the tasks which holds the declared
  45. dependency tags are completed.
  46. \fn void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)
  47. \ingroup API_Explicit_Dependencies
  48. Specify the dependencies of the task identified by tag \p id.
  49. The first argument specifies the tag which is configured, the second
  50. argument gives the number of tag(s) on which \p id depends. The
  51. following arguments are the tags which have to be terminated to unlock
  52. the task. This function must be called before the associated task is
  53. submitted to StarPU with starpu_task_submit().
  54. <b>WARNING! Use with caution</b>. Because of the variable arity of
  55. starpu_tag_declare_deps(), note that the last arguments must be of
  56. type ::starpu_tag_t : constant values typically need to be explicitly
  57. casted. Otherwise, due to integer sizes and argument passing on the
  58. stack, the C compiler might consider the tag <c>0x200000003</c>
  59. instead of <c>0x2</c> and <c>0x3</c> when calling
  60. <c>starpu_tag_declare_deps(0x1, 2, 0x2, 0x3)</c>. Using the
  61. starpu_tag_declare_deps_array() function avoids this hazard.
  62. \code{.c}
  63. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  64. starpu_tag_declare_deps((starpu_tag_t)0x1, 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  65. \endcode
  66. \fn void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array)
  67. \ingroup API_Explicit_Dependencies
  68. Similar to starpu_tag_declare_deps(), except
  69. that its does not take a variable number of arguments but an \p array of
  70. tags of size \p ndeps.
  71. \code{.c}
  72. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  73. starpu_tag_t tag_array[2] = {0x32, 0x52};
  74. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  75. \endcode
  76. \fn int starpu_tag_wait(starpu_tag_t id)
  77. \ingroup API_Explicit_Dependencies
  78. Block until the task associated to tag \p id has
  79. been executed. This is a blocking call which must therefore not be
  80. called within tasks or callbacks, but only from the application
  81. directly. It is possible to synchronize with the same tag multiple
  82. times, as long as the starpu_tag_remove() function is not called. Note
  83. that it is still possible to synchronize with a tag associated to a
  84. task for which the strucuture starpu_task was freed (e.g. if the field
  85. starpu_task::destroy was enabled).
  86. \fn int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id)
  87. \ingroup API_Explicit_Dependencies
  88. Similar to starpu_tag_wait() except that it
  89. blocks until all the \p ntags tags contained in the array \p id are
  90. terminated.
  91. \fn void starpu_tag_restart(starpu_tag_t id)
  92. \ingroup API_Explicit_Dependencies
  93. Clear the <em>already notified</em> status of a tag which is not associated with a task.
  94. Before that, calling starpu_tag_notify_from_apps() again will not
  95. notify the successors. After that, the next call to
  96. starpu_tag_notify_from_apps() will notify the successors.
  97. \fn void starpu_tag_remove(starpu_tag_t id)
  98. \ingroup API_Explicit_Dependencies
  99. Release the resources associated to tag \p id.
  100. It can be called once the corresponding task has been executed and
  101. when there is no other tag that depend on this tag anymore.
  102. \fn void starpu_tag_notify_from_apps(starpu_tag_t id)
  103. \ingroup API_Explicit_Dependencies
  104. Explicitly unlock tag \p id. It may be useful in
  105. the case of applications which execute part of their computation
  106. outside StarPU tasks (e.g. third-party libraries). It is also provided
  107. as a convenient tool for the programmer, for instance to entirely
  108. construct the task DAG before actually giving StarPU the opportunity
  109. to execute the tasks. When called several times on the same tag,
  110. notification will be done only on first call, thus implementing "OR"
  111. dependencies, until the tag is restarted using starpu_tag_restart().
  112. */