explicit_dependencies.doxy 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  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. \typedef starpu_tag_t
  23. \ingroup API_Explicit_Dependencies
  24. This type defines a task logical identifer. It is possible to
  25. associate a task with a unique <em>tag</em> chosen by the application,
  26. and to express dependencies between tasks by the means of those tags.
  27. To do so, fill the field starpu_task::tag_id with a tag number (can be
  28. arbitrary) and set the field starpu_task::use_tag to 1. If
  29. starpu_tag_declare_deps() is called with this tag number, the task
  30. will not be started until the tasks which holds the declared
  31. dependency tags are completed.
  32. \fn void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)
  33. \ingroup API_Explicit_Dependencies
  34. Specify the dependencies of the task identified by tag \p id.
  35. The first argument specifies the tag which is configured, the second
  36. argument gives the number of tag(s) on which \p id depends. The
  37. following arguments are the tags which have to be terminated to unlock
  38. the task. This function must be called before the associated task is
  39. submitted to StarPU with starpu_task_submit().
  40. <b>WARNING! Use with caution</b>. Because of the variable arity of
  41. starpu_tag_declare_deps(), note that the last arguments must be of
  42. type starpu_tag_t : constant values typically need to be explicitly
  43. casted. Otherwise, due to integer sizes and argument passing on the
  44. stack, the C compiler might consider the tag <c>0x200000003</c>
  45. instead of <c>0x2</c> and <c>0x3</c> when calling
  46. <c>starpu_tag_declare_deps(0x1, 2, 0x2, 0x3)</c>. Using the
  47. starpu_tag_declare_deps_array() function avoids this hazard.
  48. \code{.c}
  49. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  50. starpu_tag_declare_deps((starpu_tag_t)0x1, 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  51. \endcode
  52. \fn void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array)
  53. \ingroup API_Explicit_Dependencies
  54. This function is similar to starpu_tag_declare_deps(), except
  55. that its does not take a variable number of arguments but an array of
  56. tags of size \p ndeps.
  57. \code{.c}
  58. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  59. starpu_tag_t tag_array[2] = {0x32, 0x52};
  60. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  61. \endcode
  62. \fn int starpu_tag_wait(starpu_tag_t id)
  63. \ingroup API_Explicit_Dependencies
  64. This function blocks until the task associated to tag \p id has
  65. been executed. This is a blocking call which must therefore not be
  66. called within tasks or callbacks, but only from the application
  67. directly. It is possible to synchronize with the same tag multiple
  68. times, as long as the starpu_tag_remove() function is not called. Note
  69. that it is still possible to synchronize with a tag associated to a
  70. task for which the strucuture starpu_task was freed (e.g. if the field
  71. starpu_task::destroy was enabled).
  72. \fn int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id)
  73. \ingroup API_Explicit_Dependencies
  74. This function is similar to starpu_tag_wait() except that it
  75. blocks until all the \p ntags tags contained in the array \p id are
  76. terminated.
  77. \fn void starpu_tag_restart(starpu_tag_t id)
  78. \ingroup API_Explicit_Dependencies
  79. This function can be used to clear the <em>already
  80. notified</em> status of a tag which is not associated with a task.
  81. Before that, calling starpu_tag_notify_from_apps() again will not
  82. notify the successors. After that, the next call to
  83. starpu_tag_notify_from_apps() will notify the successors.
  84. \fn void starpu_tag_remove(starpu_tag_t id)
  85. \ingroup API_Explicit_Dependencies
  86. This function releases the resources associated to tag \p id.
  87. It can be called once the corresponding task has been executed and
  88. when there is no other tag that depend on this tag anymore.
  89. \fn void starpu_tag_notify_from_apps(starpu_tag_t id)
  90. \ingroup API_Explicit_Dependencies
  91. This function explicitly unlocks tag \p id. It may be useful in
  92. the case of applications which execute part of their computation
  93. outside StarPU tasks (e.g. third-party libraries). It is also provided
  94. as a convenient tool for the programmer, for instance to entirely
  95. construct the task DAG before actually giving StarPU the opportunity
  96. to execute the tasks. When called several times on the same tag,
  97. notification will be done only on first call, thus implementing "OR"
  98. dependencies, until the tag is restarted using starpu_tag_restart().
  99. */