starpu.texi 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513
  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename starpu.info
  4. @settitle StarPU
  5. @c %**end of header
  6. @setchapternewpage odd
  7. @titlepage
  8. @title StarPU
  9. @page
  10. @vskip 0pt plus 1filll
  11. @comment For the @value{version-GCC} Version*
  12. @end titlepage
  13. @summarycontents
  14. @contents
  15. @page
  16. @node Top
  17. @top Preface
  18. @cindex Preface
  19. This manual documents the usage of StarPU.
  20. @comment
  21. @comment When you add a new menu item, please keep the right hand
  22. @comment aligned to the same column. Do not use tabs. This provides
  23. @comment better formatting.
  24. @comment
  25. @menu
  26. * Introduction:: A basic introduction to using StarPU
  27. * Installing StarPU:: How to configure, build and install StarPU
  28. * Using StarPU:: How to run StarPU application
  29. * Basic Examples:: Basic examples of the use of StarPU
  30. * Configuring StarPU:: How to configure StarPU
  31. * StarPU API:: The API to use StarPU
  32. * Advanced Topics:: Advanced use of StarPU
  33. * Full source code for the 'Scaling a Vector' example::
  34. @end menu
  35. @c ---------------------------------------------------------------------
  36. @c Introduction to StarPU
  37. @c ---------------------------------------------------------------------
  38. @node Introduction
  39. @chapter Introduction to StarPU
  40. @menu
  41. * Motivation:: Why StarPU ?
  42. * StarPU in a Nutshell:: The Fundamentals of StarPU
  43. @end menu
  44. @node Motivation
  45. @section Motivation
  46. @c complex machines with heterogeneous cores/devices
  47. The use of specialized hardware such as accelerators or coprocessors offers an
  48. interesting approach to overcome the physical limits encountered by processor
  49. architects. As a result, many machines are now equipped with one or several
  50. accelerators (e.g. a GPU), in addition to the usual processor(s). While a lot of
  51. efforts have been devoted to offload computation onto such accelerators, very
  52. little attention as been paid to portability concerns on the one hand, and to the
  53. possibility of having heterogeneous accelerators and processors to interact on the other hand.
  54. StarPU is a runtime system that offers support for heterogeneous multicore
  55. architectures, it not only offers a unified view of the computational resources
  56. (i.e. CPUs and accelerators at the same time), but it also takes care of
  57. efficiently mapping and executing tasks onto an heterogeneous machine while
  58. transparently handling low-level issues in a portable fashion.
  59. @c this leads to a complicated distributed memory design
  60. @c which is not (easily) manageable by hand
  61. @c added value/benefits of StarPU
  62. @c - portability
  63. @c - scheduling, perf. portability
  64. @node StarPU in a Nutshell
  65. @section StarPU in a Nutshell
  66. @menu
  67. * Codelet and Tasks::
  68. * StarPU Data Management Library::
  69. @end menu
  70. From a programming point of view, StarPU is not a new language but a library
  71. that executes tasks explicitly submitted by the application. The data that a
  72. task manipulates are automatically transferred onto the accelerator so that the
  73. programmer does not have to take care of complex data movements. StarPU also
  74. takes particular care of scheduling those tasks efficiently and allows
  75. scheduling experts to implement custom scheduling policies in a portable
  76. fashion.
  77. @c explain the notion of codelet and task (i.e. g(A, B)
  78. @node Codelet and Tasks
  79. @subsection Codelet and Tasks
  80. One of StarPU primary data structure is the @b{codelet}. A codelet describes a
  81. computational kernel that can possibly be implemented on multiple architectures
  82. such as a CPU, a CUDA device or a Cell's SPU.
  83. @c TODO insert illustration f : f_spu, f_cpu, ...
  84. Another important data structure is the @b{task}. Executing a StarPU task
  85. consists in applying a codelet on a data set, on one of the architectures on
  86. which the codelet is implemented. In addition to the codelet that a task
  87. implements, it also describes which data are accessed, and how they are
  88. accessed during the computation (read and/or write).
  89. StarPU tasks are asynchronous: submitting a task to StarPU is a non-blocking
  90. operation. The task structure can also specify a @b{callback} function that is
  91. called once StarPU has properly executed the task. It also contains optional
  92. fields that the application may use to give hints to the scheduler (such as
  93. priority levels).
  94. A task may be identified by a unique 64-bit number which we refer as a @b{tag}.
  95. Task dependencies can be enforced either by the means of callback functions, or
  96. by expressing dependencies between tags.
  97. @c TODO insert illustration f(Ar, Brw, Cr) + ..
  98. @c DSM
  99. @node StarPU Data Management Library
  100. @subsection StarPU Data Management Library
  101. Because StarPU schedules tasks at runtime, data transfers have to be
  102. done automatically and ``just-in-time'' between processing units,
  103. relieving the application programmer from explicit data transfers.
  104. Moreover, to avoid unnecessary transfers, StarPU keeps data
  105. where it was last needed, even if was modified there, and it
  106. allows multiple copies of the same data to reside at the same time on
  107. several processing units as long as it is not modified.
  108. @c ---------------------------------------------------------------------
  109. @c Installing StarPU
  110. @c ---------------------------------------------------------------------
  111. @node Installing StarPU
  112. @chapter Installing StarPU
  113. @menu
  114. * Downloading StarPU::
  115. * Configuration of StarPU::
  116. * Building and Installing StarPU::
  117. @end menu
  118. StarPU can be built and installed by the standard means of the GNU
  119. autotools. The following chapter is intended to briefly remind how these tools
  120. can be used to install StarPU.
  121. @node Downloading StarPU
  122. @section Downloading StarPU
  123. @menu
  124. * Getting Sources::
  125. * Optional dependencies::
  126. @end menu
  127. @node Getting Sources
  128. @subsection Getting Sources
  129. The source code is managed by a Subversion server hosted by the
  130. InriaGforge. To get the source code, you need:
  131. @itemize
  132. @item
  133. To install the client side of the software Subversion if it is
  134. not already available on your system. The software can be obtained from
  135. @indicateurl{http://subversion.tigris.org}.
  136. @item
  137. You can check out the project's SVN repository through anonymous
  138. access. This will provide you with a read access to the
  139. repository.
  140. You can also choose to become a member of the project @code{starpu}.
  141. For this, you first need to get an account to the gForge server. You
  142. can then send a request to join the project
  143. (@indicateurl{https://gforge.inria.fr/project/request.php?group_id=1570}).
  144. @item
  145. More information on how to get a gForge account, to become a member of
  146. a project, or on any other related task can be obtained from the
  147. InriaGforge at @indicateurl{https://gforge.inria.fr/}. The most important
  148. thing is to upload your public SSH key on the gForge server (see the
  149. FAQ at @indicateurl{http://siteadmin.gforge.inria.fr/FAQ.html#Q6} for
  150. instructions).
  151. @end itemize
  152. You can now check out the latest version from the Subversion server:
  153. @itemize
  154. @item
  155. using the anonymous access via svn:
  156. @example
  157. % svn checkout svn://scm.gforge.inria.fr/svn/starpu/trunk
  158. @end example
  159. @item
  160. using the anonymous access via https:
  161. @example
  162. % svn checkout --username anonsvn https://scm.gforge.inria.fr/svn/starpu/trunk
  163. @end example
  164. The password is @code{anonsvn}.
  165. @item
  166. using your gForge account
  167. @example
  168. % svn checkout svn+ssh://<login>@@scm.gforge.inria.fr/svn/starpu/trunk
  169. @end example
  170. @end itemize
  171. These steps require to run autoconf and automake to generate the
  172. @code{./configure} script. This can be done by calling
  173. @code{./autogen.sh}. The required version for autoconf is 2.60 or
  174. higher.
  175. @example
  176. % ./autogen.sh
  177. @end example
  178. If the autotools are not available on your machine or not recent
  179. enough, you can choose to download the latest nightly tarball, which
  180. is provided with a @code{configure} script.
  181. @example
  182. % wget http://starpu.gforge.inria.fr/testing/starpu-nightly-latest.tar.gz
  183. @end example
  184. @node Optional dependencies
  185. @subsection Optional dependencies
  186. The topology discovery library, hwloc, is not mandatory to use StarPU
  187. but strongly recommended. It allows to increase performance, and to
  188. perform some topology aware scheduling.
  189. hwloc is available in major distributions and for most OSes and can be
  190. downloaded from @indicateurl{http://www.open-mpi.org/software/hwloc}.
  191. @node Configuration of StarPU
  192. @section Configuration of StarPU
  193. @menu
  194. * Generating Makefiles and configuration scripts::
  195. * Running the configuration::
  196. @end menu
  197. @node Generating Makefiles and configuration scripts
  198. @subsection Generating Makefiles and configuration scripts
  199. This step is not necessary when using the tarball releases of StarPU. If you
  200. are using the source code from the svn repository, you first need to generate
  201. the configure scripts and the Makefiles.
  202. @example
  203. % ./autogen.sh
  204. @end example
  205. @node Running the configuration
  206. @subsection Running the configuration
  207. @example
  208. % ./configure
  209. @end example
  210. Details about options that are useful to give to @code{./configure} are given in
  211. @ref{Compilation configuration}.
  212. @node Building and Installing StarPU
  213. @section Building and Installing StarPU
  214. @menu
  215. * Building::
  216. * Sanity Checks::
  217. * Installing::
  218. @end menu
  219. @node Building
  220. @subsection Building
  221. @example
  222. % make
  223. @end example
  224. @node Sanity Checks
  225. @subsection Sanity Checks
  226. In order to make sure that StarPU is working properly on the system, it is also
  227. possible to run a test suite.
  228. @example
  229. % make check
  230. @end example
  231. @node Installing
  232. @subsection Installing
  233. In order to install StarPU at the location that was specified during
  234. configuration:
  235. @example
  236. % make install
  237. @end example
  238. @c ---------------------------------------------------------------------
  239. @c Using StarPU
  240. @c ---------------------------------------------------------------------
  241. @node Using StarPU
  242. @chapter Using StarPU
  243. @menu
  244. * Setting flags for compiling and linking applications::
  245. * Running a basic StarPU application::
  246. @end menu
  247. @node Setting flags for compiling and linking applications
  248. @section Setting flags for compiling and linking applications
  249. Compiling and linking an application against StarPU may require to use
  250. specific flags or libraries (for instance @code{CUDA} or @code{libspe2}).
  251. To this end, it is possible to use the @code{pkg-config} tool.
  252. If StarPU was not installed at some standard location, the path of StarPU's
  253. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  254. that @code{pkg-config} can find it. For example if StarPU was installed in
  255. @code{$prefix_dir}:
  256. @example
  257. % PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$prefix_dir/lib/pkgconfig
  258. @end example
  259. The flags required to compile or link against StarPU are then
  260. accessible with the following commands:
  261. @example
  262. % pkg-config --cflags libstarpu # options for the compiler
  263. % pkg-config --libs libstarpu # options for the linker
  264. @end example
  265. @node Running a basic StarPU application
  266. @section Running a basic StarPU application
  267. Basic examples using StarPU have been built in the directory
  268. @code{$prefix_dir/lib/starpu/examples/}. You can for example run the
  269. example @code{vector_scal}.
  270. @example
  271. % $prefix_dir/lib/starpu/examples/vector_scal
  272. BEFORE : First element was 1.000000
  273. AFTER First element is 3.140000
  274. %
  275. @end example
  276. When StarPU is used for the first time, the directory
  277. @code{$HOME/.starpu/} is created, performance models will be stored in
  278. that directory.
  279. Please note that buses are benchmarked when StarPU is launched for the
  280. first time. This may take a few minutes, or less if @code{hwloc} is
  281. installed. This step is done only once per user and per machine.
  282. @c ---------------------------------------------------------------------
  283. @c Basic Examples
  284. @c ---------------------------------------------------------------------
  285. @node Basic Examples
  286. @chapter Basic Examples
  287. @menu
  288. * Compiling and linking options::
  289. * Hello World:: Submitting Tasks
  290. * Scaling a Vector:: Manipulating Data
  291. * Vector Scaling on an Hybrid CPU/GPU Machine:: Handling Heterogeneous Architectures
  292. * Task and Worker Profiling::
  293. * Partitioning Data:: Partitioning Data
  294. * Performance model example::
  295. * More examples:: More examples shipped with StarPU
  296. @end menu
  297. @node Compiling and linking options
  298. @section Compiling and linking options
  299. Let's suppose StarPU has been installed in the directory
  300. @code{$STARPU_DIR}. As explained in @ref{Setting flags for compiling and linking applications},
  301. the variable @code{PKG_CONFIG_PATH} needs to be set. It is also
  302. necessary to set the variable @code{LD_LIBRARY_PATH} to locate dynamic
  303. libraries at runtime.
  304. @example
  305. % PKG_CONFIG_PATH=$STARPU_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
  306. % LD_LIBRARY_PATH=$STARPU_DIR/lib:$LD_LIBRARY_PATH
  307. @end example
  308. The Makefile could for instance contain the following lines to define which
  309. options must be given to the compiler and to the linker:
  310. @cartouche
  311. @example
  312. CFLAGS += $$(pkg-config --cflags libstarpu)
  313. LDFLAGS += $$(pkg-config --libs libstarpu)
  314. @end example
  315. @end cartouche
  316. @node Hello World
  317. @section Hello World
  318. @menu
  319. * Required Headers::
  320. * Defining a Codelet::
  321. * Submitting a Task::
  322. * Execution of Hello World::
  323. @end menu
  324. In this section, we show how to implement a simple program that submits a task to StarPU.
  325. @node Required Headers
  326. @subsection Required Headers
  327. The @code{starpu.h} header should be included in any code using StarPU.
  328. @cartouche
  329. @smallexample
  330. #include <starpu.h>
  331. @end smallexample
  332. @end cartouche
  333. @node Defining a Codelet
  334. @subsection Defining a Codelet
  335. @cartouche
  336. @smallexample
  337. void cpu_func(void *buffers[], void *cl_arg)
  338. @{
  339. float *array = cl_arg;
  340. printf("Hello world (array = @{%f, %f@} )\n", array[0], array[1]);
  341. @}
  342. starpu_codelet cl =
  343. @{
  344. .where = STARPU_CPU,
  345. .cpu_func = cpu_func,
  346. .nbuffers = 0
  347. @};
  348. @end smallexample
  349. @end cartouche
  350. A codelet is a structure that represents a computational kernel. Such a codelet
  351. may contain an implementation of the same kernel on different architectures
  352. (e.g. CUDA, Cell's SPU, x86, ...).
  353. The @code{nbuffers} field specifies the number of data buffers that are
  354. manipulated by the codelet: here the codelet does not access or modify any data
  355. that is controlled by our data management library. Note that the argument
  356. passed to the codelet (the @code{cl_arg} field of the @code{starpu_task}
  357. structure) does not count as a buffer since it is not managed by our data
  358. management library.
  359. @c TODO need a crossref to the proper description of "where" see bla for more ...
  360. We create a codelet which may only be executed on the CPUs. The @code{where}
  361. field is a bitmask that defines where the codelet may be executed. Here, the
  362. @code{STARPU_CPU} value means that only CPUs can execute this codelet
  363. (@pxref{Codelets and Tasks} for more details on this field).
  364. When a CPU core executes a codelet, it calls the @code{cpu_func} function,
  365. which @emph{must} have the following prototype:
  366. @code{void (*cpu_func)(void *buffers[], void *cl_arg);}
  367. In this example, we can ignore the first argument of this function which gives a
  368. description of the input and output buffers (e.g. the size and the location of
  369. the matrices). The second argument is a pointer to a buffer passed as an
  370. argument to the codelet by the means of the @code{cl_arg} field of the
  371. @code{starpu_task} structure.
  372. @c TODO rewrite so that it is a little clearer ?
  373. Be aware that this may be a pointer to a
  374. @emph{copy} of the actual buffer, and not the pointer given by the programmer:
  375. if the codelet modifies this buffer, there is no guarantee that the initial
  376. buffer will be modified as well: this for instance implies that the buffer
  377. cannot be used as a synchronization medium.
  378. @node Submitting a Task
  379. @subsection Submitting a Task
  380. @cartouche
  381. @smallexample
  382. void callback_func(void *callback_arg)
  383. @{
  384. printf("Callback function (arg %x)\n", callback_arg);
  385. @}
  386. int main(int argc, char **argv)
  387. @{
  388. /* @b{initialize StarPU} */
  389. starpu_init(NULL);
  390. struct starpu_task *task = starpu_task_create();
  391. task->cl = &cl; /* @b{Pointer to the codelet defined above} */
  392. float array[2] = @{1.0f, -1.0f@};
  393. task->cl_arg = &array;
  394. task->cl_arg_size = sizeof(array);
  395. task->callback_func = callback_func;
  396. task->callback_arg = 0x42;
  397. /* @b{starpu_task_submit will be a blocking call} */
  398. task->synchronous = 1;
  399. /* @b{submit the task to StarPU} */
  400. starpu_task_submit(task);
  401. /* @b{terminate StarPU} */
  402. starpu_shutdown();
  403. return 0;
  404. @}
  405. @end smallexample
  406. @end cartouche
  407. Before submitting any tasks to StarPU, @code{starpu_init} must be called. The
  408. @code{NULL} argument specifies that we use default configuration. Tasks cannot
  409. be submitted after the termination of StarPU by a call to
  410. @code{starpu_shutdown}.
  411. In the example above, a task structure is allocated by a call to
  412. @code{starpu_task_create}. This function only allocates and fills the
  413. corresponding structure with the default settings (@pxref{starpu_task_create}),
  414. but it does not submit the task to StarPU.
  415. @c not really clear ;)
  416. The @code{cl} field is a pointer to the codelet which the task will
  417. execute: in other words, the codelet structure describes which computational
  418. kernel should be offloaded on the different architectures, and the task
  419. structure is a wrapper containing a codelet and the piece of data on which the
  420. codelet should operate.
  421. The optional @code{cl_arg} field is a pointer to a buffer (of size
  422. @code{cl_arg_size}) with some parameters for the kernel
  423. described by the codelet. For instance, if a codelet implements a computational
  424. kernel that multiplies its input vector by a constant, the constant could be
  425. specified by the means of this buffer, instead of registering it.
  426. Once a task has been executed, an optional callback function can be called.
  427. While the computational kernel could be offloaded on various architectures, the
  428. callback function is always executed on a CPU. The @code{callback_arg}
  429. pointer is passed as an argument of the callback. The prototype of a callback
  430. function must be:
  431. @code{void (*callback_function)(void *);}
  432. If the @code{synchronous} field is non-null, task submission will be
  433. synchronous: the @code{starpu_task_submit} function will not return until the
  434. task was executed. Note that the @code{starpu_shutdown} method does not
  435. guarantee that asynchronous tasks have been executed before it returns.
  436. @node Execution of Hello World
  437. @subsection Execution of Hello World
  438. @smallexample
  439. % make hello_world
  440. cc $(pkg-config --cflags libstarpu) $(pkg-config --libs libstarpu) hello_world.c -o hello_world
  441. % ./hello_world
  442. Hello world (array = @{1.000000, -1.000000@} )
  443. Callback function (arg 42)
  444. @end smallexample
  445. @node Scaling a Vector
  446. @section Manipulating Data: Scaling a Vector
  447. The previous example has shown how to submit tasks. In this section,
  448. we show how StarPU tasks can manipulate data. The full source code for
  449. this example is given in @ref{Full source code for the 'Scaling a Vector' example}.
  450. @menu
  451. * Source code of Vector Scaling::
  452. * Execution of Vector Scaling::
  453. @end menu
  454. @node Source code of Vector Scaling
  455. @subsection Source code of Vector Scaling
  456. Programmers can describe the data layout of their application so that StarPU is
  457. responsible for enforcing data coherency and availability across the machine.
  458. Instead of handling complex (and non-portable) mechanisms to perform data
  459. movements, programmers only declare which piece of data is accessed and/or
  460. modified by a task, and StarPU makes sure that when a computational kernel
  461. starts somewhere (e.g. on a GPU), its data are available locally.
  462. Before submitting those tasks, the programmer first needs to declare the
  463. different pieces of data to StarPU using the @code{starpu_*_data_register}
  464. functions. To ease the development of applications for StarPU, it is possible
  465. to describe multiple types of data layout. A type of data layout is called an
  466. @b{interface}. By default, there are different interfaces available in StarPU:
  467. here we will consider the @b{vector interface}.
  468. The following lines show how to declare an array of @code{NX} elements of type
  469. @code{float} using the vector interface:
  470. @cartouche
  471. @smallexample
  472. float vector[NX];
  473. starpu_data_handle vector_handle;
  474. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector, NX,
  475. sizeof(vector[0]));
  476. @end smallexample
  477. @end cartouche
  478. The first argument, called the @b{data handle}, is an opaque pointer which
  479. designates the array in StarPU. This is also the structure which is used to
  480. describe which data is used by a task. The second argument is the node number
  481. where the data currently resides. Here it is 0 since the @code{vector} array is in
  482. the main memory. Then comes the pointer @code{vector} where the data can be found,
  483. the number of elements in the vector and the size of each element.
  484. It is possible to construct a StarPU task that will manipulate the
  485. vector and a constant factor.
  486. @cartouche
  487. @smallexample
  488. float factor = 3.14;
  489. struct starpu_task *task = starpu_task_create();
  490. task->cl = &cl; /* @b{Pointer to the codelet defined below} */
  491. task->buffers[0].handle = vector_handle; /* @b{First parameter of the codelet} */
  492. task->buffers[0].mode = STARPU_RW;
  493. task->cl_arg = &factor;
  494. task->cl_arg_size = sizeof(factor);
  495. task->synchronous = 1;
  496. starpu_task_submit(task);
  497. @end smallexample
  498. @end cartouche
  499. Since the factor is a mere float value parameter, it does not need a preliminary registration, and
  500. can just be passed through the @code{cl_arg} pointer like in the previous
  501. example. The vector parameter is described by its handle.
  502. There are two fields in each element of the @code{buffers} array.
  503. @code{handle} is the handle of the data, and @code{mode} specifies how the
  504. kernel will access the data (@code{STARPU_R} for read-only, @code{STARPU_W} for
  505. write-only and @code{STARPU_RW} for read and write access).
  506. The definition of the codelet can be written as follows:
  507. @cartouche
  508. @smallexample
  509. void scal_cpu_func(void *buffers[], void *cl_arg)
  510. @{
  511. unsigned i;
  512. float *factor = cl_arg;
  513. /* length of the vector */
  514. unsigned n = STARPU_VECTOR_GET_NX(buffers[0]);
  515. /* local copy of the vector pointer */
  516. float *val = (float *)STARPU_VECTOR_GET_PTR(buffers[0]);
  517. for (i = 0; i < n; i++)
  518. val[i] *= *factor;
  519. @}
  520. starpu_codelet cl = @{
  521. .where = STARPU_CPU,
  522. .cpu_func = scal_cpu_func,
  523. .nbuffers = 1
  524. @};
  525. @end smallexample
  526. @end cartouche
  527. The second argument of the @code{scal_cpu_func} function contains a pointer to the
  528. parameters of the codelet (given in @code{task->cl_arg}), so that we read the
  529. constant factor from this pointer. The first argument is an array that gives
  530. a description of all the buffers passed in the @code{task->buffers}@ array. The
  531. size of this array is given by the @code{nbuffers} field of the codelet
  532. structure. For the sake of generality, this array contains pointers to the
  533. different interfaces describing each buffer. In the case of the @b{vector
  534. interface}, the location of the vector (resp. its length) is accessible in the
  535. @code{ptr} (resp. @code{nx}) of this array. Since the vector is accessed in a
  536. read-write fashion, any modification will automatically affect future accesses
  537. to this vector made by other tasks.
  538. @node Execution of Vector Scaling
  539. @subsection Execution of Vector Scaling
  540. @smallexample
  541. % make vector_scal
  542. cc $(pkg-config --cflags libstarpu) $(pkg-config --libs libstarpu) vector_scal.c -o vector_scal
  543. % ./vector_scal
  544. 0.000000 3.000000 6.000000 9.000000 12.000000
  545. @end smallexample
  546. @node Vector Scaling on an Hybrid CPU/GPU Machine
  547. @section Vector Scaling on an Hybrid CPU/GPU Machine
  548. Contrary to the previous examples, the task submitted in this example may not
  549. only be executed by the CPUs, but also by a CUDA device.
  550. @menu
  551. * Definition of the CUDA Codelet::
  552. * Definition of the OpenCL Codelet::
  553. * Definition of the Main Code::
  554. * Execution of Hybrid Vector Scaling::
  555. @end menu
  556. @node Definition of the CUDA Codelet
  557. @subsection Definition of the CUDA Codelet
  558. The CUDA implementation can be written as follows. It needs to be
  559. compiled with a CUDA compiler such as nvcc, the NVIDIA CUDA compiler
  560. driver.
  561. @cartouche
  562. @smallexample
  563. #include <starpu.h>
  564. static __global__ void vector_mult_cuda(float *val, unsigned n,
  565. float factor)
  566. @{
  567. unsigned i;
  568. for(i = 0 ; i < n ; i++)
  569. val[i] *= factor;
  570. @}
  571. extern "C" void scal_cuda_func(void *buffers[], void *_args)
  572. @{
  573. float *factor = (float *)_args;
  574. /* length of the vector */
  575. unsigned n = STARPU_VECTOR_GET_NX(buffers[0]);
  576. /* local copy of the vector pointer */
  577. float *val = (float *)STARPU_VECTOR_GET_PTR(buffers[0]);
  578. @i{ vector_mult_cuda<<<1,1>>>(val, n, *factor);}
  579. @i{ cudaThreadSynchronize();}
  580. @}
  581. @end smallexample
  582. @end cartouche
  583. @node Definition of the OpenCL Codelet
  584. @subsection Definition of the OpenCL Codelet
  585. The OpenCL implementation can be written as follows. StarPU provides
  586. tools to compile a OpenCL codelet stored in a file.
  587. @cartouche
  588. @smallexample
  589. __kernel void vector_mult_opencl(__global float* val, int nx, float factor)
  590. @{
  591. const int i = get_global_id(0);
  592. if (i < nx) @{
  593. val[i] *= factor;
  594. @}
  595. @}
  596. @end smallexample
  597. @end cartouche
  598. @cartouche
  599. @smallexample
  600. #include <starpu.h>
  601. @i{#include <starpu_opencl.h>}
  602. @i{extern struct starpu_opencl_program programs;}
  603. void scal_opencl_func(void *buffers[], void *_args)
  604. @{
  605. float *factor = _args;
  606. @i{ int id, devid, err;}
  607. @i{ cl_kernel kernel;}
  608. @i{ cl_command_queue queue;}
  609. /* length of the vector */
  610. unsigned n = STARPU_VECTOR_GET_NX(buffers[0]);
  611. /* local copy of the vector pointer */
  612. float *val = (float *)STARPU_VECTOR_GET_PTR(buffers[0]);
  613. @i{ id = starpu_worker_get_id();}
  614. @i{ devid = starpu_worker_get_devid(id);}
  615. @i{ err = starpu_opencl_load_kernel(&kernel, &queue, &programs,}
  616. @i{ "vector_mult_opencl", devid); /* @b{Name of the codelet defined above} */}
  617. @i{ if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);}
  618. @i{ err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &val);}
  619. @i{ err |= clSetKernelArg(kernel, 1, sizeof(n), &n);}
  620. @i{ err |= clSetKernelArg(kernel, 2, sizeof(*factor), factor);}
  621. @i{ if (err) STARPU_OPENCL_REPORT_ERROR(err);}
  622. @i{ @{}
  623. @i{ size_t global=1;}
  624. @i{ size_t local=1;}
  625. @i{ err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, &local, 0, NULL, NULL);}
  626. @i{ if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);}
  627. @i{ @}}
  628. @i{ clFinish(queue);}
  629. @i{ starpu_opencl_release_kernel(kernel);}
  630. @}
  631. @end smallexample
  632. @end cartouche
  633. @node Definition of the Main Code
  634. @subsection Definition of the Main Code
  635. The CPU implementation is the same as in the previous section.
  636. Here is the source of the main application. You can notice the value of the
  637. field @code{where} for the codelet. We specify
  638. @code{STARPU_CPU|STARPU_CUDA|STARPU_OPENCL} to indicate to StarPU that the codelet
  639. can be executed either on a CPU or on a CUDA or an OpenCL device.
  640. @cartouche
  641. @smallexample
  642. #include <starpu.h>
  643. #define NX 2048
  644. extern void scal_cuda_func(void *buffers[], void *_args);
  645. extern void scal_cpu_func(void *buffers[], void *_args);
  646. extern void scal_opencl_func(void *buffers[], void *_args);
  647. /* @b{Definition of the codelet} */
  648. static starpu_codelet cl = @{
  649. .where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL; /* @b{It can be executed on a CPU,} */
  650. /* @b{on a CUDA device, or on an OpenCL device} */
  651. .cuda_func = scal_cuda_func;
  652. .cpu_func = scal_cpu_func;
  653. .opencl_func = scal_opencl_func;
  654. .nbuffers = 1;
  655. @}
  656. #ifdef STARPU_USE_OPENCL
  657. /* @b{The compiled version of the OpenCL program} */
  658. struct starpu_opencl_program programs;
  659. #endif
  660. int main(int argc, char **argv)
  661. @{
  662. float *vector;
  663. int i, ret;
  664. float factor=3.0;
  665. struct starpu_task *task;
  666. starpu_data_handle vector_handle;
  667. starpu_init(NULL); /* @b{Initialising StarPU} */
  668. #ifdef STARPU_USE_OPENCL
  669. starpu_opencl_load_opencl_from_file("examples/basic_examples/vector_scal_opencl_codelet.cl",
  670. &programs);
  671. #endif
  672. vector = malloc(NX*sizeof(vector[0]));
  673. assert(vector);
  674. for(i=0 ; i<NX ; i++) vector[i] = i;
  675. @end smallexample
  676. @end cartouche
  677. @cartouche
  678. @smallexample
  679. /* @b{Registering data within StarPU} */
  680. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector,
  681. NX, sizeof(vector[0]));
  682. /* @b{Definition of the task} */
  683. task = starpu_task_create();
  684. task->cl = &cl;
  685. task->buffers[0].handle = vector_handle;
  686. task->buffers[0].mode = STARPU_RW;
  687. task->cl_arg = &factor;
  688. task->cl_arg_size = sizeof(factor);
  689. @end smallexample
  690. @end cartouche
  691. @cartouche
  692. @smallexample
  693. /* @b{Submitting the task} */
  694. ret = starpu_task_submit(task);
  695. if (ret == -ENODEV) @{
  696. fprintf(stderr, "No worker may execute this task\n");
  697. return 1;
  698. @}
  699. /* @b{Waiting for its termination} */
  700. starpu_task_wait_for_all();
  701. /* @b{Update the vector in RAM} */
  702. starpu_data_acquire(vector_handle, STARPU_R);
  703. @end smallexample
  704. @end cartouche
  705. @cartouche
  706. @smallexample
  707. /* @b{Access the data} */
  708. for(i=0 ; i<NX; i++) @{
  709. fprintf(stderr, "%f ", vector[i]);
  710. @}
  711. fprintf(stderr, "\n");
  712. /* @b{Release the data and shutdown StarPU} */
  713. starpu_data_release(vector_handle);
  714. starpu_shutdown();
  715. return 0;
  716. @}
  717. @end smallexample
  718. @end cartouche
  719. @node Execution of Hybrid Vector Scaling
  720. @subsection Execution of Hybrid Vector Scaling
  721. The Makefile given at the beginning of the section must be extended to
  722. give the rules to compile the CUDA source code. Note that the source
  723. file of the OpenCL codelet does not need to be compiled now, it will
  724. be compiled at run-time when calling the function
  725. @code{starpu_opencl_load_opencl_from_file} (@pxref{starpu_opencl_load_opencl_from_file}).
  726. @cartouche
  727. @smallexample
  728. CFLAGS += $(shell pkg-config --cflags libstarpu)
  729. LDFLAGS += $(shell pkg-config --libs libstarpu)
  730. CC = gcc
  731. vector_scal: vector_scal.o vector_scal_cpu.o vector_scal_cuda.o vector_scal_opencl.o
  732. %.o: %.cu
  733. nvcc $(CFLAGS) $< -c $@
  734. clean:
  735. rm -f vector_scal *.o
  736. @end smallexample
  737. @end cartouche
  738. @smallexample
  739. % make
  740. @end smallexample
  741. and to execute it, with the default configuration:
  742. @smallexample
  743. % ./vector_scal
  744. 0.000000 3.000000 6.000000 9.000000 12.000000
  745. @end smallexample
  746. or for example, by disabling CPU devices:
  747. @smallexample
  748. % STARPU_NCPUS=0 ./vector_scal
  749. 0.000000 3.000000 6.000000 9.000000 12.000000
  750. @end smallexample
  751. or by disabling CUDA devices:
  752. @smallexample
  753. % STARPU_NCUDA=0 ./vector_scal
  754. 0.000000 3.000000 6.000000 9.000000 12.000000
  755. @end smallexample
  756. @node Task and Worker Profiling
  757. @section Task and Worker Profiling
  758. A full example showing how to use the profiling API is available in
  759. the StarPU sources in the directory @code{examples/profiling/}.
  760. @cartouche
  761. @smallexample
  762. struct starpu_task *task = starpu_task_create();
  763. task->cl = &cl;
  764. task->synchronous = 1;
  765. /* We will destroy the task structure by hand so that we can
  766. * query the profiling info before the task is destroyed. */
  767. task->destroy = 0;
  768. starpu_task_submit(task);
  769. /* The task is finished, get profiling information */
  770. struct starpu_task_profiling_info *info = task->profiling_info;
  771. /* How much time did it take before the task started ? */
  772. double delay += starpu_timing_timespec_delay_us(&info->submit_time, &info->start_time);
  773. /* How long was the task execution ? */
  774. double length += starpu_timing_timespec_delay_us(&info->start_time, &info->end_time);
  775. /* We don't need the task structure anymore */
  776. starpu_task_destroy(task);
  777. @end smallexample
  778. @end cartouche
  779. @cartouche
  780. @smallexample
  781. /* Display the occupancy of all workers during the test */
  782. int worker;
  783. for (worker = 0; worker < starpu_worker_get_count(); worker++)
  784. @{
  785. struct starpu_worker_profiling_info worker_info;
  786. int ret = starpu_worker_get_profiling_info(worker, &worker_info);
  787. STARPU_ASSERT(!ret);
  788. double total_time = starpu_timing_timespec_to_us(&worker_info.total_time);
  789. double executing_time = starpu_timing_timespec_to_us(&worker_info.executing_time);
  790. double sleeping_time = starpu_timing_timespec_to_us(&worker_info.sleeping_time);
  791. float executing_ratio = 100.0*executing_time/total_time;
  792. float sleeping_ratio = 100.0*sleeping_time/total_time;
  793. char workername[128];
  794. starpu_worker_get_name(worker, workername, 128);
  795. fprintf(stderr, "Worker %s:\n", workername);
  796. fprintf(stderr, "\ttotal time : %.2lf ms\n", total_time*1e-3);
  797. fprintf(stderr, "\texec time : %.2lf ms (%.2f %%)\n", executing_time*1e-3,
  798. executing_ratio);
  799. fprintf(stderr, "\tblocked time : %.2lf ms (%.2f %%)\n", sleeping_time*1e-3,
  800. sleeping_ratio);
  801. @}
  802. @end smallexample
  803. @end cartouche
  804. @node Partitioning Data
  805. @section Partitioning Data
  806. An existing piece of data can be partitioned in sub parts to be used by different tasks, for instance:
  807. @cartouche
  808. @smallexample
  809. int vector[NX];
  810. starpu_data_handle handle;
  811. /* Declare data to StarPU */
  812. starpu_vector_data_register(&handle, 0, (uintptr_t)vector, NX, sizeof(vector[0]));
  813. /* Partition the vector in PARTS sub-vectors */
  814. starpu_filter f =
  815. @{
  816. .filter_func = starpu_block_filter_func_vector,
  817. .nchildren = PARTS,
  818. .get_nchildren = NULL,
  819. .get_child_ops = NULL
  820. @};
  821. starpu_data_partition(handle, &f);
  822. @end smallexample
  823. @end cartouche
  824. @cartouche
  825. @smallexample
  826. /* Submit a task on each sub-vector */
  827. for (i=0; i<starpu_data_get_nb_children(handle); i++) @{
  828. starpu_data_handle sub_handle = starpu_data_get_sub_data(handle, 1, i);
  829. struct starpu_task *task = starpu_task_create();
  830. task->buffers[0].handle = sub_handle;
  831. task->buffers[0].mode = STARPU_RW;
  832. task->cl = &cl;
  833. task->synchronous = 1;
  834. task->cl_arg = &factor;
  835. task->cl_arg_size = sizeof(factor);
  836. starpu_task_submit(task);
  837. @}
  838. @end smallexample
  839. @end cartouche
  840. Partitioning can be applied several times, see
  841. @code{examples/basic_examples/mult.c} and @code{examples/filters/}.
  842. @node Performance model example
  843. @section Performance model example
  844. To achieve good scheduling, StarPU scheduling policies need to be able to
  845. estimate in advance the duration of a task. This is done by giving to codelets a
  846. performance model. There are several kinds of performance models.
  847. @itemize
  848. @item
  849. Providing an estimation from the application itself (@code{STARPU_COMMON} model type and @code{cost_model} field),
  850. see for instance
  851. @code{examples/common/blas_model.c} and @code{examples/common/blas_model.h}. It can also be provided for each architecture (@code{STARPU_PER_ARCH} model type and @code{per_arch} field)
  852. @item
  853. Measured at runtime (STARPU_HISTORY_BASED model type). This assumes that for a
  854. given set of data input/output sizes, the performance will always be about the
  855. same. This is very true for regular kernels on GPUs for instance (<0.1% error),
  856. and just a bit less true on CPUs (~=1% error). This also assumes that there are
  857. few different sets of data input/output sizes. StarPU will then keep record of
  858. the average time of previous executions on the various processing units, and use
  859. it as an estimation. It will also save it in @code{~/.starpu/sampling/codelets}
  860. for further executions. The following is a small code example.
  861. @cartouche
  862. @smallexample
  863. static struct starpu_perfmodel_t mult_perf_model = @{
  864. .type = STARPU_HISTORY_BASED,
  865. .symbol = "mult_perf_model"
  866. @};
  867. starpu_codelet cl = @{
  868. .where = STARPU_CPU,
  869. .cpu_func = cpu_mult,
  870. .nbuffers = 3,
  871. /* for the scheduling policy to be able to use performance models */
  872. .model = &mult_perf_model
  873. @};
  874. @end smallexample
  875. @end cartouche
  876. @item
  877. Measured at runtime and refined by regression (STARPU_REGRESSION_BASED model
  878. type). This still assumes performance regularity, but can work with various data
  879. input sizes, by applying a*n^b+c regression over observed execution times.
  880. @end itemize
  881. @node Theoretical lower bound on execution time
  882. @section Theoretical lower bound on execution time
  883. For history-based kernels, StarPU can very easily provide a theoretical lower
  884. bound for the execution time of a whole set of tasks. See for
  885. instance @code{examples/lu/lu_example.c}: before submitting tasks,
  886. call @code{starpu_bound_start}, and after complete execution, call
  887. @code{starpu_bound_stop}. @code{starpu_bound_print_lp} can then be used to
  888. output a Linear Programming problem corresponding to the schedule of your
  889. tasks. Run it through @code{lp_solve}, and that will give you a lower bound for the total execution time of your tasks.
  890. Note that this is not taking into account task dependencies and data
  891. transfers. It only takes into account the actual computations on processing
  892. units. It however properly takes into account the varying performances of
  893. kernels and processing units, which is quite more accurate than just comparing
  894. StarPU performances with the fastest of the kernels being used.
  895. @node More examples
  896. @section More examples
  897. More examples are available in the StarPU sources in the @code{examples/}
  898. directory. Simple examples include:
  899. @table @asis
  900. @item @code{incrementer/}:
  901. Trivial incrementation test.
  902. @item @code{basic_examples/}:
  903. Simple documented Hello world (as shown in @ref{Hello World}), vector/scalar product (as shown
  904. in @ref{Vector Scaling on an Hybrid CPU/GPU Machine}), matrix
  905. product examples (as shown in @ref{Performance model example}), an example using the blocked matrix data
  906. interface, and an example using the variable data interface.
  907. @item @code{matvecmult/}:
  908. OpenCL example from NVidia, adapted to StarPU.
  909. @item @code{axpy/}:
  910. AXPY CUBLAS operation adapted to StarPU.
  911. @item @code{fortran/}:
  912. Example of Fortran bindings.
  913. @end table
  914. More advanced examples include:
  915. @table @asis
  916. @item @code{filters/}:
  917. Examples using filters, as shown in @ref{Partitioning Data}.
  918. @item @code{lu/}:
  919. LU matrix factorization.
  920. @end table
  921. @c ---------------------------------------------------------------------
  922. @c Configuration options
  923. @c ---------------------------------------------------------------------
  924. @node Configuring StarPU
  925. @chapter Configuring StarPU
  926. @menu
  927. * Compilation configuration::
  928. * Execution configuration through environment variables::
  929. @end menu
  930. @node Compilation configuration
  931. @section Compilation configuration
  932. The following arguments can be given to the @code{configure} script.
  933. @menu
  934. * Common configuration::
  935. * Configuring workers::
  936. * Advanced configuration::
  937. @end menu
  938. @node Common configuration
  939. @subsection Common configuration
  940. @menu
  941. * --enable-debug::
  942. * --enable-fast::
  943. * --enable-verbose::
  944. * --enable-coverage::
  945. @end menu
  946. @node --enable-debug
  947. @subsubsection @code{--enable-debug}
  948. @table @asis
  949. @item @emph{Description}:
  950. Enable debugging messages.
  951. @end table
  952. @node --enable-fast
  953. @subsubsection @code{--enable-fast}
  954. @table @asis
  955. @item @emph{Description}:
  956. Do not enforce assertions, saves a lot of time spent to compute them otherwise.
  957. @end table
  958. @node --enable-verbose
  959. @subsubsection @code{--enable-verbose}
  960. @table @asis
  961. @item @emph{Description}:
  962. Augment the verbosity of the debugging messages.
  963. @end table
  964. @node --enable-coverage
  965. @subsubsection @code{--enable-coverage}
  966. @table @asis
  967. @item @emph{Description}:
  968. Enable flags for the coverage tool.
  969. @end table
  970. @node Configuring workers
  971. @subsection Configuring workers
  972. @menu
  973. * --enable-nmaxcpus::
  974. * --disable-cpu::
  975. * --enable-maxcudadev::
  976. * --disable-cuda::
  977. * --with-cuda-dir::
  978. * --enable-maxopencldev::
  979. * --disable-opencl::
  980. * --with-opencl-dir::
  981. * --enable-gordon::
  982. * --with-gordon-dir::
  983. @end menu
  984. @node --enable-nmaxcpus
  985. @subsubsection @code{--enable-nmaxcpus=<number>}
  986. @table @asis
  987. @item @emph{Description}:
  988. Defines the maximum number of CPU cores that StarPU will support, then
  989. available as the @code{STARPU_NMAXCPUS} macro.
  990. @end table
  991. @node --disable-cpu
  992. @subsubsection @code{--disable-cpu}
  993. @table @asis
  994. @item @emph{Description}:
  995. Disable the use of CPUs of the machine. Only GPUs etc. will be used.
  996. @end table
  997. @node --enable-maxcudadev
  998. @subsubsection @code{--enable-maxcudadev=<number>}
  999. @table @asis
  1000. @item @emph{Description}:
  1001. Defines the maximum number of CUDA devices that StarPU will support, then
  1002. available as the @code{STARPU_MAXCUDADEVS} macro.
  1003. @end table
  1004. @node --disable-cuda
  1005. @subsubsection @code{--disable-cuda}
  1006. @table @asis
  1007. @item @emph{Description}:
  1008. Disable the use of CUDA, even if a valid CUDA installation was detected.
  1009. @end table
  1010. @node --with-cuda-dir
  1011. @subsubsection @code{--with-cuda-dir=<path>}
  1012. @table @asis
  1013. @item @emph{Description}:
  1014. Specify the directory where CUDA is installed. This directory should notably contain
  1015. @code{include/cuda.h}.
  1016. @end table
  1017. @node --enable-maxopencldev
  1018. @subsubsection @code{--enable-maxopencldev=<number>}
  1019. @table @asis
  1020. @item @emph{Description}:
  1021. Defines the maximum number of OpenCL devices that StarPU will support, then
  1022. available as the @code{STARPU_MAXOPENCLDEVS} macro.
  1023. @end table
  1024. @node --disable-opencl
  1025. @subsubsection @code{--disable-opencl}
  1026. @table @asis
  1027. @item @emph{Description}:
  1028. Disable the use of OpenCL, even if the SDK is detected.
  1029. @end table
  1030. @node --with-opencl-dir
  1031. @subsubsection @code{--with-opencl-dir=<path>}
  1032. @table @asis
  1033. @item @emph{Description}:
  1034. Specify the location of the OpenCL SDK. This directory should notably contain
  1035. @code{include/CL/cl.h}.
  1036. @end table
  1037. @node --enable-gordon
  1038. @subsubsection @code{--enable-gordon}
  1039. @table @asis
  1040. @item @emph{Description}:
  1041. Enable the use of the Gordon runtime for Cell SPUs.
  1042. @c TODO: rather default to enabled when detected
  1043. @end table
  1044. @node --with-gordon-dir
  1045. @subsubsection @code{--with-gordon-dir=<path>}
  1046. @table @asis
  1047. @item @emph{Description}:
  1048. Specify the location of the Gordon SDK.
  1049. @end table
  1050. @node Advanced configuration
  1051. @subsection Advanced configuration
  1052. @menu
  1053. * --enable-perf-debug::
  1054. * --enable-model-debug::
  1055. * --enable-stats::
  1056. * --enable-maxbuffers::
  1057. * --enable-allocation-cache::
  1058. * --enable-opengl-render::
  1059. * --enable-blas-lib::
  1060. * --with-magma::
  1061. * --with-fxt::
  1062. * --with-perf-model-dir::
  1063. * --with-mpicc::
  1064. * --with-goto-dir::
  1065. * --with-atlas-dir::
  1066. @end menu
  1067. @node --enable-perf-debug
  1068. @subsubsection @code{--enable-perf-debug}
  1069. @table @asis
  1070. @item @emph{Description}:
  1071. Enable performance debugging.
  1072. @end table
  1073. @node --enable-model-debug
  1074. @subsubsection @code{--enable-model-debug}
  1075. @table @asis
  1076. @item @emph{Description}:
  1077. Enable performance model debugging.
  1078. @end table
  1079. @node --enable-stats
  1080. @subsubsection @code{--enable-stats}
  1081. @table @asis
  1082. @item @emph{Description}:
  1083. Enable statistics.
  1084. @end table
  1085. @node --enable-maxbuffers
  1086. @subsubsection @code{--enable-maxbuffers=<nbuffers>}
  1087. @table @asis
  1088. @item @emph{Description}:
  1089. Define the maximum number of buffers that tasks will be able to take
  1090. as parameters, then available as the @code{STARPU_NMAXBUFS} macro.
  1091. @end table
  1092. @node --enable-allocation-cache
  1093. @subsubsection @code{--enable-allocation-cache}
  1094. @table @asis
  1095. @item @emph{Description}:
  1096. Enable the use of a data allocation cache to avoid the cost of it with
  1097. CUDA. Still experimental.
  1098. @end table
  1099. @node --enable-opengl-render
  1100. @subsubsection @code{--enable-opengl-render}
  1101. @table @asis
  1102. @item @emph{Description}:
  1103. Enable the use of OpenGL for the rendering of some examples.
  1104. @c TODO: rather default to enabled when detected
  1105. @end table
  1106. @node --enable-blas-lib
  1107. @subsubsection @code{--enable-blas-lib=<name>}
  1108. @table @asis
  1109. @item @emph{Description}:
  1110. Specify the blas library to be used by some of the examples. The
  1111. library has to be 'atlas' or 'goto'.
  1112. @end table
  1113. @node --with-magma
  1114. @subsubsection @code{--with-magma=<path>}
  1115. @table @asis
  1116. @item @emph{Description}:
  1117. Specify where magma is installed.
  1118. @end table
  1119. @node --with-fxt
  1120. @subsubsection @code{--with-fxt=<path>}
  1121. @table @asis
  1122. @item @emph{Description}:
  1123. Specify the location of FxT (for generating traces and rendering them
  1124. using ViTE). This directory should notably contain
  1125. @code{include/fxt/fxt.h}.
  1126. @end table
  1127. @node --with-perf-model-dir
  1128. @subsubsection @code{--with-perf-model-dir=<dir>}
  1129. @table @asis
  1130. @item @emph{Description}:
  1131. Specify where performance models should be stored (instead of defaulting to the
  1132. current user's home).
  1133. @end table
  1134. @node --with-mpicc
  1135. @subsubsection @code{--with-mpicc=<path to mpicc>}
  1136. @table @asis
  1137. @item @emph{Description}:
  1138. Specify the location of the @code{mpicc} compiler to be used for starpumpi.
  1139. @end table
  1140. @node --with-goto-dir
  1141. @subsubsection @code{--with-goto-dir=<dir>}
  1142. @table @asis
  1143. @item @emph{Description}:
  1144. Specify the location of GotoBLAS.
  1145. @end table
  1146. @node --with-atlas-dir
  1147. @subsubsection @code{--with-atlas-dir=<dir>}
  1148. @table @asis
  1149. @item @emph{Description}:
  1150. Specify the location of ATLAS. This directory should notably contain
  1151. @code{include/cblas.h}.
  1152. @end table
  1153. @c ---------------------------------------------------------------------
  1154. @c Environment variables
  1155. @c ---------------------------------------------------------------------
  1156. @node Execution configuration through environment variables
  1157. @section Execution configuration through environment variables
  1158. @menu
  1159. * Workers:: Configuring workers
  1160. * Scheduling:: Configuring the Scheduling engine
  1161. * Misc:: Miscellaneous and debug
  1162. @end menu
  1163. Note: the values given in @code{starpu_conf} structure passed when
  1164. calling @code{starpu_init} will override the values of the environment
  1165. variables.
  1166. @node Workers
  1167. @subsection Configuring workers
  1168. @menu
  1169. * STARPU_NCPUS:: Number of CPU workers
  1170. * STARPU_NCUDA:: Number of CUDA workers
  1171. * STARPU_NOPENCL:: Number of OpenCL workers
  1172. * STARPU_NGORDON:: Number of SPU workers (Cell)
  1173. * STARPU_WORKERS_CPUID:: Bind workers to specific CPUs
  1174. * STARPU_WORKERS_CUDAID:: Select specific CUDA devices
  1175. * STARPU_WORKERS_OPENCLID:: Select specific OpenCL devices
  1176. @end menu
  1177. @node STARPU_NCPUS
  1178. @subsubsection @code{STARPU_NCPUS} -- Number of CPU workers
  1179. @table @asis
  1180. @item @emph{Description}:
  1181. Specify the maximum number of CPU workers. Note that StarPU will not allocate
  1182. more CPUs than there are physical CPUs, and that some CPUs are used to control
  1183. the accelerators.
  1184. @end table
  1185. @node STARPU_NCUDA
  1186. @subsubsection @code{STARPU_NCUDA} -- Number of CUDA workers
  1187. @table @asis
  1188. @item @emph{Description}:
  1189. Specify the maximum number of CUDA devices that StarPU can use. If
  1190. @code{STARPU_NCUDA} is lower than the number of physical devices, it is
  1191. possible to select which CUDA devices should be used by the means of the
  1192. @code{STARPU_WORKERS_CUDAID} environment variable.
  1193. @end table
  1194. @node STARPU_NOPENCL
  1195. @subsubsection @code{STARPU_NOPENCL} -- Number of OpenCL workers
  1196. @table @asis
  1197. @item @emph{Description}:
  1198. OpenCL equivalent of the @code{STARPU_NCUDA} environment variable.
  1199. @end table
  1200. @node STARPU_NGORDON
  1201. @subsubsection @code{STARPU_NGORDON} -- Number of SPU workers (Cell)
  1202. @table @asis
  1203. @item @emph{Description}:
  1204. Specify the maximum number of SPUs that StarPU can use.
  1205. @end table
  1206. @node STARPU_WORKERS_CPUID
  1207. @subsubsection @code{STARPU_WORKERS_CPUID} -- Bind workers to specific CPUs
  1208. @table @asis
  1209. @item @emph{Description}:
  1210. Passing an array of integers (starting from 0) in @code{STARPU_WORKERS_CPUID}
  1211. specifies on which logical CPU the different workers should be
  1212. bound. For instance, if @code{STARPU_WORKERS_CPUID = "1 3 0 2"}, the first
  1213. worker will be bound to logical CPU #1, the second CPU worker will be bound to
  1214. logical CPU #3 and so on. Note that the logical ordering of the CPUs is either
  1215. determined by the OS, or provided by the @code{hwloc} library in case it is
  1216. available.
  1217. Note that the first workers correspond to the CUDA workers, then come the
  1218. OpenCL and the SPU, and finally the CPU workers. For example if
  1219. we have @code{STARPU_NCUDA=1}, @code{STARPU_NOPENCL=1}, @code{STARPU_NCPUS=2}
  1220. and @code{STARPU_WORKERS_CPUID = "0 2 1 3"}, the CUDA device will be controlled
  1221. by logical CPU #0, the OpenCL device will be controlled by logical CPU #2, and
  1222. the logical CPUs #1 and #3 will be used by the CPU workers.
  1223. If the number of workers is larger than the array given in
  1224. @code{STARPU_WORKERS_CPUID}, the workers are bound to the logical CPUs in a
  1225. round-robin fashion: if @code{STARPU_WORKERS_CPUID = "0 1"}, the first and the
  1226. third (resp. second and fourth) workers will be put on CPU #0 (resp. CPU #1).
  1227. This variable is ignored if the @code{use_explicit_workers_bindid} flag of the
  1228. @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1229. @end table
  1230. @node STARPU_WORKERS_CUDAID
  1231. @subsubsection @code{STARPU_WORKERS_CUDAID} -- Select specific CUDA devices
  1232. @table @asis
  1233. @item @emph{Description}:
  1234. Similarly to the @code{STARPU_WORKERS_CPUID} environment variable, it is
  1235. possible to select which CUDA devices should be used by StarPU. On a machine
  1236. equipped with 4 GPUs, setting @code{STARPU_WORKERS_CUDAID = "1 3"} and
  1237. @code{STARPU_NCUDA=2} specifies that 2 CUDA workers should be created, and that
  1238. they should use CUDA devices #1 and #3 (the logical ordering of the devices is
  1239. the one reported by CUDA).
  1240. This variable is ignored if the @code{use_explicit_workers_cuda_gpuid} flag of
  1241. the @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1242. @end table
  1243. @node STARPU_WORKERS_OPENCLID
  1244. @subsubsection @code{STARPU_WORKERS_OPENCLID} -- Select specific OpenCL devices
  1245. @table @asis
  1246. @item @emph{Description}:
  1247. OpenCL equivalent of the @code{STARPU_WORKERS_CUDAID} environment variable.
  1248. This variable is ignored if the @code{use_explicit_workers_opencl_gpuid} flag of
  1249. the @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1250. @end table
  1251. @node Scheduling
  1252. @subsection Configuring the Scheduling engine
  1253. @menu
  1254. * STARPU_SCHED:: Scheduling policy
  1255. * STARPU_CALIBRATE:: Calibrate performance models
  1256. * STARPU_PREFETCH:: Use data prefetch
  1257. * STARPU_SCHED_ALPHA:: Computation factor
  1258. * STARPU_SCHED_BETA:: Communication factor
  1259. @end menu
  1260. @node STARPU_SCHED
  1261. @subsubsection @code{STARPU_SCHED} -- Scheduling policy
  1262. @table @asis
  1263. @item @emph{Description}:
  1264. This chooses between the different scheduling policies proposed by StarPU: work
  1265. random, stealing, greedy, with performance models, etc.
  1266. Use @code{STARPU_SCHED=help} to get the list of available schedulers.
  1267. @end table
  1268. @node STARPU_CALIBRATE
  1269. @subsubsection @code{STARPU_CALIBRATE} -- Calibrate performance models
  1270. @table @asis
  1271. @item @emph{Description}:
  1272. If this variable is set to 1, the performance models are calibrated during
  1273. the execution. If it is set to 2, the previous values are dropped to restart
  1274. calibration from scratch.
  1275. Note: this currently only applies to dm and dmda scheduling policies.
  1276. @end table
  1277. @node STARPU_PREFETCH
  1278. @subsubsection @code{STARPU_PREFETCH} -- Use data prefetch
  1279. @table @asis
  1280. @item @emph{Description}:
  1281. This variable indicates whether data prefetching should be enabled (0 means
  1282. that it is disabled). If prefetching is enabled, when a task is scheduled to be
  1283. executed e.g. on a GPU, StarPU will request an asynchronous transfer in
  1284. advance, so that data is already present on the GPU when the task starts. As a
  1285. result, computation and data transfers are overlapped.
  1286. @end table
  1287. @node STARPU_SCHED_ALPHA
  1288. @subsubsection @code{STARPU_SCHED_ALPHA} -- Computation factor
  1289. @table @asis
  1290. @item @emph{Description}:
  1291. To estimate the cost of a task StarPU takes into account the estimated
  1292. computation time (obtained thanks to performance models). The alpha factor is
  1293. the coefficient to be applied to it before adding it to the communication part.
  1294. @end table
  1295. @node STARPU_SCHED_BETA
  1296. @subsubsection @code{STARPU_SCHED_BETA} -- Communication factor
  1297. @table @asis
  1298. @item @emph{Description}:
  1299. To estimate the cost of a task StarPU takes into account the estimated
  1300. data transfer time (obtained thanks to performance models). The beta factor is
  1301. the coefficient to be applied to it before adding it to the computation part.
  1302. @end table
  1303. @node Misc
  1304. @subsection Miscellaneous and debug
  1305. @menu
  1306. * STARPU_LOGFILENAME:: Select debug file name
  1307. @end menu
  1308. @node STARPU_LOGFILENAME
  1309. @subsubsection @code{STARPU_LOGFILENAME} -- Select debug file name
  1310. @table @asis
  1311. @item @emph{Description}:
  1312. This variable specify in which file the debugging output should be saved to.
  1313. @end table
  1314. @c ---------------------------------------------------------------------
  1315. @c StarPU API
  1316. @c ---------------------------------------------------------------------
  1317. @node StarPU API
  1318. @chapter StarPU API
  1319. @menu
  1320. * Initialization and Termination:: Initialization and Termination methods
  1321. * Workers' Properties:: Methods to enumerate workers' properties
  1322. * Data Library:: Methods to manipulate data
  1323. * Data Interfaces::
  1324. * Data Partition::
  1325. * Codelets and Tasks:: Methods to construct tasks
  1326. * Explicit Dependencies:: Explicit Dependencies
  1327. * Implicit Data Dependencies:: Implicit Data Dependencies
  1328. * Performance Model API::
  1329. * Profiling API:: Profiling API
  1330. * CUDA extensions:: CUDA extensions
  1331. * OpenCL extensions:: OpenCL extensions
  1332. * Cell extensions:: Cell extensions
  1333. * Miscellaneous helpers::
  1334. @end menu
  1335. @node Initialization and Termination
  1336. @section Initialization and Termination
  1337. @menu
  1338. * starpu_init:: Initialize StarPU
  1339. * struct starpu_conf:: StarPU runtime configuration
  1340. * starpu_shutdown:: Terminate StarPU
  1341. @end menu
  1342. @node starpu_init
  1343. @subsection @code{starpu_init} -- Initialize StarPU
  1344. @table @asis
  1345. @item @emph{Description}:
  1346. This is StarPU initialization method, which must be called prior to any other
  1347. StarPU call. It is possible to specify StarPU's configuration (e.g. scheduling
  1348. policy, number of cores, ...) by passing a non-null argument. Default
  1349. configuration is used if the passed argument is @code{NULL}.
  1350. @item @emph{Return value}:
  1351. Upon successful completion, this function returns 0. Otherwise, @code{-ENODEV}
  1352. indicates that no worker was available (so that StarPU was not initialized).
  1353. @item @emph{Prototype}:
  1354. @code{int starpu_init(struct starpu_conf *conf);}
  1355. @end table
  1356. @node struct starpu_conf
  1357. @subsection @code{struct starpu_conf} -- StarPU runtime configuration
  1358. @table @asis
  1359. @item @emph{Description}:
  1360. This structure is passed to the @code{starpu_init} function in order
  1361. to configure StarPU.
  1362. When the default value is used, StarPU automatically selects the number
  1363. of processing units and takes the default scheduling policy. This parameter
  1364. overwrites the equivalent environment variables.
  1365. @item @emph{Fields}:
  1366. @table @asis
  1367. @item @code{sched_policy_name} (default = NULL):
  1368. This is the name of the scheduling policy. This can also be specified with the
  1369. @code{STARPU_SCHED} environment variable.
  1370. @item @code{sched_policy} (default = NULL):
  1371. This is the definition of the scheduling policy. This field is ignored
  1372. if @code{sched_policy_name} is set.
  1373. @item @code{ncpus} (default = -1):
  1374. This is the maximum number of CPU cores that StarPU can use. This can also be
  1375. specified with the @code{STARPU_NCPUS} environment variable.
  1376. @item @code{ncuda} (default = -1):
  1377. This is the maximum number of CUDA devices that StarPU can use. This can also be
  1378. specified with the @code{STARPU_NCUDA} environment variable.
  1379. @item @code{nopencl} (default = -1):
  1380. This is the maximum number of OpenCL devices that StarPU can use. This can also be
  1381. specified with the @code{STARPU_NOPENCL} environment variable.
  1382. @item @code{nspus} (default = -1):
  1383. This is the maximum number of Cell SPUs that StarPU can use. This can also be
  1384. specified with the @code{STARPU_NGORDON} environment variable.
  1385. @item @code{use_explicit_workers_bindid} (default = 0)
  1386. If this flag is set, the @code{workers_bindid} array indicates where the
  1387. different workers are bound, otherwise StarPU automatically selects where to
  1388. bind the different workers unless the @code{STARPU_WORKERS_CPUID} environment
  1389. variable is set. The @code{STARPU_WORKERS_CPUID} environment variable is
  1390. ignored if the @code{use_explicit_workers_bindid} flag is set.
  1391. @item @code{workers_bindid[STARPU_NMAXWORKERS]}
  1392. If the @code{use_explicit_workers_bindid} flag is set, this array indicates
  1393. where to bind the different workers. The i-th entry of the
  1394. @code{workers_bindid} indicates the logical identifier of the processor which
  1395. should execute the i-th worker. Note that the logical ordering of the CPUs is
  1396. either determined by the OS, or provided by the @code{hwloc} library in case it
  1397. is available.
  1398. When this flag is set, the @ref{STARPU_WORKERS_CPUID} environment variable is
  1399. ignored.
  1400. @item @code{use_explicit_workers_cuda_gpuid} (default = 0)
  1401. If this flag is set, the CUDA workers will be attached to the CUDA devices
  1402. specified in the @code{workers_cuda_gpuid} array. Otherwise, StarPU affects the
  1403. CUDA devices in a round-robin fashion.
  1404. When this flag is set, the @ref{STARPU_WORKERS_CUDAID} environment variable is
  1405. ignored.
  1406. @item @code{workers_cuda_gpuid[STARPU_NMAXWORKERS]}
  1407. If the @code{use_explicit_workers_cuda_gpuid} flag is set, this array contains
  1408. the logical identifiers of the CUDA devices (as used by @code{cudaGetDevice}).
  1409. @item @code{use_explicit_workers_opencl_gpuid} (default = 0)
  1410. If this flag is set, the OpenCL workers will be attached to the OpenCL devices
  1411. specified in the @code{workers_opencl_gpuid} array. Otherwise, StarPU affects the
  1412. OpenCL devices in a round-robin fashion.
  1413. @item @code{workers_opencl_gpuid[STARPU_NMAXWORKERS]}:
  1414. @item @code{calibrate} (default = 0):
  1415. If this flag is set, StarPU will calibrate the performance models when
  1416. executing tasks. If this value is equal to -1, the default value is used. The
  1417. default value is overwritten by the @code{STARPU_CALIBRATE} environment
  1418. variable when it is set.
  1419. @end table
  1420. @end table
  1421. @node starpu_shutdown
  1422. @subsection @code{starpu_shutdown} -- Terminate StarPU
  1423. @table @asis
  1424. @item @emph{Description}:
  1425. This is StarPU termination method. It must be called at the end of the
  1426. application: statistics and other post-mortem debugging information are not
  1427. guaranteed to be available until this method has been called.
  1428. @item @emph{Prototype}:
  1429. @code{void starpu_shutdown(void);}
  1430. @end table
  1431. @node Workers' Properties
  1432. @section Workers' Properties
  1433. @menu
  1434. * starpu_worker_get_count:: Get the number of processing units
  1435. * starpu_cpu_worker_get_count:: Get the number of CPU controlled by StarPU
  1436. * starpu_cuda_worker_get_count:: Get the number of CUDA devices controlled by StarPU
  1437. * starpu_opencl_worker_get_count:: Get the number of OpenCL devices controlled by StarPU
  1438. * starpu_spu_worker_get_count:: Get the number of Cell SPUs controlled by StarPU
  1439. * starpu_worker_get_id:: Get the identifier of the current worker
  1440. * starpu_worker_get_devid:: Get the device identifier of a worker
  1441. * starpu_worker_get_type:: Get the type of processing unit associated to a worker
  1442. * starpu_worker_get_name:: Get the name of a worker
  1443. * starpu_worker_get_memory_node:: Get the memory node of a worker
  1444. @end menu
  1445. @node starpu_worker_get_count
  1446. @subsection @code{starpu_worker_get_count} -- Get the number of processing units
  1447. @table @asis
  1448. @item @emph{Description}:
  1449. This function returns the number of workers (i.e. processing units executing
  1450. StarPU tasks). The returned value should be at most @code{STARPU_NMAXWORKERS}.
  1451. @item @emph{Prototype}:
  1452. @code{unsigned starpu_worker_get_count(void);}
  1453. @end table
  1454. @node starpu_cpu_worker_get_count
  1455. @subsection @code{starpu_cpu_worker_get_count} -- Get the number of CPU controlled by StarPU
  1456. @table @asis
  1457. @item @emph{Description}:
  1458. This function returns the number of CPUs controlled by StarPU. The returned
  1459. value should be at most @code{STARPU_NMAXCPUS}.
  1460. @item @emph{Prototype}:
  1461. @code{unsigned starpu_cpu_worker_get_count(void);}
  1462. @end table
  1463. @node starpu_cuda_worker_get_count
  1464. @subsection @code{starpu_cuda_worker_get_count} -- Get the number of CUDA devices controlled by StarPU
  1465. @table @asis
  1466. @item @emph{Description}:
  1467. This function returns the number of CUDA devices controlled by StarPU. The returned
  1468. value should be at most @code{STARPU_MAXCUDADEVS}.
  1469. @item @emph{Prototype}:
  1470. @code{unsigned starpu_cuda_worker_get_count(void);}
  1471. @end table
  1472. @node starpu_opencl_worker_get_count
  1473. @subsection @code{starpu_opencl_worker_get_count} -- Get the number of OpenCL devices controlled by StarPU
  1474. @table @asis
  1475. @item @emph{Description}:
  1476. This function returns the number of OpenCL devices controlled by StarPU. The returned
  1477. value should be at most @code{STARPU_MAXOPENCLDEVS}.
  1478. @item @emph{Prototype}:
  1479. @code{unsigned starpu_opencl_worker_get_count(void);}
  1480. @end table
  1481. @node starpu_spu_worker_get_count
  1482. @subsection @code{starpu_spu_worker_get_count} -- Get the number of Cell SPUs controlled by StarPU
  1483. @table @asis
  1484. @item @emph{Description}:
  1485. This function returns the number of Cell SPUs controlled by StarPU.
  1486. @item @emph{Prototype}:
  1487. @code{unsigned starpu_opencl_worker_get_count(void);}
  1488. @end table
  1489. @node starpu_worker_get_id
  1490. @subsection @code{starpu_worker_get_id} -- Get the identifier of the current worker
  1491. @table @asis
  1492. @item @emph{Description}:
  1493. This function returns the identifier of the worker associated to the calling
  1494. thread. The returned value is either -1 if the current context is not a StarPU
  1495. worker (i.e. when called from the application outside a task or a callback), or
  1496. an integer between 0 and @code{starpu_worker_get_count() - 1}.
  1497. @item @emph{Prototype}:
  1498. @code{int starpu_worker_get_id(void);}
  1499. @end table
  1500. @node starpu_worker_get_devid
  1501. @subsection @code{starpu_worker_get_devid} -- Get the device identifier of a worker
  1502. @table @asis
  1503. @item @emph{Description}:
  1504. This functions returns the device id of the worker associated to an identifier
  1505. (as returned by the @code{starpu_worker_get_id} function). In the case of a
  1506. CUDA worker, this device identifier is the logical device identifier exposed by
  1507. CUDA (used by the @code{cudaGetDevice} function for instance). The device
  1508. identifier of a CPU worker is the logical identifier of the core on which the
  1509. worker was bound; this identifier is either provided by the OS or by the
  1510. @code{hwloc} library in case it is available.
  1511. @item @emph{Prototype}:
  1512. @code{int starpu_worker_get_devid(int id);}
  1513. @end table
  1514. @node starpu_worker_get_type
  1515. @subsection @code{starpu_worker_get_type} -- Get the type of processing unit associated to a worker
  1516. @table @asis
  1517. @item @emph{Description}:
  1518. This function returns the type of worker associated to an identifier (as
  1519. returned by the @code{starpu_worker_get_id} function). The returned value
  1520. indicates the architecture of the worker: @code{STARPU_CPU_WORKER} for a CPU
  1521. core, @code{STARPU_CUDA_WORKER} for a CUDA device,
  1522. @code{STARPU_OPENCL_WORKER} for a OpenCL device, and
  1523. @code{STARPU_GORDON_WORKER} for a Cell SPU. The value returned for an invalid
  1524. identifier is unspecified.
  1525. @item @emph{Prototype}:
  1526. @code{enum starpu_archtype starpu_worker_get_type(int id);}
  1527. @end table
  1528. @node starpu_worker_get_name
  1529. @subsection @code{starpu_worker_get_name} -- Get the name of a worker
  1530. @table @asis
  1531. @item @emph{Description}:
  1532. StarPU associates a unique human readable string to each processing unit. This
  1533. function copies at most the @code{maxlen} first bytes of the unique string
  1534. associated to a worker identified by its identifier @code{id} into the
  1535. @code{dst} buffer. The caller is responsible for ensuring that the @code{dst}
  1536. is a valid pointer to a buffer of @code{maxlen} bytes at least. Calling this
  1537. function on an invalid identifier results in an unspecified behaviour.
  1538. @item @emph{Prototype}:
  1539. @code{void starpu_worker_get_name(int id, char *dst, size_t maxlen);}
  1540. @end table
  1541. @node starpu_worker_get_memory_node
  1542. @subsection @code{starpu_worker_get_memory_node} -- Get the memory node of a worker
  1543. @table @asis
  1544. @item @emph{Description}:
  1545. This function returns the identifier of the memory node associated to the
  1546. worker identified by @code{workerid}.
  1547. @item @emph{Prototype}:
  1548. @code{unsigned starpu_worker_get_memory_node(unsigned workerid);}
  1549. @end table
  1550. @node Data Library
  1551. @section Data Library
  1552. This section describes the data management facilities provided by StarPU.
  1553. We show how to use existing data interfaces in @ref{Data Interfaces}, but developers can
  1554. design their own data interfaces if required.
  1555. @menu
  1556. * starpu_access_mode:: starpu_access_mode
  1557. * unsigned memory_node:: Memory node
  1558. * starpu_data_handle:: StarPU opaque data handle
  1559. * void *interface:: StarPU data interface
  1560. * starpu_data_register:: Register a piece of data to StarPU
  1561. * starpu_data_unregister:: Unregister a piece of data from StarPU
  1562. * starpu_data_invalidate:: Invalidate all data replicates
  1563. * starpu_data_acquire:: Access registered data from the application
  1564. * starpu_data_acquire_cb:: Access registered data from the application asynchronously
  1565. * starpu_data_release:: Release registered data from the application
  1566. @end menu
  1567. @node starpu_access_mode
  1568. @subsection @code{starpu_access_mode} -- Data access mode
  1569. This datatype describes a data access mode. The different available modes are:
  1570. @table @asis
  1571. @table @asis
  1572. @item @code{STARPU_R} read-only mode.
  1573. @item @code{STARPU_W} write-only mode.
  1574. @item @code{STARPU_RW} read-write mode. This is equivalent to @code{STARPU_R|STARPU_W}.
  1575. @item @code{STARPU_SCRATCH} scratch memory. A temporary buffer is allocated for the task, but StarPU does not enforce data consistency.
  1576. @end table
  1577. @end table
  1578. @node unsigned memory_node
  1579. @subsection @code{unsigned memory_node} -- Memory node
  1580. @table @asis
  1581. @item @emph{Description}:
  1582. Every worker is associated to a memory node which is a logical abstraction of
  1583. the address space from which the processing unit gets its data. For instance,
  1584. the memory node associated to the different CPU workers represents main memory
  1585. (RAM), the memory node associated to a GPU is DRAM embedded on the device.
  1586. Every memory node is identified by a logical index which is accessible from the
  1587. @code{starpu_worker_get_memory_node} function. When registering a piece of data
  1588. to StarPU, the specified memory node indicates where the piece of data
  1589. initially resides (we also call this memory node the home node of a piece of
  1590. data).
  1591. @end table
  1592. @node starpu_data_handle
  1593. @subsection @code{starpu_data_handle} -- StarPU opaque data handle
  1594. @table @asis
  1595. @item @emph{Description}:
  1596. StarPU uses @code{starpu_data_handle} as an opaque handle to manage a piece of
  1597. data. Once a piece of data has been registered to StarPU, it is associated to a
  1598. @code{starpu_data_handle} which keeps track of the state of the piece of data
  1599. over the entire machine, so that we can maintain data consistency and locate
  1600. data replicates for instance.
  1601. @end table
  1602. @node void *interface
  1603. @subsection @code{void *interface} -- StarPU data interface
  1604. @table @asis
  1605. @item @emph{Description}:
  1606. Data management is done at a high-level in StarPU: rather than accessing a mere
  1607. list of contiguous buffers, the tasks may manipulate data that are described by
  1608. a high-level construct which we call data interface.
  1609. An example of data interface is the "vector" interface which describes a
  1610. contiguous data array on a spefic memory node. This interface is a simple
  1611. structure containing the number of elements in the array, the size of the
  1612. elements, and the address of the array in the appropriate address space (this
  1613. address may be invalid if there is no valid copy of the array in the memory
  1614. node). More informations on the data interfaces provided by StarPU are
  1615. given in @ref{Data Interfaces}.
  1616. When a piece of data managed by StarPU is used by a task, the task
  1617. implementation is given a pointer to an interface describing a valid copy of
  1618. the data that is accessible from the current processing unit.
  1619. @end table
  1620. @node starpu_data_register
  1621. @subsection @code{starpu_data_register} -- Register a piece of data to StarPU
  1622. @table @asis
  1623. @item @emph{Description}:
  1624. Register a piece of data into the handle located at the @code{handleptr}
  1625. address. The @code{interface} buffer contains the initial description of the
  1626. data in the home node. The @code{ops} argument is a pointer to a structure
  1627. describing the different methods used to manipulate this type of interface. See
  1628. @ref{struct starpu_data_interface_ops_t} for more details on this structure.
  1629. If @code{home_node} is not a valid memory node, StarPU will automatically
  1630. allocate the memory described by the interface the data handle is used for the
  1631. first time in write-only mode. Once such data handle has been automatically
  1632. allocated, it is possible to access it using any access mode.
  1633. Note that StarPU supplies a set of predefined types of interface (e.g. vector or
  1634. matrix) which can be registered by the means of helper functions (e.g.
  1635. @code{starpu_vector_data_register} or @code{starpu_matrix_data_register}).
  1636. @item @emph{Prototype}:
  1637. @code{void starpu_data_register(starpu_data_handle *handleptr,
  1638. uint32_t home_node,
  1639. void *interface,
  1640. struct starpu_data_interface_ops_t *ops);}
  1641. @end table
  1642. @node starpu_data_unregister
  1643. @subsection @code{starpu_data_unregister} -- Unregister a piece of data from StarPU
  1644. @table @asis
  1645. @item @emph{Description}:
  1646. This function unregisters a data handle from StarPU. If the data was
  1647. automatically allocated by StarPU because the home node was not valid, all
  1648. automatically allocated buffers are freed. Otherwise, a valid copy of the data
  1649. is put back into the home node in the buffer that was initially registered.
  1650. Using a data handle that has been unregistered from StarPU results in an
  1651. undefined behaviour.
  1652. @item @emph{Prototype}:
  1653. @code{void starpu_data_unregister(starpu_data_handle handle);}
  1654. @end table
  1655. @node starpu_data_invalidate
  1656. @subsection @code{starpu_data_invalidate} -- Invalidate all data replicates
  1657. @table @asis
  1658. @item @emph{Description}:
  1659. Destroy all replicates of the data handle. After data invalidation, the first
  1660. access to the handle must be performed in write-only mode. Accessing an
  1661. invalidated data in read-mode results in undefined behaviour.
  1662. @item @emph{Prototype}:
  1663. @code{void starpu_data_invalidate(starpu_data_handle handle);}
  1664. @end table
  1665. @c TODO create a specific sections about user interaction with the DSM ?
  1666. @node starpu_data_acquire
  1667. @subsection @code{starpu_data_acquire} -- Access registered data from the application
  1668. @table @asis
  1669. @item @emph{Description}:
  1670. The application must call this function prior to accessing registered data from
  1671. main memory outside tasks. StarPU ensures that the application will get an
  1672. up-to-date copy of the data in main memory located where the data was
  1673. originally registered, and that all concurrent accesses (e.g. from tasks) will
  1674. be consistent with the access mode specified in the @code{mode} argument.
  1675. @code{starpu_data_release} must be called once the application does not need to
  1676. access the piece of data anymore.
  1677. Note that implicit data dependencies are also enforced by
  1678. @code{starpu_data_acquire} in case they are enabled.
  1679. @code{starpu_data_acquire} is a blocking call, so that it cannot be called from
  1680. tasks or from their callbacks (in that case, @code{starpu_data_acquire} returns
  1681. @code{-EDEADLK}). Upon successful completion, this function returns 0.
  1682. @item @emph{Prototype}:
  1683. @code{int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode);}
  1684. @end table
  1685. @node starpu_data_acquire_cb
  1686. @subsection @code{starpu_data_acquire_cb} -- Access registered data from the application asynchronously
  1687. @table @asis
  1688. @item @emph{Description}:
  1689. @code{starpu_data_acquire_cb} is the asynchronous equivalent of
  1690. @code{starpu_data_release}. When the data specified in the first argument is
  1691. available in the appropriate access mode, the callback function is executed.
  1692. The application may access the requested data during the execution of this
  1693. callback. The callback function must call @code{starpu_data_release} once the
  1694. application does not need to access the piece of data anymore.
  1695. Note that implicit data dependencies are also enforced by
  1696. @code{starpu_data_acquire} in case they are enabled.
  1697. Contrary to @code{starpu_data_acquire}, this function is non-blocking and may
  1698. be called from task callbacks. Upon successful completion, this function
  1699. returns 0.
  1700. @item @emph{Prototype}:
  1701. @code{int starpu_data_acquire_cb(starpu_data_handle handle, starpu_access_mode mode, void (*callback)(void *), void *arg);}
  1702. @end table
  1703. @node starpu_data_release
  1704. @subsection @code{starpu_data_release} -- Release registered data from the application
  1705. @table @asis
  1706. @item @emph{Description}:
  1707. This function releases the piece of data acquired by the application either by
  1708. @code{starpu_data_acquire} or by @code{starpu_data_acquire_cb}.
  1709. @item @emph{Prototype}:
  1710. @code{void starpu_data_release(starpu_data_handle handle);}
  1711. @end table
  1712. @node Data Interfaces
  1713. @section Data Interfaces
  1714. @menu
  1715. * Variable Interface::
  1716. * Vector Interface::
  1717. * Matrix Interface::
  1718. * BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)::
  1719. * CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)::
  1720. * Block Interface::
  1721. @end menu
  1722. @node Variable Interface
  1723. @subsection Variable Interface
  1724. @table @asis
  1725. @item @emph{Description}:
  1726. @item @emph{Prototype}:
  1727. @code{void starpu_variable_data_register(starpu_data_handle *handle,
  1728. uint32_t home_node,
  1729. uintptr_t ptr, size_t elemsize);}
  1730. @item @emph{Example}:
  1731. @cartouche
  1732. @smallexample
  1733. float var;
  1734. starpu_data_handle var_handle;
  1735. starpu_variable_data_register(&var_handle, 0, (uintptr_t)&var, sizeof(var));
  1736. @end smallexample
  1737. @end cartouche
  1738. @end table
  1739. @node Vector Interface
  1740. @subsection Vector Interface
  1741. @table @asis
  1742. @item @emph{Description}:
  1743. @item @emph{Prototype}:
  1744. @code{void starpu_vector_data_register(starpu_data_handle *handle, uint32_t home_node,
  1745. uintptr_t ptr, uint32_t nx, size_t elemsize);}
  1746. @item @emph{Example}:
  1747. @cartouche
  1748. @smallexample
  1749. float vector[NX];
  1750. starpu_data_handle vector_handle;
  1751. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector, NX,
  1752. sizeof(vector[0]));
  1753. @end smallexample
  1754. @end cartouche
  1755. @end table
  1756. @node Matrix Interface
  1757. @subsection Matrix Interface
  1758. @table @asis
  1759. @item @emph{Description}:
  1760. @item @emph{Prototype}:
  1761. @code{void starpu_matrix_data_register(starpu_data_handle *handle, uint32_t home_node,
  1762. uintptr_t ptr, uint32_t ld, uint32_t nx,
  1763. uint32_t ny, size_t elemsize);}
  1764. @item @emph{Example}:
  1765. @cartouche
  1766. @smallexample
  1767. float *matrix;
  1768. starpu_data_handle matrix_handle;
  1769. matrix = (float*)malloc(width * height * sizeof(float));
  1770. starpu_matrix_data_register(&matrix_handle, 0, (uintptr_t)matrix,
  1771. width, width, height, sizeof(float));
  1772. @end smallexample
  1773. @end cartouche
  1774. @end table
  1775. @node BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)
  1776. @subsection BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)
  1777. @table @asis
  1778. @item @emph{Description}:
  1779. @item @emph{Prototype}:
  1780. @code{void starpu_bcsr_data_register(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  1781. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, uint32_t r, uint32_t c, size_t elemsize);}
  1782. @item @emph{Example}:
  1783. @cartouche
  1784. @smallexample
  1785. @end smallexample
  1786. @end cartouche
  1787. @end table
  1788. @node CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)
  1789. @subsection CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)
  1790. @table @asis
  1791. @item @emph{Description}:
  1792. @item @emph{Prototype}:
  1793. @code{void starpu_csr_data_register(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  1794. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);}
  1795. @item @emph{Example}:
  1796. @cartouche
  1797. @smallexample
  1798. @end smallexample
  1799. @end cartouche
  1800. @end table
  1801. @node Block Interface
  1802. @subsection Block Interface
  1803. @table @asis
  1804. @item @emph{Description}:
  1805. @item @emph{Prototype}:
  1806. @code{void starpu_block_data_register(starpu_data_handle *handle, uint32_t home_node,
  1807. uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx,
  1808. uint32_t ny, uint32_t nz, size_t elemsize);}
  1809. @item @emph{Example}:
  1810. @cartouche
  1811. @smallexample
  1812. float *block;
  1813. starpu_data_handle block_handle;
  1814. block = (float*)malloc(nx*ny*nz*sizeof(float));
  1815. starpu_block_data_register(&block_handle, 0, (uintptr_t)block,
  1816. nx, nx*ny, nx, ny, nz, sizeof(float));
  1817. @end smallexample
  1818. @end cartouche
  1819. @end table
  1820. @node Data Partition
  1821. @section Data Partition
  1822. @menu
  1823. * struct starpu_data_filter:: StarPU filter structure
  1824. * starpu_data_partition:: Partition Data
  1825. * starpu_data_unpartition:: Unpartition Data
  1826. * starpu_data_get_nb_children::
  1827. * starpu_data_get_sub_data::
  1828. * Predefined filter functions::
  1829. @end menu
  1830. @node struct starpu_data_filter
  1831. @subsection @code{struct starpu_data_filter} -- StarPU filter structure
  1832. @table @asis
  1833. @item @emph{Description}:
  1834. The filter structure describes a data partitioning function.
  1835. @item @emph{Fields}:
  1836. @table @asis
  1837. @item @code{filter_func}:
  1838. TODO
  1839. @code{void (*filter_func)(void *father_interface, void* child_interface, struct starpu_data_filter *, unsigned id, unsigned nparts);}
  1840. @item @code{get_nchildren}:
  1841. TODO
  1842. @code{unsigned (*get_nchildren)(struct starpu_data_filter *, starpu_data_handle initial_handle);}
  1843. @item @code{get_child_ops}:
  1844. TODO
  1845. @code{struct starpu_data_interface_ops_t *(*get_child_ops)(struct starpu_data_filter *, unsigned id);}
  1846. @item @code{filter_arg}:
  1847. TODO
  1848. @item @code{nchildren}:
  1849. TODO
  1850. @item @code{filter_arg_ptr}:
  1851. TODO
  1852. @end table
  1853. @end table
  1854. @node starpu_data_partition
  1855. @subsection starpu_data_partition -- Partition Data
  1856. @table @asis
  1857. @item @emph{Description}:
  1858. TODO
  1859. @item @emph{Prototype}:
  1860. @code{void starpu_data_partition(starpu_data_handle initial_handle, struct starpu_data_filter *f);}
  1861. @end table
  1862. @node starpu_data_unpartition
  1863. @subsection starpu_data_unpartition -- Unpartition data
  1864. @table @asis
  1865. @item @emph{Description}:
  1866. TODO
  1867. @item @emph{Prototype}:
  1868. @code{void starpu_data_unpartition(starpu_data_handle root_data, uint32_t gathering_node);}
  1869. @end table
  1870. @node starpu_data_get_nb_children
  1871. @subsection starpu_data_get_nb_children
  1872. @table @asis
  1873. @item @emph{Description}:
  1874. TODO
  1875. @item @emph{Return value}:
  1876. This function returns returns the number of children.
  1877. @item @emph{Prototype}:
  1878. @code{int starpu_data_get_nb_children(starpu_data_handle handle);}
  1879. @end table
  1880. @c starpu_data_handle starpu_data_get_child(starpu_data_handle handle, unsigned i);
  1881. @node starpu_data_get_sub_data
  1882. @subsection starpu_data_get_sub_data
  1883. @table @asis
  1884. @item @emph{Description}:
  1885. TODO
  1886. @item @emph{Return value}:
  1887. TODO
  1888. @item @emph{Prototype}:
  1889. @code{starpu_data_handle starpu_data_get_sub_data(starpu_data_handle root_data, unsigned depth, ... );}
  1890. @end table
  1891. @node Predefined filter functions
  1892. @subsection Predefined filter functions
  1893. @menu
  1894. * Partitioning BCSR Data::
  1895. * Partitioning BLAS interface::
  1896. * Partitioning Vector Data::
  1897. * Partitioning Block Data::
  1898. @end menu
  1899. This section gives a list of the predefined partitioning functions.
  1900. Examples on how to use them are shown in @ref{Partitioning Data}.
  1901. @node Partitioning BCSR Data
  1902. @subsubsection Partitioning BCSR Data
  1903. @itemize
  1904. @item
  1905. TODO
  1906. @code{void starpu_canonical_block_filter_bcsr(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1907. @item
  1908. TODO
  1909. @code{void starpu_vertical_block_filter_func_csr(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1910. @end itemize
  1911. @node Partitioning BLAS interface
  1912. @subsubsection Partitioning BLAS interface
  1913. @itemize
  1914. @item
  1915. TODO
  1916. @code{void starpu_block_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1917. @item
  1918. TODO
  1919. @code{void starpu_vertical_block_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1920. @end itemize
  1921. @node Partitioning Vector Data
  1922. @subsubsection Partitioning Vector Data
  1923. @itemize
  1924. @item
  1925. TODO
  1926. @code{void starpu_block_filter_func_vector(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1927. @item
  1928. TODO
  1929. @code{void starpu_vector_list_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1930. @item
  1931. TODO
  1932. @code{void starpu_vector_divide_in_2_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1933. @end itemize
  1934. @node Partitioning Block Data
  1935. @subsubsection Partitioning Block Data
  1936. @itemize
  1937. @item
  1938. TODO
  1939. @code{void starpu_block_filter_func_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1940. @end itemize
  1941. @node Codelets and Tasks
  1942. @section Codelets and Tasks
  1943. @menu
  1944. * struct starpu_codelet:: StarPU codelet structure
  1945. * struct starpu_task:: StarPU task structure
  1946. * starpu_task_init:: Initialize a Task
  1947. * starpu_task_create:: Allocate and Initialize a Task
  1948. * starpu_task_deinit:: Release all the resources used by a Task
  1949. * starpu_task_destroy:: Destroy a dynamically allocated Task
  1950. * starpu_task_wait:: Wait for the termination of a Task
  1951. * starpu_task_submit:: Submit a Task
  1952. * starpu_task_wait_for_all:: Wait for the termination of all Tasks
  1953. * starpu_get_current_task:: Return the task currently executed by the worker
  1954. * starpu_display_codelet_stats:: Display statistics
  1955. @end menu
  1956. @node struct starpu_codelet
  1957. @subsection @code{struct starpu_codelet} -- StarPU codelet structure
  1958. @table @asis
  1959. @item @emph{Description}:
  1960. The codelet structure describes a kernel that is possibly implemented on
  1961. various targets.
  1962. @item @emph{Fields}:
  1963. @table @asis
  1964. @item @code{where}:
  1965. Indicates which types of processing units are able to execute the codelet.
  1966. @code{STARPU_CPU|STARPU_CUDA} for instance indicates that the codelet is
  1967. implemented for both CPU cores and CUDA devices while @code{STARPU_GORDON}
  1968. indicates that it is only available on Cell SPUs.
  1969. @item @code{cpu_func} (optional):
  1970. Is a function pointer to the CPU implementation of the codelet. Its prototype
  1971. must be: @code{void cpu_func(void *buffers[], void *cl_arg)}. The first
  1972. argument being the array of data managed by the data management library, and
  1973. the second argument is a pointer to the argument passed from the @code{cl_arg}
  1974. field of the @code{starpu_task} structure.
  1975. The @code{cpu_func} field is ignored if @code{STARPU_CPU} does not appear in
  1976. the @code{where} field, it must be non-null otherwise.
  1977. @item @code{cuda_func} (optional):
  1978. Is a function pointer to the CUDA implementation of the codelet. @emph{This
  1979. must be a host-function written in the CUDA runtime API}. Its prototype must
  1980. be: @code{void cuda_func(void *buffers[], void *cl_arg);}. The @code{cuda_func}
  1981. field is ignored if @code{STARPU_CUDA} does not appear in the @code{where}
  1982. field, it must be non-null otherwise.
  1983. @item @code{opencl_func} (optional):
  1984. Is a function pointer to the OpenCL implementation of the codelet. Its
  1985. prototype must be:
  1986. @code{void opencl_func(starpu_data_interface_t *descr, void *arg);}.
  1987. This pointer is ignored if @code{STARPU_OPENCL} does not appear in the
  1988. @code{where} field, it must be non-null otherwise.
  1989. @item @code{gordon_func} (optional):
  1990. This is the index of the Cell SPU implementation within the Gordon library.
  1991. See Gordon documentation for more details on how to register a kernel and
  1992. retrieve its index.
  1993. @item @code{nbuffers}:
  1994. Specifies the number of arguments taken by the codelet. These arguments are
  1995. managed by the DSM and are accessed from the @code{void *buffers[]}
  1996. array. The constant argument passed with the @code{cl_arg} field of the
  1997. @code{starpu_task} structure is not counted in this number. This value should
  1998. not be above @code{STARPU_NMAXBUFS}.
  1999. @item @code{model} (optional):
  2000. This is a pointer to the performance model associated to this codelet. This
  2001. optional field is ignored when set to @code{NULL}. TODO
  2002. @end table
  2003. @end table
  2004. @node struct starpu_task
  2005. @subsection @code{struct starpu_task} -- StarPU task structure
  2006. @table @asis
  2007. @item @emph{Description}:
  2008. The @code{starpu_task} structure describes a task that can be offloaded on the various
  2009. processing units managed by StarPU. It instantiates a codelet. It can either be
  2010. allocated dynamically with the @code{starpu_task_create} method, or declared
  2011. statically. In the latter case, the programmer has to zero the
  2012. @code{starpu_task} structure and to fill the different fields properly. The
  2013. indicated default values correspond to the configuration of a task allocated
  2014. with @code{starpu_task_create}.
  2015. @item @emph{Fields}:
  2016. @table @asis
  2017. @item @code{cl}:
  2018. Is a pointer to the corresponding @code{starpu_codelet} data structure. This
  2019. describes where the kernel should be executed, and supplies the appropriate
  2020. implementations. When set to @code{NULL}, no code is executed during the tasks,
  2021. such empty tasks can be useful for synchronization purposes.
  2022. @item @code{buffers}:
  2023. Is an array of @code{starpu_buffer_descr_t} structures. It describes the
  2024. different pieces of data accessed by the task, and how they should be accessed.
  2025. The @code{starpu_buffer_descr_t} structure is composed of two fields, the
  2026. @code{handle} field specifies the handle of the piece of data, and the
  2027. @code{mode} field is the required access mode (eg @code{STARPU_RW}). The number
  2028. of entries in this array must be specified in the @code{nbuffers} field of the
  2029. @code{starpu_codelet} structure, and should not excede @code{STARPU_NMAXBUFS}.
  2030. If unsufficient, this value can be set with the @code{--enable-maxbuffers}
  2031. option when configuring StarPU.
  2032. @item @code{cl_arg} (optional) (default = NULL):
  2033. This pointer is passed to the codelet through the second argument
  2034. of the codelet implementation (e.g. @code{cpu_func} or @code{cuda_func}).
  2035. In the specific case of the Cell processor, see the @code{cl_arg_size}
  2036. argument.
  2037. @item @code{cl_arg_size} (optional, Cell specific):
  2038. In the case of the Cell processor, the @code{cl_arg} pointer is not directly
  2039. given to the SPU function. A buffer of size @code{cl_arg_size} is allocated on
  2040. the SPU. This buffer is then filled with the @code{cl_arg_size} bytes starting
  2041. at address @code{cl_arg}. In this case, the argument given to the SPU codelet
  2042. is therefore not the @code{cl_arg} pointer, but the address of the buffer in
  2043. local store (LS) instead. This field is ignored for CPU, CUDA and OpenCL
  2044. codelets.
  2045. @item @code{callback_func} (optional) (default = @code{NULL}):
  2046. This is a function pointer of prototype @code{void (*f)(void *)} which
  2047. specifies a possible callback. If this pointer is non-null, the callback
  2048. function is executed @emph{on the host} after the execution of the task. The
  2049. callback is passed the value contained in the @code{callback_arg} field. No
  2050. callback is executed if the field is set to @code{NULL}.
  2051. @item @code{callback_arg} (optional) (default = @code{NULL}):
  2052. This is the pointer passed to the callback function. This field is ignored if
  2053. the @code{callback_func} is set to @code{NULL}.
  2054. @item @code{use_tag} (optional) (default = 0):
  2055. If set, this flag indicates that the task should be associated with the tag
  2056. contained in the @code{tag_id} field. Tag allow the application to synchronize
  2057. with the task and to express task dependencies easily.
  2058. @item @code{tag_id}:
  2059. This fields contains the tag associated to the task if the @code{use_tag} field
  2060. was set, it is ignored otherwise.
  2061. @item @code{synchronous}:
  2062. If this flag is set, the @code{starpu_task_submit} function is blocking and
  2063. returns only when the task has been executed (or if no worker is able to
  2064. process the task). Otherwise, @code{starpu_task_submit} returns immediately.
  2065. @item @code{priority} (optional) (default = @code{STARPU_DEFAULT_PRIO}):
  2066. This field indicates a level of priority for the task. This is an integer value
  2067. that must be set between @code{STARPU_MIN_PRIO} (for the least important
  2068. tasks) and @code{STARPU_MAX_PRIO} (for the most important tasks) included.
  2069. Default priority is @code{STARPU_DEFAULT_PRIO}. Scheduling strategies that
  2070. take priorities into account can use this parameter to take better scheduling
  2071. decisions, but the scheduling policy may also ignore it.
  2072. @item @code{execute_on_a_specific_worker} (default = 0):
  2073. If this flag is set, StarPU will bypass the scheduler and directly affect this
  2074. task to the worker specified by the @code{workerid} field.
  2075. @item @code{workerid} (optional):
  2076. If the @code{execute_on_a_specific_worker} field is set, this field indicates
  2077. which is the identifier of the worker that should process this task (as
  2078. returned by @code{starpu_worker_get_id}). This field is ignored if
  2079. @code{execute_on_a_specific_worker} field is set to 0.
  2080. @item @code{detach} (optional) (default = 1):
  2081. If this flag is set, it is not possible to synchronize with the task
  2082. by the means of @code{starpu_task_wait} later on. Internal data structures
  2083. are only guaranteed to be freed once @code{starpu_task_wait} is called if the
  2084. flag is not set.
  2085. @item @code{destroy} (optional) (default = 1):
  2086. If this flag is set, the task structure will automatically be freed, either
  2087. after the execution of the callback if the task is detached, or during
  2088. @code{starpu_task_wait} otherwise. If this flag is not set, dynamically
  2089. allocated data structures will not be freed until @code{starpu_task_destroy} is
  2090. called explicitly. Setting this flag for a statically allocated task structure
  2091. will result in undefined behaviour.
  2092. @item @code{predicted} (output field):
  2093. Predicted duration of the task. This field is only set if the scheduling
  2094. strategy used performance models.
  2095. @end table
  2096. @end table
  2097. @node starpu_task_init
  2098. @subsection @code{starpu_task_init} -- Initialize a Task
  2099. @table @asis
  2100. @item @emph{Description}:
  2101. Initialize a task structure with default values. This function is implicitly
  2102. called by @code{starpu_task_create}. By default, tasks initialized with
  2103. @code{starpu_task_init} must be deinitialized explicitly with
  2104. @code{starpu_task_deinit}. Tasks can also be initialized statically, using the
  2105. constant @code{STARPU_TASK_INITIALIZER}.
  2106. @item @emph{Prototype}:
  2107. @code{void starpu_task_init(struct starpu_task *task);}
  2108. @end table
  2109. @node starpu_task_create
  2110. @subsection @code{starpu_task_create} -- Allocate and Initialize a Task
  2111. @table @asis
  2112. @item @emph{Description}:
  2113. Allocate a task structure and initialize it with default values. Tasks
  2114. allocated dynamically with @code{starpu_task_create} are automatically freed when the
  2115. task is terminated. If the destroy flag is explicitly unset, the resources used
  2116. by the task are freed by calling
  2117. @code{starpu_task_destroy}.
  2118. @item @emph{Prototype}:
  2119. @code{struct starpu_task *starpu_task_create(void);}
  2120. @end table
  2121. @node starpu_task_deinit
  2122. @subsection @code{starpu_task_deinit} -- Release all the resources used by a Task
  2123. @table @asis
  2124. @item @emph{Description}:
  2125. Release all the structures automatically allocated to execute the task. This is
  2126. called automatically by @code{starpu_task_destroy}, but the task structure itself is not
  2127. freed. This should be used for statically allocated tasks for instance.
  2128. @item @emph{Prototype}:
  2129. @code{void starpu_task_deinit(struct starpu_task *task);}
  2130. @end table
  2131. @node starpu_task_destroy
  2132. @subsection @code{starpu_task_destroy} -- Destroy a dynamically allocated Task
  2133. @table @asis
  2134. @item @emph{Description}:
  2135. Free the resource allocated during @code{starpu_task_create}. This function can be
  2136. called automatically after the execution of a task by setting the
  2137. @code{destroy} flag of the @code{starpu_task} structure (default behaviour).
  2138. Calling this function on a statically allocated task results in an undefined
  2139. behaviour.
  2140. @item @emph{Prototype}:
  2141. @code{void starpu_task_destroy(struct starpu_task *task);}
  2142. @end table
  2143. @node starpu_task_wait
  2144. @subsection @code{starpu_task_wait} -- Wait for the termination of a Task
  2145. @table @asis
  2146. @item @emph{Description}:
  2147. This function blocks until the task has been executed. It is not possible to
  2148. synchronize with a task more than once. It is not possible to wait for
  2149. synchronous or detached tasks.
  2150. @item @emph{Return value}:
  2151. Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
  2152. indicates that the specified task was either synchronous or detached.
  2153. @item @emph{Prototype}:
  2154. @code{int starpu_task_wait(struct starpu_task *task);}
  2155. @end table
  2156. @node starpu_task_submit
  2157. @subsection @code{starpu_task_submit} -- Submit a Task
  2158. @table @asis
  2159. @item @emph{Description}:
  2160. This function submits a task to StarPU. Calling this function does
  2161. not mean that the task will be executed immediately as there can be data or task
  2162. (tag) dependencies that are not fulfilled yet: StarPU will take care of
  2163. scheduling this task with respect to such dependencies.
  2164. This function returns immediately if the @code{synchronous} field of the
  2165. @code{starpu_task} structure was set to 0, and block until the termination of
  2166. the task otherwise. It is also possible to synchronize the application with
  2167. asynchronous tasks by the means of tags, using the @code{starpu_tag_wait}
  2168. function for instance.
  2169. @item @emph{Return value}:
  2170. In case of success, this function returns 0, a return value of @code{-ENODEV}
  2171. means that there is no worker able to process this task (e.g. there is no GPU
  2172. available and this task is only implemented for CUDA devices).
  2173. @item @emph{Prototype}:
  2174. @code{int starpu_task_submit(struct starpu_task *task);}
  2175. @end table
  2176. @node starpu_task_wait_for_all
  2177. @subsection @code{starpu_task_wait_for_all} -- Wait for the termination of all Tasks
  2178. @table @asis
  2179. @item @emph{Description}:
  2180. This function blocks until all the tasks that were submitted are terminated.
  2181. @item @emph{Prototype}:
  2182. @code{void starpu_task_wait_for_all(void);}
  2183. @end table
  2184. @node starpu_get_current_task
  2185. @subsection @code{starpu_get_current_task} -- Return the task currently executed by the worker
  2186. @table @asis
  2187. @item @emph{Description}:
  2188. This function returns the task currently executed by the worker, or
  2189. NULL if it is called either from a thread that is not a task or simply
  2190. because there is no task being executed at the moment.
  2191. @item @emph{Prototype}:
  2192. @code{struct starpu_task *starpu_get_current_task(void);}
  2193. @end table
  2194. @node starpu_display_codelet_stats
  2195. @subsection @code{starpu_display_codelet_stats} -- Display statistics
  2196. @table @asis
  2197. @item @emph{Description}:
  2198. TODO
  2199. @item @emph{Prototype}:
  2200. @code{void starpu_display_codelet_stats(struct starpu_codelet_t *cl);}
  2201. @end table
  2202. @c Callbacks : what can we put in callbacks ?
  2203. @node Explicit Dependencies
  2204. @section Explicit Dependencies
  2205. @menu
  2206. * starpu_task_declare_deps_array:: starpu_task_declare_deps_array
  2207. * starpu_tag_t:: Task logical identifier
  2208. * starpu_tag_declare_deps:: Declare the Dependencies of a Tag
  2209. * starpu_tag_declare_deps_array:: Declare the Dependencies of a Tag
  2210. * starpu_tag_wait:: Block until a Tag is terminated
  2211. * starpu_tag_wait_array:: Block until a set of Tags is terminated
  2212. * starpu_tag_remove:: Destroy a Tag
  2213. * starpu_tag_notify_from_apps:: Feed a tag explicitly
  2214. @end menu
  2215. @node starpu_task_declare_deps_array
  2216. @subsection @code{starpu_task_declare_deps_array} -- Declare task dependencies
  2217. @table @asis
  2218. @item @emph{Description}:
  2219. Declare task dependencies between a @code{task} and an array of tasks of length
  2220. @code{ndeps}. This function must be called prior to the submission of the task,
  2221. but it may called after the submission or the execution of the tasks in the
  2222. array provided the tasks are still valid (ie. they were not automatically
  2223. destroyed). Calling this function on a task that was already submitted or with
  2224. an entry of @code{task_array} that is not a valid task anymore results in an
  2225. undefined behaviour. If @code{ndeps} is null, no dependency is added. It is
  2226. possible to call @code{starpu_task_declare_deps_array} multiple times on the
  2227. same task, in this case, the dependencies are added. It is possible to have
  2228. redundancy in the task dependencies.
  2229. @item @emph{Prototype}:
  2230. @code{void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[]);}
  2231. @end table
  2232. @node starpu_tag_t
  2233. @subsection @code{starpu_tag_t} -- Task logical identifier
  2234. @table @asis
  2235. @item @emph{Description}:
  2236. It is possible to associate a task with a unique ``tag'' and to express
  2237. dependencies between tasks by the means of those tags. To do so, fill the
  2238. @code{tag_id} field of the @code{starpu_task} structure with a tag number (can
  2239. be arbitrary) and set the @code{use_tag} field to 1.
  2240. If @code{starpu_tag_declare_deps} is called with this tag number, the task will
  2241. not be started until the tasks which holds the declared dependency tags are
  2242. completed.
  2243. @end table
  2244. @node starpu_tag_declare_deps
  2245. @subsection @code{starpu_tag_declare_deps} -- Declare the Dependencies of a Tag
  2246. @table @asis
  2247. @item @emph{Description}:
  2248. Specify the dependencies of the task identified by tag @code{id}. The first
  2249. argument specifies the tag which is configured, the second argument gives the
  2250. number of tag(s) on which @code{id} depends. The following arguments are the
  2251. tags which have to be terminated to unlock the task.
  2252. This function must be called before the associated task is submitted to StarPU
  2253. with @code{starpu_task_submit}.
  2254. @item @emph{Remark}
  2255. Because of the variable arity of @code{starpu_tag_declare_deps}, note that the
  2256. last arguments @emph{must} be of type @code{starpu_tag_t}: constant values
  2257. typically need to be explicitly casted. Using the
  2258. @code{starpu_tag_declare_deps_array} function avoids this hazard.
  2259. @item @emph{Prototype}:
  2260. @code{void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);}
  2261. @item @emph{Example}:
  2262. @cartouche
  2263. @example
  2264. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  2265. starpu_tag_declare_deps((starpu_tag_t)0x1,
  2266. 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  2267. @end example
  2268. @end cartouche
  2269. @end table
  2270. @node starpu_tag_declare_deps_array
  2271. @subsection @code{starpu_tag_declare_deps_array} -- Declare the Dependencies of a Tag
  2272. @table @asis
  2273. @item @emph{Description}:
  2274. This function is similar to @code{starpu_tag_declare_deps}, except that its
  2275. does not take a variable number of arguments but an array of tags of size
  2276. @code{ndeps}.
  2277. @item @emph{Prototype}:
  2278. @code{void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);}
  2279. @item @emph{Example}:
  2280. @cartouche
  2281. @example
  2282. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  2283. starpu_tag_t tag_array[2] = @{0x32, 0x52@};
  2284. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  2285. @end example
  2286. @end cartouche
  2287. @end table
  2288. @node starpu_tag_wait
  2289. @subsection @code{starpu_tag_wait} -- Block until a Tag is terminated
  2290. @table @asis
  2291. @item @emph{Description}:
  2292. This function blocks until the task associated to tag @code{id} has been
  2293. executed. This is a blocking call which must therefore not be called within
  2294. tasks or callbacks, but only from the application directly. It is possible to
  2295. synchronize with the same tag multiple times, as long as the
  2296. @code{starpu_tag_remove} function is not called. Note that it is still
  2297. possible to synchronize with a tag associated to a task which @code{starpu_task}
  2298. data structure was freed (e.g. if the @code{destroy} flag of the
  2299. @code{starpu_task} was enabled).
  2300. @item @emph{Prototype}:
  2301. @code{void starpu_tag_wait(starpu_tag_t id);}
  2302. @end table
  2303. @node starpu_tag_wait_array
  2304. @subsection @code{starpu_tag_wait_array} -- Block until a set of Tags is terminated
  2305. @table @asis
  2306. @item @emph{Description}:
  2307. This function is similar to @code{starpu_tag_wait} except that it blocks until
  2308. @emph{all} the @code{ntags} tags contained in the @code{id} array are
  2309. terminated.
  2310. @item @emph{Prototype}:
  2311. @code{void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);}
  2312. @end table
  2313. @node starpu_tag_remove
  2314. @subsection @code{starpu_tag_remove} -- Destroy a Tag
  2315. @table @asis
  2316. @item @emph{Description}:
  2317. This function releases the resources associated to tag @code{id}. It can be
  2318. called once the corresponding task has been executed and when there is
  2319. no other tag that depend on this tag anymore.
  2320. @item @emph{Prototype}:
  2321. @code{void starpu_tag_remove(starpu_tag_t id);}
  2322. @end table
  2323. @node starpu_tag_notify_from_apps
  2324. @subsection @code{starpu_tag_notify_from_apps} -- Feed a Tag explicitly
  2325. @table @asis
  2326. @item @emph{Description}:
  2327. This function explicitly unlocks tag @code{id}. It may be useful in the
  2328. case of applications which execute part of their computation outside StarPU
  2329. tasks (e.g. third-party libraries). It is also provided as a
  2330. convenient tool for the programmer, for instance to entirely construct the task
  2331. DAG before actually giving StarPU the opportunity to execute the tasks.
  2332. @item @emph{Prototype}:
  2333. @code{void starpu_tag_notify_from_apps(starpu_tag_t id);}
  2334. @end table
  2335. @node Implicit Data Dependencies
  2336. @section Implicit Data Dependencies
  2337. @menu
  2338. * starpu_data_set_default_sequential_consistency_flag:: starpu_data_set_default_sequential_consistency_flag
  2339. * starpu_data_get_default_sequential_consistency_flag:: starpu_data_get_default_sequential_consistency_flag
  2340. * starpu_data_set_sequential_consistency_flag:: starpu_data_set_sequential_consistency_flag
  2341. @end menu
  2342. In this section, we describe how StarPU makes it possible to insert implicit
  2343. task dependencies in order to enforce sequential data consistency. When this
  2344. data consistency is enabled on a specific data handle, any data access will
  2345. appear as sequentially consistent from the application. For instance, if the
  2346. application submits two tasks that access the same piece of data in read-only
  2347. mode, and then a third task that access it in write mode, dependencies will be
  2348. added between the two first tasks and the third one. Implicit data dependencies
  2349. are also inserted in the case of data accesses from the application.
  2350. @node starpu_data_set_default_sequential_consistency_flag
  2351. @subsection @code{starpu_data_set_default_sequential_consistency_flag} -- Set default sequential consistency flag
  2352. @table @asis
  2353. @item @emph{Description}:
  2354. Set the default sequential consistency flag. If a non-zero value is passed, a
  2355. sequential data consistency will be enforced for all handles registered after
  2356. this function call, otherwise it is disabled. By default, StarPU enables
  2357. sequential data consistency. It is also possible to select the data consistency
  2358. mode of a specific data handle with the
  2359. @code{starpu_data_set_sequential_consistency_flag} function.
  2360. @item @emph{Prototype}:
  2361. @code{void starpu_data_set_default_sequential_consistency_flag(unsigned flag);}
  2362. @end table
  2363. @node starpu_data_get_default_sequential_consistency_flag
  2364. @subsection @code{starpu_data_get_default_sequential_consistency_flag} -- Get current default sequential consistency flag
  2365. @table @asis
  2366. @item @emph{Description}:
  2367. This function returns the current default sequential consistency flag.
  2368. @item @emph{Prototype}:
  2369. @code{unsigned starpu_data_set_default_sequential_consistency_flag(void);}
  2370. @end table
  2371. @node starpu_data_set_sequential_consistency_flag
  2372. @subsection @code{starpu_data_set_sequential_consistency_flag} -- Set data sequential consistency mode
  2373. @table @asis
  2374. @item @emph{Description}:
  2375. Select the data consistency mode associated to a data handle. The consistency
  2376. mode set using this function has the priority over the default mode which can
  2377. be set with @code{starpu_data_set_sequential_consistency_flag}.
  2378. @item @emph{Prototype}:
  2379. @code{void starpu_data_set_sequential_consistency_flag(starpu_data_handle handle, unsigned flag);}
  2380. @end table
  2381. @node Performance Model API
  2382. @section Performance Model API
  2383. @menu
  2384. * starpu_load_history_debug::
  2385. * starpu_perfmodel_debugfilepath::
  2386. * starpu_perfmodel_get_arch_name::
  2387. * starpu_force_bus_sampling::
  2388. @end menu
  2389. @node starpu_load_history_debug
  2390. @subsection @code{starpu_load_history_debug}
  2391. @table @asis
  2392. @item @emph{Description}:
  2393. TODO
  2394. @item @emph{Prototype}:
  2395. @code{int starpu_load_history_debug(const char *symbol, struct starpu_perfmodel_t *model);}
  2396. @end table
  2397. @node starpu_perfmodel_debugfilepath
  2398. @subsection @code{starpu_perfmodel_debugfilepath}
  2399. @table @asis
  2400. @item @emph{Description}:
  2401. TODO
  2402. @item @emph{Prototype}:
  2403. @code{void starpu_perfmodel_debugfilepath(struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch, char *path, size_t maxlen);}
  2404. @end table
  2405. @node starpu_perfmodel_get_arch_name
  2406. @subsection @code{starpu_perfmodel_get_arch_name}
  2407. @table @asis
  2408. @item @emph{Description}:
  2409. TODO
  2410. @item @emph{Prototype}:
  2411. @code{void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch, char *archname, size_t maxlen);}
  2412. @end table
  2413. @node starpu_force_bus_sampling
  2414. @subsection @code{starpu_force_bus_sampling}
  2415. @table @asis
  2416. @item @emph{Description}:
  2417. TODO
  2418. @item @emph{Prototype}:
  2419. @code{void starpu_force_bus_sampling(void);}
  2420. @end table
  2421. @node Profiling API
  2422. @section Profiling API
  2423. @menu
  2424. * starpu_profiling_status_set:: starpu_profiling_status_set
  2425. * starpu_profiling_status_get:: starpu_profiling_status_get
  2426. * struct starpu_task_profiling_info:: task profiling information
  2427. * struct starpu_worker_profiling_info:: worker profiling information
  2428. * starpu_worker_get_profiling_info:: starpu_worker_get_profiling_info
  2429. * struct starpu_bus_profiling_info:: bus profiling information
  2430. * starpu_bus_get_count::
  2431. * starpu_bus_get_id::
  2432. * starpu_bus_get_src::
  2433. * starpu_bus_get_dst::
  2434. * starpu_timing_timespec_delay_us::
  2435. * starpu_timing_timespec_to_us::
  2436. * starpu_bus_profiling_helper_display_summary::
  2437. @end menu
  2438. @node starpu_profiling_status_set
  2439. @subsection @code{starpu_profiling_status_set} -- Set current profiling status
  2440. @table @asis
  2441. @item @emph{Description}:
  2442. Thie function sets the profiling status. Profiling is activated by passing
  2443. @code{STARPU_PROFILING_ENABLE} in @code{status}. Passing
  2444. @code{STARPU_PROFILING_DISABLE} disables profiling. Calling this function
  2445. resets all profiling measurements. When profiling is enabled, the
  2446. @code{profiling_info} field of the @code{struct starpu_task} structure points
  2447. to a valid @code{struct starpu_task_profiling_info} structure containing
  2448. information about the execution of the task.
  2449. @item @emph{Return value}:
  2450. Negative return values indicate an error, otherwise the previous status is
  2451. returned.
  2452. @item @emph{Prototype}:
  2453. @code{int starpu_profiling_status_set(int status);}
  2454. @end table
  2455. @node starpu_profiling_status_get
  2456. @subsection @code{starpu_profiling_status_get} -- Get current profiling status
  2457. @table @asis
  2458. @item @emph{Description}:
  2459. Return the current profiling status or a negative value in case there was an error.
  2460. @item @emph{Prototype}:
  2461. @code{int starpu_profiling_status_get(void);}
  2462. @end table
  2463. @node struct starpu_task_profiling_info
  2464. @subsection @code{struct starpu_task_profiling_info} -- Task profiling information
  2465. @table @asis
  2466. @item @emph{Description}:
  2467. This structure contains information about the execution of a task. It is
  2468. accessible from the @code{.profiling_info} field of the @code{starpu_task}
  2469. structure if profiling was enabled.
  2470. @item @emph{Fields}:
  2471. @table @asis
  2472. @item @code{submit_time}:
  2473. Date of task submission (relative to the initialization of StarPU).
  2474. @item @code{start_time}:
  2475. Date of task execution beginning (relative to the initialization of StarPU).
  2476. @item @code{end_time}:
  2477. Date of task execution termination (relative to the initialization of StarPU).
  2478. @item @code{workerid}:
  2479. Identifier of the worker which has executed the task.
  2480. @end table
  2481. @end table
  2482. @node struct starpu_worker_profiling_info
  2483. @subsection @code{struct starpu_worker_profiling_info} -- Worker profiling information
  2484. @table @asis
  2485. @item @emph{Description}:
  2486. This structure contains the profiling information associated to a worker.
  2487. @item @emph{Fields}:
  2488. @table @asis
  2489. @item @code{start_time}:
  2490. Starting date for the reported profiling measurements.
  2491. @item @code{total_time}:
  2492. Duration of the profiling measurement interval.
  2493. @item @code{executing_time}:
  2494. Time spent by the worker to execute tasks during the profiling measurement interval.
  2495. @item @code{sleeping_time}:
  2496. Time spent idling by the worker during the profiling measurement interval.
  2497. @item @code{executed_tasks}:
  2498. Number of tasks executed by the worker during the profiling measurement interval.
  2499. @end table
  2500. @end table
  2501. @node starpu_worker_get_profiling_info
  2502. @subsection @code{starpu_worker_get_profiling_info} -- Get worker profiling info
  2503. @table @asis
  2504. @item @emph{Description}:
  2505. Get the profiling info associated to the worker identified by @code{workerid},
  2506. and reset the profiling measurements. If the @code{worker_info} argument is
  2507. NULL, only reset the counters associated to worker @code{workerid}.
  2508. @item @emph{Return value}:
  2509. Upon successful completion, this function returns 0. Otherwise, a negative
  2510. value is returned.
  2511. @item @emph{Prototype}:
  2512. @code{int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profiling_info *worker_info);}
  2513. @end table
  2514. @node struct starpu_bus_profiling_info
  2515. @subsection @code{struct starpu_bus_profiling_info} -- Bus profiling information
  2516. @table @asis
  2517. @item @emph{Description}:
  2518. TODO
  2519. @item @emph{Fields}:
  2520. @table @asis
  2521. @item @code{start_time}:
  2522. TODO
  2523. @item @code{total_time}:
  2524. TODO
  2525. @item @code{transferred_bytes}:
  2526. TODO
  2527. @item @code{transfer_count}:
  2528. TODO
  2529. @end table
  2530. @end table
  2531. @node starpu_bus_get_count
  2532. @subsection @code{starpu_bus_get_count}
  2533. @table @asis
  2534. @item @emph{Description}:
  2535. TODO
  2536. @item @emph{Prototype}:
  2537. @code{int starpu_bus_get_count(void);}
  2538. @end table
  2539. @node starpu_bus_get_id
  2540. @subsection @code{starpu_bus_get_id}
  2541. @table @asis
  2542. @item @emph{Description}:
  2543. TODO
  2544. @item @emph{Prototype}:
  2545. @code{int starpu_bus_get_id(int src, int dst);}
  2546. @end table
  2547. @node starpu_bus_get_src
  2548. @subsection @code{starpu_bus_get_src}
  2549. @table @asis
  2550. @item @emph{Description}:
  2551. TODO
  2552. @item @emph{Prototype}:
  2553. @code{int starpu_bus_get_src(int busid);}
  2554. @end table
  2555. @node starpu_bus_get_dst
  2556. @subsection @code{starpu_bus_get_dst}
  2557. @table @asis
  2558. @item @emph{Description}:
  2559. TODO
  2560. @item @emph{Prototype}:
  2561. @code{int starpu_bus_get_dst(int busid);}
  2562. @end table
  2563. @node starpu_timing_timespec_delay_us
  2564. @subsection @code{starpu_timing_timespec_delay_us}
  2565. @table @asis
  2566. @item @emph{Description}:
  2567. TODO
  2568. @item @emph{Prototype}:
  2569. @code{double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);}
  2570. @end table
  2571. @node starpu_timing_timespec_to_us
  2572. @subsection @code{starpu_timing_timespec_to_us}
  2573. @table @asis
  2574. @item @emph{Description}:
  2575. TODO
  2576. @item @emph{Prototype}:
  2577. @code{double starpu_timing_timespec_to_us(struct timespec *ts);}
  2578. @end table
  2579. @node starpu_bus_profiling_helper_display_summary
  2580. @subsection @code{starpu_bus_profiling_helper_display_summary}
  2581. @table @asis
  2582. @item @emph{Description}:
  2583. TODO
  2584. @item @emph{Prototype}:
  2585. @code{void starpu_bus_profiling_helper_display_summary(void);}
  2586. @end table
  2587. @node CUDA extensions
  2588. @section CUDA extensions
  2589. @c void starpu_data_malloc_pinned_if_possible(float **A, size_t dim);
  2590. @menu
  2591. * starpu_cuda_get_local_stream:: Get current worker's CUDA stream
  2592. * starpu_helper_cublas_init:: Initialize CUBLAS on every CUDA device
  2593. * starpu_helper_cublas_shutdown:: Deinitialize CUBLAS on every CUDA device
  2594. @end menu
  2595. @node starpu_cuda_get_local_stream
  2596. @subsection @code{starpu_cuda_get_local_stream} -- Get current worker's CUDA stream
  2597. @table @asis
  2598. @item @emph{Description}:
  2599. StarPU provides a stream for every CUDA device controlled by StarPU. This
  2600. function is only provided for convenience so that programmers can easily use
  2601. asynchronous operations within codelets without having to create a stream by
  2602. hand. Note that the application is not forced to use the stream provided by
  2603. @code{starpu_cuda_get_local_stream} and may also create its own streams.
  2604. @item @emph{Prototype}:
  2605. @code{cudaStream_t *starpu_cuda_get_local_stream(void);}
  2606. @end table
  2607. @node starpu_helper_cublas_init
  2608. @subsection @code{starpu_helper_cublas_init} -- Initialize CUBLAS on every CUDA device
  2609. @table @asis
  2610. @item @emph{Description}:
  2611. The CUBLAS library must be initialized prior to any CUBLAS call. Calling
  2612. @code{starpu_helper_cublas_init} will initialize CUBLAS on every CUDA device
  2613. controlled by StarPU. This call blocks until CUBLAS has been properly
  2614. initialized on every device.
  2615. @item @emph{Prototype}:
  2616. @code{void starpu_helper_cublas_init(void);}
  2617. @end table
  2618. @node starpu_helper_cublas_shutdown
  2619. @subsection @code{starpu_helper_cublas_shutdown} -- Deinitialize CUBLAS on every CUDA device
  2620. @table @asis
  2621. @item @emph{Description}:
  2622. This function synchronously deinitializes the CUBLAS library on every CUDA device.
  2623. @item @emph{Prototype}:
  2624. @code{void starpu_helper_cublas_shutdown(void);}
  2625. @end table
  2626. @node OpenCL extensions
  2627. @section OpenCL extensions
  2628. @menu
  2629. * Enabling OpenCL:: Enabling OpenCL
  2630. * Compiling OpenCL codelets:: Compiling OpenCL codelets
  2631. * Loading OpenCL codelets:: Loading OpenCL codelets
  2632. @end menu
  2633. @node Enabling OpenCL
  2634. @subsection Enabling OpenCL
  2635. On GPU devices which can run both CUDA and OpenCL, CUDA will be
  2636. enabled by default. To enable OpenCL, you need either to disable CUDA
  2637. when configuring StarPU:
  2638. @example
  2639. % ./configure --disable-cuda
  2640. @end example
  2641. or when running applications:
  2642. @example
  2643. % STARPU_NCUDA=0 ./application
  2644. @end example
  2645. OpenCL will automatically be started on any device not yet used by
  2646. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  2647. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  2648. so:
  2649. @example
  2650. % STARPU_NCUDA=2 ./application
  2651. @end example
  2652. @node Compiling OpenCL codelets
  2653. @subsection Compiling OpenCL codelets
  2654. Source codes for OpenCL codelets can be stored in a file or in a
  2655. string. StarPU provides functions to build the program executable for
  2656. each available OpenCL device as a @code{cl_program} object. This
  2657. program executable can then be loaded within a specific queue as
  2658. explained in the next section. These are only helpers, Applications
  2659. can also fill a @code{starpu_opencl_program} array by hand for more advanced
  2660. use (e.g. different programs on the different OpenCL devices, for
  2661. relocation purpose for instance).
  2662. @menu
  2663. * starpu_opencl_load_opencl_from_file:: Compiling OpenCL source code
  2664. * starpu_opencl_load_opencl_from_string:: Compiling OpenCL source code
  2665. * starpu_opencl_unload_opencl:: Releasing OpenCL code
  2666. @end menu
  2667. @node starpu_opencl_load_opencl_from_file
  2668. @subsubsection @code{starpu_opencl_load_opencl_from_file} -- Compiling OpenCL source code
  2669. @table @asis
  2670. @item @emph{Description}:
  2671. TODO
  2672. @item @emph{Prototype}:
  2673. @code{int starpu_opencl_load_opencl_from_file(char *source_file_name, struct starpu_opencl_program *opencl_programs);}
  2674. @end table
  2675. @node starpu_opencl_load_opencl_from_string
  2676. @subsubsection @code{starpu_opencl_load_opencl_from_string} -- Compiling OpenCL source code
  2677. @table @asis
  2678. @item @emph{Description}:
  2679. TODO
  2680. @item @emph{Prototype}:
  2681. @code{int starpu_opencl_load_opencl_from_string(char *opencl_program_source, struct starpu_opencl_program *opencl_programs);}
  2682. @end table
  2683. @node starpu_opencl_unload_opencl
  2684. @subsubsection @code{starpu_opencl_unload_opencl} -- Releasing OpenCL code
  2685. @table @asis
  2686. @item @emph{Description}:
  2687. TODO
  2688. @item @emph{Prototype}:
  2689. @code{int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs);}
  2690. @end table
  2691. @node Loading OpenCL codelets
  2692. @subsection Loading OpenCL codelets
  2693. @menu
  2694. * starpu_opencl_load_kernel:: Loading a kernel
  2695. * starpu_opencl_relase_kernel:: Releasing a kernel
  2696. @end menu
  2697. @node starpu_opencl_load_kernel
  2698. @subsubsection @code{starpu_opencl_load_kernel} -- Loading a kernel
  2699. @table @asis
  2700. @item @emph{Description}:
  2701. TODO
  2702. @item @emph{Prototype}:
  2703. @code{int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, char *kernel_name, int devid)
  2704. }
  2705. @end table
  2706. @node starpu_opencl_relase_kernel
  2707. @subsubsection @code{starpu_opencl_release_kernel} -- Releasing a kernel
  2708. @table @asis
  2709. @item @emph{Description}:
  2710. TODO
  2711. @item @emph{Prototype}:
  2712. @code{int starpu_opencl_release_kernel(cl_kernel kernel);}
  2713. @end table
  2714. @node Cell extensions
  2715. @section Cell extensions
  2716. nothing yet.
  2717. @node Miscellaneous helpers
  2718. @section Miscellaneous helpers
  2719. @menu
  2720. * starpu_execute_on_each_worker:: Execute a function on a subset of workers
  2721. @end menu
  2722. @node starpu_execute_on_each_worker
  2723. @subsection @code{starpu_execute_on_each_worker} -- Execute a function on a subset of workers
  2724. @table @asis
  2725. @item @emph{Description}:
  2726. When calling this method, the offloaded function specified by the first argument is
  2727. executed by every StarPU worker that may execute the function.
  2728. The second argument is passed to the offloaded function.
  2729. The last argument specifies on which types of processing units the function
  2730. should be executed. Similarly to the @code{where} field of the
  2731. @code{starpu_codelet} structure, it is possible to specify that the function
  2732. should be executed on every CUDA device and every CPU by passing
  2733. @code{STARPU_CPU|STARPU_CUDA}.
  2734. This function blocks until the function has been executed on every appropriate
  2735. processing units, so that it may not be called from a callback function for
  2736. instance.
  2737. @item @emph{Prototype}:
  2738. @code{void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);}
  2739. @end table
  2740. @c ---------------------------------------------------------------------
  2741. @c Advanced Topics
  2742. @c ---------------------------------------------------------------------
  2743. @node Advanced Topics
  2744. @chapter Advanced Topics
  2745. @menu
  2746. * Defining a new data interface::
  2747. * Defining a new scheduling policy::
  2748. @end menu
  2749. @node Defining a new data interface
  2750. @section Defining a new data interface
  2751. @menu
  2752. * struct starpu_data_interface_ops_t:: Per-interface methods
  2753. * struct starpu_data_copy_methods:: Per-interface data transfer methods
  2754. * An example of data interface:: An example of data interface
  2755. @end menu
  2756. @c void *starpu_data_get_interface_on_node(starpu_data_handle handle, unsigned memory_node); TODO
  2757. @node struct starpu_data_interface_ops_t
  2758. @subsection @code{struct starpu_data_interface_ops_t} -- Per-interface methods
  2759. @table @asis
  2760. @item @emph{Description}:
  2761. TODO describe all the different fields
  2762. @end table
  2763. @node struct starpu_data_copy_methods
  2764. @subsection @code{struct starpu_data_copy_methods} -- Per-interface data transfer methods
  2765. @table @asis
  2766. @item @emph{Description}:
  2767. TODO describe all the different fields
  2768. @end table
  2769. @node An example of data interface
  2770. @subsection An example of data interface
  2771. @table @asis
  2772. TODO
  2773. @end table
  2774. @node Defining a new scheduling policy
  2775. @section Defining a new scheduling policy
  2776. TODO
  2777. A full example showing how to define a new scheduling policy is available in
  2778. the StarPU sources in the directory @code{examples/scheduler/}.
  2779. @menu
  2780. * struct starpu_sched_policy_s::
  2781. * starpu_worker_set_sched_condition::
  2782. * Source code::
  2783. @end menu
  2784. @node struct starpu_sched_policy_s
  2785. @subsection @code{struct starpu_sched_policy_s} -- Scheduler methods
  2786. @table @asis
  2787. @item @emph{Description}:
  2788. This structure contains all the methods that implement a scheduling policy. An
  2789. application may specify which scheduling strategy in the @code{sched_policy}
  2790. field of the @code{starpu_conf} structure passed to the @code{starpu_init}
  2791. function.
  2792. @item @emph{Fields}:
  2793. @table @asis
  2794. @item @code{init_sched}:
  2795. Initialize the scheduling policy.
  2796. @item @code{deinit_sched}:
  2797. Cleanup the scheduling policy.
  2798. @item @code{push_task}:
  2799. Insert a task into the scheduler.
  2800. @item @code{push_prio_task}:
  2801. Insert a priority task into the scheduler.
  2802. @item @code{pop_task}:
  2803. Get a task from the scheduler. The mutex associated to the worker is already
  2804. taken when this method is called.
  2805. @item @code{pop_every_task}:
  2806. Remove all available tasks from the scheduler (tasks are chained by the means
  2807. of the prev and next fields of the starpu_task structure). The mutex associated
  2808. to the worker is already taken when this method is called.
  2809. @item @code{post_exec_hook} (optionnal):
  2810. This method is called every time a task has been executed.
  2811. @item @code{policy_name}:
  2812. Name of the policy (optionnal).
  2813. @item @code{policy_description}:
  2814. Description of the policy (optionnal).
  2815. @end table
  2816. @end table
  2817. @node starpu_worker_set_sched_condition
  2818. @subsection @code{starpu_worker_set_sched_condition} -- Specify the condition variable associated to a worker
  2819. @table @asis
  2820. @item @emph{Description}:
  2821. When there is no available task for a worker, StarPU blocks this worker on a
  2822. condition variable. This function specifies which condition variable (and the
  2823. associated mutex) should be used to block (and to wake up) a worker. Note that
  2824. multiple workers may use the same condition variable. For instance, in the case
  2825. of a scheduling strategy with a single task queue, the same condition variable
  2826. would be used to block and wake up all workers.
  2827. The initialization method of a scheduling strategy (@code{init_sched}) must
  2828. call this function once per worker.
  2829. @item @emph{Prototype}:
  2830. @code{void starpu_worker_set_sched_condition(int workerid, pthread_cond_t *sched_cond, pthread_mutex_t *sched_mutex);}
  2831. @end table
  2832. @node Source code
  2833. @subsection Source code
  2834. @cartouche
  2835. @smallexample
  2836. static struct starpu_sched_policy_s dummy_sched_policy = @{
  2837. .init_sched = init_dummy_sched,
  2838. .deinit_sched = deinit_dummy_sched,
  2839. .push_task = push_task_dummy,
  2840. .push_prio_task = NULL,
  2841. .pop_task = pop_task_dummy,
  2842. .post_exec_hook = NULL,
  2843. .pop_every_task = NULL,
  2844. .policy_name = "dummy",
  2845. .policy_description = "dummy scheduling strategy"
  2846. @};
  2847. @end smallexample
  2848. @end cartouche
  2849. @c ---------------------------------------------------------------------
  2850. @c Appendices
  2851. @c ---------------------------------------------------------------------
  2852. @c ---------------------------------------------------------------------
  2853. @c Full source code for the 'Scaling a Vector' example
  2854. @c ---------------------------------------------------------------------
  2855. @node Full source code for the 'Scaling a Vector' example
  2856. @appendix Full source code for the 'Scaling a Vector' example
  2857. @menu
  2858. * Main application::
  2859. * CPU Codelet::
  2860. * CUDA Codelet::
  2861. * OpenCL Codelet::
  2862. @end menu
  2863. @node Main application
  2864. @section Main application
  2865. @smallexample
  2866. @include vector_scal_c.texi
  2867. @end smallexample
  2868. @node CPU Codelet
  2869. @section CPU Codelet
  2870. @smallexample
  2871. @include vector_scal_cpu.texi
  2872. @end smallexample
  2873. @node CUDA Codelet
  2874. @section CUDA Codelet
  2875. @smallexample
  2876. @include vector_scal_cuda.texi
  2877. @end smallexample
  2878. @node OpenCL Codelet
  2879. @section OpenCL Codelet
  2880. @menu
  2881. * Invoking the kernel::
  2882. * Source of the kernel::
  2883. @end menu
  2884. @node Invoking the kernel
  2885. @subsection Invoking the kernel
  2886. @smallexample
  2887. @include vector_scal_opencl.texi
  2888. @end smallexample
  2889. @node Source of the kernel
  2890. @subsection Source of the kernel
  2891. @smallexample
  2892. @include vector_scal_opencl_codelet.texi
  2893. @end smallexample
  2894. @bye