| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | /* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2010-2013,2015,2017,2018                      CNRS * Copyright (C) 2009-2011,2014-2016                      Université de Bordeaux * Copyright (C) 2011-2012                                Inria * * StarPU is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * StarPU is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License in COPYING.LGPL for more details. *//*! \defgroup API_Explicit_Dependencies Explicit Dependencies\fn void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])\ingroup API_Explicit_DependenciesDeclare task dependencies between a \p task and an array oftasks of length \p ndeps. This function must be called prior to thesubmission of the task, but it may called after the submission or theexecution of the tasks in the array, provided the tasks are stillvalid (i.e. they were not automatically destroyed). Calling thisfunction on a task that was already submitted or with an entry of\p task_array that is no longer a valid task results in an undefinedbehaviour. If \p ndeps is 0, no dependency is added. It is possible tocall starpu_task_declare_deps_array() several times on the same task,in this case, the dependencies are added. It is possible to haveredundancy in the task dependencies.\fn int starpu_task_get_task_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])\ingroup API_Explicit_DependenciesFill \p task_array with the list of tasks which are direct children of \p task.\p ndeps is the size of \p task_array.  This function returns the number ofdirect children. \p task_array can be set to <c>NULL</c> if \p ndeps is 0, which allowsto compute the number of children before allocating an array to store them.This function can only be called if \p task has not completed yet, otherwisethe results are undefined. The result may also be outdated if some additionaldependency has been added in the meanwhile.\fn int starpu_task_get_task_scheduled_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])\ingroup API_Explicit_DependenciesBehave like starpu_task_get_task_succs(), except that it only reportstasks which will go through the scheduler, thus avoiding tasks with not codelet,or with explicit placement.\typedef starpu_tag_t\ingroup API_Explicit_DependenciesDefine a task logical identifer. It is possible toassociate a task with a unique <em>tag</em> chosen by the application,and to express dependencies between tasks by the means of those tags.To do so, fill the field starpu_task::tag_id with a tag number (can bearbitrary) and set the field starpu_task::use_tag to 1. Ifstarpu_tag_declare_deps() is called with this tag number, the taskwill not be started until the tasks which holds the declareddependency tags are completed.\fn void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)\ingroup API_Explicit_DependenciesSpecify the dependencies of the task identified by tag \p id.The first argument specifies the tag which is configured, the secondargument gives the number of tag(s) on which \p id depends. Thefollowing arguments are the tags which have to be terminated to unlockthe task. This function must be called before the associated task issubmitted to StarPU with starpu_task_submit().<b>WARNING! Use with caution</b>. Because of the variable arity ofstarpu_tag_declare_deps(), note that the last arguments must be oftype ::starpu_tag_t : constant values typically need to be explicitlycasted. Otherwise, due to integer sizes and argument passing on thestack, the C compiler might consider the tag <c>0x200000003</c>instead of <c>0x2</c> and <c>0x3</c> when calling<c>starpu_tag_declare_deps(0x1, 2, 0x2, 0x3)</c>. Using thestarpu_tag_declare_deps_array() function avoids this hazard.\code{.c}/*  Tag 0x1 depends on tags 0x32 and 0x52 */starpu_tag_declare_deps((starpu_tag_t)0x1, 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);\endcode\fn void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array)\ingroup API_Explicit_DependenciesSimilar to starpu_tag_declare_deps(), exceptthat its does not take a variable number of arguments but an \p array oftags of size \p ndeps.\code{.c}/*  Tag 0x1 depends on tags 0x32 and 0x52 */starpu_tag_t tag_array[2] = {0x32, 0x52};starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);\endcode\fn int starpu_tag_wait(starpu_tag_t id)\ingroup API_Explicit_DependenciesBlock until the task associated to tag \p id hasbeen executed. This is a blocking call which must therefore not becalled within tasks or callbacks, but only from the applicationdirectly. It is possible to synchronize with the same tag multipletimes, as long as the starpu_tag_remove() function is not called. Notethat it is still possible to synchronize with a tag associated to atask for which the strucuture starpu_task was freed (e.g. if the fieldstarpu_task::destroy was enabled).\fn int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id)\ingroup API_Explicit_DependenciesSimilar to starpu_tag_wait() except that itblocks until all the \p ntags tags contained in the array \p id areterminated.\fn void starpu_tag_restart(starpu_tag_t id)\ingroup API_Explicit_DependenciesClear the <em>already notified</em> status of a tag which is not associated with a task.Before that, calling starpu_tag_notify_from_apps() again will notnotify the successors. After that, the next call tostarpu_tag_notify_from_apps() will notify the successors.\fn void starpu_tag_remove(starpu_tag_t id)\ingroup API_Explicit_DependenciesRelease the resources associated to tag \p id.It can be called once the corresponding task has been executed andwhen there is no other tag that depend on this tag anymore.\fn void starpu_tag_notify_from_apps(starpu_tag_t id)\ingroup API_Explicit_DependenciesExplicitly unlock tag \p id. It may be useful inthe case of applications which execute part of their computationoutside StarPU tasks (e.g. third-party libraries). It is also providedas a convenient tool for the programmer, for instance to entirelyconstruct the task DAG before actually giving StarPU the opportunityto execute the tasks. When called several times on the same tag,notification will be done only on first call, thus implementing "OR"dependencies, until the tag is restarted using starpu_tag_restart().\fn void starpu_task_end_dep_add(struct starpu_task *t, int nb_deps)\ingroup API_Explicit_DependenciesAdd \p nb_deps end dependencies to the task \p t. This means the taskwill not terminate until the required number of calls to the functionstarpu_task_end_dep_release() has been made.\fn void starpu_task_end_dep_release(struct starpu_task *t)\ingroup API_Explicit_DependenciesUnlock 1 end dependency to the task \p t. This function must be calledafter starpu_task_end_dep_add().*/
 |