explicit_dependencies.doxy 7.2 KB

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