starpu.texi 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517
  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} or
  888. @code{starpu_bound_print_mps} can then be used to output a Linear Programming
  889. problem corresponding to the schedule of your tasks. Run it through
  890. @code{lp_solve} or any other linear programming solver, and that will give you a
  891. lower bound for the total execution time of your tasks. If StarPU was compiled
  892. with the glpk library installed, starpu_bound_compute can be used to solve it
  893. immediately and get the optimized minimum.
  894. Note that this is not taking into account task dependencies and data
  895. transfers. It only takes into account the actual computations on processing
  896. units. It however properly takes into account the varying performances of
  897. kernels and processing units, which is quite more accurate than just comparing
  898. StarPU performances with the fastest of the kernels being used.
  899. @node More examples
  900. @section More examples
  901. More examples are available in the StarPU sources in the @code{examples/}
  902. directory. Simple examples include:
  903. @table @asis
  904. @item @code{incrementer/}:
  905. Trivial incrementation test.
  906. @item @code{basic_examples/}:
  907. Simple documented Hello world (as shown in @ref{Hello World}), vector/scalar product (as shown
  908. in @ref{Vector Scaling on an Hybrid CPU/GPU Machine}), matrix
  909. product examples (as shown in @ref{Performance model example}), an example using the blocked matrix data
  910. interface, and an example using the variable data interface.
  911. @item @code{matvecmult/}:
  912. OpenCL example from NVidia, adapted to StarPU.
  913. @item @code{axpy/}:
  914. AXPY CUBLAS operation adapted to StarPU.
  915. @item @code{fortran/}:
  916. Example of Fortran bindings.
  917. @end table
  918. More advanced examples include:
  919. @table @asis
  920. @item @code{filters/}:
  921. Examples using filters, as shown in @ref{Partitioning Data}.
  922. @item @code{lu/}:
  923. LU matrix factorization.
  924. @end table
  925. @c ---------------------------------------------------------------------
  926. @c Configuration options
  927. @c ---------------------------------------------------------------------
  928. @node Configuring StarPU
  929. @chapter Configuring StarPU
  930. @menu
  931. * Compilation configuration::
  932. * Execution configuration through environment variables::
  933. @end menu
  934. @node Compilation configuration
  935. @section Compilation configuration
  936. The following arguments can be given to the @code{configure} script.
  937. @menu
  938. * Common configuration::
  939. * Configuring workers::
  940. * Advanced configuration::
  941. @end menu
  942. @node Common configuration
  943. @subsection Common configuration
  944. @menu
  945. * --enable-debug::
  946. * --enable-fast::
  947. * --enable-verbose::
  948. * --enable-coverage::
  949. @end menu
  950. @node --enable-debug
  951. @subsubsection @code{--enable-debug}
  952. @table @asis
  953. @item @emph{Description}:
  954. Enable debugging messages.
  955. @end table
  956. @node --enable-fast
  957. @subsubsection @code{--enable-fast}
  958. @table @asis
  959. @item @emph{Description}:
  960. Do not enforce assertions, saves a lot of time spent to compute them otherwise.
  961. @end table
  962. @node --enable-verbose
  963. @subsubsection @code{--enable-verbose}
  964. @table @asis
  965. @item @emph{Description}:
  966. Augment the verbosity of the debugging messages.
  967. @end table
  968. @node --enable-coverage
  969. @subsubsection @code{--enable-coverage}
  970. @table @asis
  971. @item @emph{Description}:
  972. Enable flags for the coverage tool.
  973. @end table
  974. @node Configuring workers
  975. @subsection Configuring workers
  976. @menu
  977. * --enable-nmaxcpus::
  978. * --disable-cpu::
  979. * --enable-maxcudadev::
  980. * --disable-cuda::
  981. * --with-cuda-dir::
  982. * --enable-maxopencldev::
  983. * --disable-opencl::
  984. * --with-opencl-dir::
  985. * --enable-gordon::
  986. * --with-gordon-dir::
  987. @end menu
  988. @node --enable-nmaxcpus
  989. @subsubsection @code{--enable-nmaxcpus=<number>}
  990. @table @asis
  991. @item @emph{Description}:
  992. Defines the maximum number of CPU cores that StarPU will support, then
  993. available as the @code{STARPU_NMAXCPUS} macro.
  994. @end table
  995. @node --disable-cpu
  996. @subsubsection @code{--disable-cpu}
  997. @table @asis
  998. @item @emph{Description}:
  999. Disable the use of CPUs of the machine. Only GPUs etc. will be used.
  1000. @end table
  1001. @node --enable-maxcudadev
  1002. @subsubsection @code{--enable-maxcudadev=<number>}
  1003. @table @asis
  1004. @item @emph{Description}:
  1005. Defines the maximum number of CUDA devices that StarPU will support, then
  1006. available as the @code{STARPU_MAXCUDADEVS} macro.
  1007. @end table
  1008. @node --disable-cuda
  1009. @subsubsection @code{--disable-cuda}
  1010. @table @asis
  1011. @item @emph{Description}:
  1012. Disable the use of CUDA, even if a valid CUDA installation was detected.
  1013. @end table
  1014. @node --with-cuda-dir
  1015. @subsubsection @code{--with-cuda-dir=<path>}
  1016. @table @asis
  1017. @item @emph{Description}:
  1018. Specify the directory where CUDA is installed. This directory should notably contain
  1019. @code{include/cuda.h}.
  1020. @end table
  1021. @node --enable-maxopencldev
  1022. @subsubsection @code{--enable-maxopencldev=<number>}
  1023. @table @asis
  1024. @item @emph{Description}:
  1025. Defines the maximum number of OpenCL devices that StarPU will support, then
  1026. available as the @code{STARPU_MAXOPENCLDEVS} macro.
  1027. @end table
  1028. @node --disable-opencl
  1029. @subsubsection @code{--disable-opencl}
  1030. @table @asis
  1031. @item @emph{Description}:
  1032. Disable the use of OpenCL, even if the SDK is detected.
  1033. @end table
  1034. @node --with-opencl-dir
  1035. @subsubsection @code{--with-opencl-dir=<path>}
  1036. @table @asis
  1037. @item @emph{Description}:
  1038. Specify the location of the OpenCL SDK. This directory should notably contain
  1039. @code{include/CL/cl.h}.
  1040. @end table
  1041. @node --enable-gordon
  1042. @subsubsection @code{--enable-gordon}
  1043. @table @asis
  1044. @item @emph{Description}:
  1045. Enable the use of the Gordon runtime for Cell SPUs.
  1046. @c TODO: rather default to enabled when detected
  1047. @end table
  1048. @node --with-gordon-dir
  1049. @subsubsection @code{--with-gordon-dir=<path>}
  1050. @table @asis
  1051. @item @emph{Description}:
  1052. Specify the location of the Gordon SDK.
  1053. @end table
  1054. @node Advanced configuration
  1055. @subsection Advanced configuration
  1056. @menu
  1057. * --enable-perf-debug::
  1058. * --enable-model-debug::
  1059. * --enable-stats::
  1060. * --enable-maxbuffers::
  1061. * --enable-allocation-cache::
  1062. * --enable-opengl-render::
  1063. * --enable-blas-lib::
  1064. * --with-magma::
  1065. * --with-fxt::
  1066. * --with-perf-model-dir::
  1067. * --with-mpicc::
  1068. * --with-goto-dir::
  1069. * --with-atlas-dir::
  1070. @end menu
  1071. @node --enable-perf-debug
  1072. @subsubsection @code{--enable-perf-debug}
  1073. @table @asis
  1074. @item @emph{Description}:
  1075. Enable performance debugging.
  1076. @end table
  1077. @node --enable-model-debug
  1078. @subsubsection @code{--enable-model-debug}
  1079. @table @asis
  1080. @item @emph{Description}:
  1081. Enable performance model debugging.
  1082. @end table
  1083. @node --enable-stats
  1084. @subsubsection @code{--enable-stats}
  1085. @table @asis
  1086. @item @emph{Description}:
  1087. Enable statistics.
  1088. @end table
  1089. @node --enable-maxbuffers
  1090. @subsubsection @code{--enable-maxbuffers=<nbuffers>}
  1091. @table @asis
  1092. @item @emph{Description}:
  1093. Define the maximum number of buffers that tasks will be able to take
  1094. as parameters, then available as the @code{STARPU_NMAXBUFS} macro.
  1095. @end table
  1096. @node --enable-allocation-cache
  1097. @subsubsection @code{--enable-allocation-cache}
  1098. @table @asis
  1099. @item @emph{Description}:
  1100. Enable the use of a data allocation cache to avoid the cost of it with
  1101. CUDA. Still experimental.
  1102. @end table
  1103. @node --enable-opengl-render
  1104. @subsubsection @code{--enable-opengl-render}
  1105. @table @asis
  1106. @item @emph{Description}:
  1107. Enable the use of OpenGL for the rendering of some examples.
  1108. @c TODO: rather default to enabled when detected
  1109. @end table
  1110. @node --enable-blas-lib
  1111. @subsubsection @code{--enable-blas-lib=<name>}
  1112. @table @asis
  1113. @item @emph{Description}:
  1114. Specify the blas library to be used by some of the examples. The
  1115. library has to be 'atlas' or 'goto'.
  1116. @end table
  1117. @node --with-magma
  1118. @subsubsection @code{--with-magma=<path>}
  1119. @table @asis
  1120. @item @emph{Description}:
  1121. Specify where magma is installed.
  1122. @end table
  1123. @node --with-fxt
  1124. @subsubsection @code{--with-fxt=<path>}
  1125. @table @asis
  1126. @item @emph{Description}:
  1127. Specify the location of FxT (for generating traces and rendering them
  1128. using ViTE). This directory should notably contain
  1129. @code{include/fxt/fxt.h}.
  1130. @end table
  1131. @node --with-perf-model-dir
  1132. @subsubsection @code{--with-perf-model-dir=<dir>}
  1133. @table @asis
  1134. @item @emph{Description}:
  1135. Specify where performance models should be stored (instead of defaulting to the
  1136. current user's home).
  1137. @end table
  1138. @node --with-mpicc
  1139. @subsubsection @code{--with-mpicc=<path to mpicc>}
  1140. @table @asis
  1141. @item @emph{Description}:
  1142. Specify the location of the @code{mpicc} compiler to be used for starpumpi.
  1143. @end table
  1144. @node --with-goto-dir
  1145. @subsubsection @code{--with-goto-dir=<dir>}
  1146. @table @asis
  1147. @item @emph{Description}:
  1148. Specify the location of GotoBLAS.
  1149. @end table
  1150. @node --with-atlas-dir
  1151. @subsubsection @code{--with-atlas-dir=<dir>}
  1152. @table @asis
  1153. @item @emph{Description}:
  1154. Specify the location of ATLAS. This directory should notably contain
  1155. @code{include/cblas.h}.
  1156. @end table
  1157. @c ---------------------------------------------------------------------
  1158. @c Environment variables
  1159. @c ---------------------------------------------------------------------
  1160. @node Execution configuration through environment variables
  1161. @section Execution configuration through environment variables
  1162. @menu
  1163. * Workers:: Configuring workers
  1164. * Scheduling:: Configuring the Scheduling engine
  1165. * Misc:: Miscellaneous and debug
  1166. @end menu
  1167. Note: the values given in @code{starpu_conf} structure passed when
  1168. calling @code{starpu_init} will override the values of the environment
  1169. variables.
  1170. @node Workers
  1171. @subsection Configuring workers
  1172. @menu
  1173. * STARPU_NCPUS:: Number of CPU workers
  1174. * STARPU_NCUDA:: Number of CUDA workers
  1175. * STARPU_NOPENCL:: Number of OpenCL workers
  1176. * STARPU_NGORDON:: Number of SPU workers (Cell)
  1177. * STARPU_WORKERS_CPUID:: Bind workers to specific CPUs
  1178. * STARPU_WORKERS_CUDAID:: Select specific CUDA devices
  1179. * STARPU_WORKERS_OPENCLID:: Select specific OpenCL devices
  1180. @end menu
  1181. @node STARPU_NCPUS
  1182. @subsubsection @code{STARPU_NCPUS} -- Number of CPU workers
  1183. @table @asis
  1184. @item @emph{Description}:
  1185. Specify the maximum number of CPU workers. Note that StarPU will not allocate
  1186. more CPUs than there are physical CPUs, and that some CPUs are used to control
  1187. the accelerators.
  1188. @end table
  1189. @node STARPU_NCUDA
  1190. @subsubsection @code{STARPU_NCUDA} -- Number of CUDA workers
  1191. @table @asis
  1192. @item @emph{Description}:
  1193. Specify the maximum number of CUDA devices that StarPU can use. If
  1194. @code{STARPU_NCUDA} is lower than the number of physical devices, it is
  1195. possible to select which CUDA devices should be used by the means of the
  1196. @code{STARPU_WORKERS_CUDAID} environment variable.
  1197. @end table
  1198. @node STARPU_NOPENCL
  1199. @subsubsection @code{STARPU_NOPENCL} -- Number of OpenCL workers
  1200. @table @asis
  1201. @item @emph{Description}:
  1202. OpenCL equivalent of the @code{STARPU_NCUDA} environment variable.
  1203. @end table
  1204. @node STARPU_NGORDON
  1205. @subsubsection @code{STARPU_NGORDON} -- Number of SPU workers (Cell)
  1206. @table @asis
  1207. @item @emph{Description}:
  1208. Specify the maximum number of SPUs that StarPU can use.
  1209. @end table
  1210. @node STARPU_WORKERS_CPUID
  1211. @subsubsection @code{STARPU_WORKERS_CPUID} -- Bind workers to specific CPUs
  1212. @table @asis
  1213. @item @emph{Description}:
  1214. Passing an array of integers (starting from 0) in @code{STARPU_WORKERS_CPUID}
  1215. specifies on which logical CPU the different workers should be
  1216. bound. For instance, if @code{STARPU_WORKERS_CPUID = "1 3 0 2"}, the first
  1217. worker will be bound to logical CPU #1, the second CPU worker will be bound to
  1218. logical CPU #3 and so on. Note that the logical ordering of the CPUs is either
  1219. determined by the OS, or provided by the @code{hwloc} library in case it is
  1220. available.
  1221. Note that the first workers correspond to the CUDA workers, then come the
  1222. OpenCL and the SPU, and finally the CPU workers. For example if
  1223. we have @code{STARPU_NCUDA=1}, @code{STARPU_NOPENCL=1}, @code{STARPU_NCPUS=2}
  1224. and @code{STARPU_WORKERS_CPUID = "0 2 1 3"}, the CUDA device will be controlled
  1225. by logical CPU #0, the OpenCL device will be controlled by logical CPU #2, and
  1226. the logical CPUs #1 and #3 will be used by the CPU workers.
  1227. If the number of workers is larger than the array given in
  1228. @code{STARPU_WORKERS_CPUID}, the workers are bound to the logical CPUs in a
  1229. round-robin fashion: if @code{STARPU_WORKERS_CPUID = "0 1"}, the first and the
  1230. third (resp. second and fourth) workers will be put on CPU #0 (resp. CPU #1).
  1231. This variable is ignored if the @code{use_explicit_workers_bindid} flag of the
  1232. @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1233. @end table
  1234. @node STARPU_WORKERS_CUDAID
  1235. @subsubsection @code{STARPU_WORKERS_CUDAID} -- Select specific CUDA devices
  1236. @table @asis
  1237. @item @emph{Description}:
  1238. Similarly to the @code{STARPU_WORKERS_CPUID} environment variable, it is
  1239. possible to select which CUDA devices should be used by StarPU. On a machine
  1240. equipped with 4 GPUs, setting @code{STARPU_WORKERS_CUDAID = "1 3"} and
  1241. @code{STARPU_NCUDA=2} specifies that 2 CUDA workers should be created, and that
  1242. they should use CUDA devices #1 and #3 (the logical ordering of the devices is
  1243. the one reported by CUDA).
  1244. This variable is ignored if the @code{use_explicit_workers_cuda_gpuid} flag of
  1245. the @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1246. @end table
  1247. @node STARPU_WORKERS_OPENCLID
  1248. @subsubsection @code{STARPU_WORKERS_OPENCLID} -- Select specific OpenCL devices
  1249. @table @asis
  1250. @item @emph{Description}:
  1251. OpenCL equivalent of the @code{STARPU_WORKERS_CUDAID} environment variable.
  1252. This variable is ignored if the @code{use_explicit_workers_opencl_gpuid} flag of
  1253. the @code{starpu_conf} structure passed to @code{starpu_init} is set.
  1254. @end table
  1255. @node Scheduling
  1256. @subsection Configuring the Scheduling engine
  1257. @menu
  1258. * STARPU_SCHED:: Scheduling policy
  1259. * STARPU_CALIBRATE:: Calibrate performance models
  1260. * STARPU_PREFETCH:: Use data prefetch
  1261. * STARPU_SCHED_ALPHA:: Computation factor
  1262. * STARPU_SCHED_BETA:: Communication factor
  1263. @end menu
  1264. @node STARPU_SCHED
  1265. @subsubsection @code{STARPU_SCHED} -- Scheduling policy
  1266. @table @asis
  1267. @item @emph{Description}:
  1268. This chooses between the different scheduling policies proposed by StarPU: work
  1269. random, stealing, greedy, with performance models, etc.
  1270. Use @code{STARPU_SCHED=help} to get the list of available schedulers.
  1271. @end table
  1272. @node STARPU_CALIBRATE
  1273. @subsubsection @code{STARPU_CALIBRATE} -- Calibrate performance models
  1274. @table @asis
  1275. @item @emph{Description}:
  1276. If this variable is set to 1, the performance models are calibrated during
  1277. the execution. If it is set to 2, the previous values are dropped to restart
  1278. calibration from scratch.
  1279. Note: this currently only applies to dm and dmda scheduling policies.
  1280. @end table
  1281. @node STARPU_PREFETCH
  1282. @subsubsection @code{STARPU_PREFETCH} -- Use data prefetch
  1283. @table @asis
  1284. @item @emph{Description}:
  1285. This variable indicates whether data prefetching should be enabled (0 means
  1286. that it is disabled). If prefetching is enabled, when a task is scheduled to be
  1287. executed e.g. on a GPU, StarPU will request an asynchronous transfer in
  1288. advance, so that data is already present on the GPU when the task starts. As a
  1289. result, computation and data transfers are overlapped.
  1290. @end table
  1291. @node STARPU_SCHED_ALPHA
  1292. @subsubsection @code{STARPU_SCHED_ALPHA} -- Computation factor
  1293. @table @asis
  1294. @item @emph{Description}:
  1295. To estimate the cost of a task StarPU takes into account the estimated
  1296. computation time (obtained thanks to performance models). The alpha factor is
  1297. the coefficient to be applied to it before adding it to the communication part.
  1298. @end table
  1299. @node STARPU_SCHED_BETA
  1300. @subsubsection @code{STARPU_SCHED_BETA} -- Communication factor
  1301. @table @asis
  1302. @item @emph{Description}:
  1303. To estimate the cost of a task StarPU takes into account the estimated
  1304. data transfer time (obtained thanks to performance models). The beta factor is
  1305. the coefficient to be applied to it before adding it to the computation part.
  1306. @end table
  1307. @node Misc
  1308. @subsection Miscellaneous and debug
  1309. @menu
  1310. * STARPU_LOGFILENAME:: Select debug file name
  1311. @end menu
  1312. @node STARPU_LOGFILENAME
  1313. @subsubsection @code{STARPU_LOGFILENAME} -- Select debug file name
  1314. @table @asis
  1315. @item @emph{Description}:
  1316. This variable specify in which file the debugging output should be saved to.
  1317. @end table
  1318. @c ---------------------------------------------------------------------
  1319. @c StarPU API
  1320. @c ---------------------------------------------------------------------
  1321. @node StarPU API
  1322. @chapter StarPU API
  1323. @menu
  1324. * Initialization and Termination:: Initialization and Termination methods
  1325. * Workers' Properties:: Methods to enumerate workers' properties
  1326. * Data Library:: Methods to manipulate data
  1327. * Data Interfaces::
  1328. * Data Partition::
  1329. * Codelets and Tasks:: Methods to construct tasks
  1330. * Explicit Dependencies:: Explicit Dependencies
  1331. * Implicit Data Dependencies:: Implicit Data Dependencies
  1332. * Performance Model API::
  1333. * Profiling API:: Profiling API
  1334. * CUDA extensions:: CUDA extensions
  1335. * OpenCL extensions:: OpenCL extensions
  1336. * Cell extensions:: Cell extensions
  1337. * Miscellaneous helpers::
  1338. @end menu
  1339. @node Initialization and Termination
  1340. @section Initialization and Termination
  1341. @menu
  1342. * starpu_init:: Initialize StarPU
  1343. * struct starpu_conf:: StarPU runtime configuration
  1344. * starpu_shutdown:: Terminate StarPU
  1345. @end menu
  1346. @node starpu_init
  1347. @subsection @code{starpu_init} -- Initialize StarPU
  1348. @table @asis
  1349. @item @emph{Description}:
  1350. This is StarPU initialization method, which must be called prior to any other
  1351. StarPU call. It is possible to specify StarPU's configuration (e.g. scheduling
  1352. policy, number of cores, ...) by passing a non-null argument. Default
  1353. configuration is used if the passed argument is @code{NULL}.
  1354. @item @emph{Return value}:
  1355. Upon successful completion, this function returns 0. Otherwise, @code{-ENODEV}
  1356. indicates that no worker was available (so that StarPU was not initialized).
  1357. @item @emph{Prototype}:
  1358. @code{int starpu_init(struct starpu_conf *conf);}
  1359. @end table
  1360. @node struct starpu_conf
  1361. @subsection @code{struct starpu_conf} -- StarPU runtime configuration
  1362. @table @asis
  1363. @item @emph{Description}:
  1364. This structure is passed to the @code{starpu_init} function in order
  1365. to configure StarPU.
  1366. When the default value is used, StarPU automatically selects the number
  1367. of processing units and takes the default scheduling policy. This parameter
  1368. overwrites the equivalent environment variables.
  1369. @item @emph{Fields}:
  1370. @table @asis
  1371. @item @code{sched_policy_name} (default = NULL):
  1372. This is the name of the scheduling policy. This can also be specified with the
  1373. @code{STARPU_SCHED} environment variable.
  1374. @item @code{sched_policy} (default = NULL):
  1375. This is the definition of the scheduling policy. This field is ignored
  1376. if @code{sched_policy_name} is set.
  1377. @item @code{ncpus} (default = -1):
  1378. This is the maximum number of CPU cores that StarPU can use. This can also be
  1379. specified with the @code{STARPU_NCPUS} environment variable.
  1380. @item @code{ncuda} (default = -1):
  1381. This is the maximum number of CUDA devices that StarPU can use. This can also be
  1382. specified with the @code{STARPU_NCUDA} environment variable.
  1383. @item @code{nopencl} (default = -1):
  1384. This is the maximum number of OpenCL devices that StarPU can use. This can also be
  1385. specified with the @code{STARPU_NOPENCL} environment variable.
  1386. @item @code{nspus} (default = -1):
  1387. This is the maximum number of Cell SPUs that StarPU can use. This can also be
  1388. specified with the @code{STARPU_NGORDON} environment variable.
  1389. @item @code{use_explicit_workers_bindid} (default = 0)
  1390. If this flag is set, the @code{workers_bindid} array indicates where the
  1391. different workers are bound, otherwise StarPU automatically selects where to
  1392. bind the different workers unless the @code{STARPU_WORKERS_CPUID} environment
  1393. variable is set. The @code{STARPU_WORKERS_CPUID} environment variable is
  1394. ignored if the @code{use_explicit_workers_bindid} flag is set.
  1395. @item @code{workers_bindid[STARPU_NMAXWORKERS]}
  1396. If the @code{use_explicit_workers_bindid} flag is set, this array indicates
  1397. where to bind the different workers. The i-th entry of the
  1398. @code{workers_bindid} indicates the logical identifier of the processor which
  1399. should execute the i-th worker. Note that the logical ordering of the CPUs is
  1400. either determined by the OS, or provided by the @code{hwloc} library in case it
  1401. is available.
  1402. When this flag is set, the @ref{STARPU_WORKERS_CPUID} environment variable is
  1403. ignored.
  1404. @item @code{use_explicit_workers_cuda_gpuid} (default = 0)
  1405. If this flag is set, the CUDA workers will be attached to the CUDA devices
  1406. specified in the @code{workers_cuda_gpuid} array. Otherwise, StarPU affects the
  1407. CUDA devices in a round-robin fashion.
  1408. When this flag is set, the @ref{STARPU_WORKERS_CUDAID} environment variable is
  1409. ignored.
  1410. @item @code{workers_cuda_gpuid[STARPU_NMAXWORKERS]}
  1411. If the @code{use_explicit_workers_cuda_gpuid} flag is set, this array contains
  1412. the logical identifiers of the CUDA devices (as used by @code{cudaGetDevice}).
  1413. @item @code{use_explicit_workers_opencl_gpuid} (default = 0)
  1414. If this flag is set, the OpenCL workers will be attached to the OpenCL devices
  1415. specified in the @code{workers_opencl_gpuid} array. Otherwise, StarPU affects the
  1416. OpenCL devices in a round-robin fashion.
  1417. @item @code{workers_opencl_gpuid[STARPU_NMAXWORKERS]}:
  1418. @item @code{calibrate} (default = 0):
  1419. If this flag is set, StarPU will calibrate the performance models when
  1420. executing tasks. If this value is equal to -1, the default value is used. The
  1421. default value is overwritten by the @code{STARPU_CALIBRATE} environment
  1422. variable when it is set.
  1423. @end table
  1424. @end table
  1425. @node starpu_shutdown
  1426. @subsection @code{starpu_shutdown} -- Terminate StarPU
  1427. @table @asis
  1428. @item @emph{Description}:
  1429. This is StarPU termination method. It must be called at the end of the
  1430. application: statistics and other post-mortem debugging information are not
  1431. guaranteed to be available until this method has been called.
  1432. @item @emph{Prototype}:
  1433. @code{void starpu_shutdown(void);}
  1434. @end table
  1435. @node Workers' Properties
  1436. @section Workers' Properties
  1437. @menu
  1438. * starpu_worker_get_count:: Get the number of processing units
  1439. * starpu_cpu_worker_get_count:: Get the number of CPU controlled by StarPU
  1440. * starpu_cuda_worker_get_count:: Get the number of CUDA devices controlled by StarPU
  1441. * starpu_opencl_worker_get_count:: Get the number of OpenCL devices controlled by StarPU
  1442. * starpu_spu_worker_get_count:: Get the number of Cell SPUs controlled by StarPU
  1443. * starpu_worker_get_id:: Get the identifier of the current worker
  1444. * starpu_worker_get_devid:: Get the device identifier of a worker
  1445. * starpu_worker_get_type:: Get the type of processing unit associated to a worker
  1446. * starpu_worker_get_name:: Get the name of a worker
  1447. * starpu_worker_get_memory_node:: Get the memory node of a worker
  1448. @end menu
  1449. @node starpu_worker_get_count
  1450. @subsection @code{starpu_worker_get_count} -- Get the number of processing units
  1451. @table @asis
  1452. @item @emph{Description}:
  1453. This function returns the number of workers (i.e. processing units executing
  1454. StarPU tasks). The returned value should be at most @code{STARPU_NMAXWORKERS}.
  1455. @item @emph{Prototype}:
  1456. @code{unsigned starpu_worker_get_count(void);}
  1457. @end table
  1458. @node starpu_cpu_worker_get_count
  1459. @subsection @code{starpu_cpu_worker_get_count} -- Get the number of CPU controlled by StarPU
  1460. @table @asis
  1461. @item @emph{Description}:
  1462. This function returns the number of CPUs controlled by StarPU. The returned
  1463. value should be at most @code{STARPU_NMAXCPUS}.
  1464. @item @emph{Prototype}:
  1465. @code{unsigned starpu_cpu_worker_get_count(void);}
  1466. @end table
  1467. @node starpu_cuda_worker_get_count
  1468. @subsection @code{starpu_cuda_worker_get_count} -- Get the number of CUDA devices controlled by StarPU
  1469. @table @asis
  1470. @item @emph{Description}:
  1471. This function returns the number of CUDA devices controlled by StarPU. The returned
  1472. value should be at most @code{STARPU_MAXCUDADEVS}.
  1473. @item @emph{Prototype}:
  1474. @code{unsigned starpu_cuda_worker_get_count(void);}
  1475. @end table
  1476. @node starpu_opencl_worker_get_count
  1477. @subsection @code{starpu_opencl_worker_get_count} -- Get the number of OpenCL devices controlled by StarPU
  1478. @table @asis
  1479. @item @emph{Description}:
  1480. This function returns the number of OpenCL devices controlled by StarPU. The returned
  1481. value should be at most @code{STARPU_MAXOPENCLDEVS}.
  1482. @item @emph{Prototype}:
  1483. @code{unsigned starpu_opencl_worker_get_count(void);}
  1484. @end table
  1485. @node starpu_spu_worker_get_count
  1486. @subsection @code{starpu_spu_worker_get_count} -- Get the number of Cell SPUs controlled by StarPU
  1487. @table @asis
  1488. @item @emph{Description}:
  1489. This function returns the number of Cell SPUs controlled by StarPU.
  1490. @item @emph{Prototype}:
  1491. @code{unsigned starpu_opencl_worker_get_count(void);}
  1492. @end table
  1493. @node starpu_worker_get_id
  1494. @subsection @code{starpu_worker_get_id} -- Get the identifier of the current worker
  1495. @table @asis
  1496. @item @emph{Description}:
  1497. This function returns the identifier of the worker associated to the calling
  1498. thread. The returned value is either -1 if the current context is not a StarPU
  1499. worker (i.e. when called from the application outside a task or a callback), or
  1500. an integer between 0 and @code{starpu_worker_get_count() - 1}.
  1501. @item @emph{Prototype}:
  1502. @code{int starpu_worker_get_id(void);}
  1503. @end table
  1504. @node starpu_worker_get_devid
  1505. @subsection @code{starpu_worker_get_devid} -- Get the device identifier of a worker
  1506. @table @asis
  1507. @item @emph{Description}:
  1508. This functions returns the device id of the worker associated to an identifier
  1509. (as returned by the @code{starpu_worker_get_id} function). In the case of a
  1510. CUDA worker, this device identifier is the logical device identifier exposed by
  1511. CUDA (used by the @code{cudaGetDevice} function for instance). The device
  1512. identifier of a CPU worker is the logical identifier of the core on which the
  1513. worker was bound; this identifier is either provided by the OS or by the
  1514. @code{hwloc} library in case it is available.
  1515. @item @emph{Prototype}:
  1516. @code{int starpu_worker_get_devid(int id);}
  1517. @end table
  1518. @node starpu_worker_get_type
  1519. @subsection @code{starpu_worker_get_type} -- Get the type of processing unit associated to a worker
  1520. @table @asis
  1521. @item @emph{Description}:
  1522. This function returns the type of worker associated to an identifier (as
  1523. returned by the @code{starpu_worker_get_id} function). The returned value
  1524. indicates the architecture of the worker: @code{STARPU_CPU_WORKER} for a CPU
  1525. core, @code{STARPU_CUDA_WORKER} for a CUDA device,
  1526. @code{STARPU_OPENCL_WORKER} for a OpenCL device, and
  1527. @code{STARPU_GORDON_WORKER} for a Cell SPU. The value returned for an invalid
  1528. identifier is unspecified.
  1529. @item @emph{Prototype}:
  1530. @code{enum starpu_archtype starpu_worker_get_type(int id);}
  1531. @end table
  1532. @node starpu_worker_get_name
  1533. @subsection @code{starpu_worker_get_name} -- Get the name of a worker
  1534. @table @asis
  1535. @item @emph{Description}:
  1536. StarPU associates a unique human readable string to each processing unit. This
  1537. function copies at most the @code{maxlen} first bytes of the unique string
  1538. associated to a worker identified by its identifier @code{id} into the
  1539. @code{dst} buffer. The caller is responsible for ensuring that the @code{dst}
  1540. is a valid pointer to a buffer of @code{maxlen} bytes at least. Calling this
  1541. function on an invalid identifier results in an unspecified behaviour.
  1542. @item @emph{Prototype}:
  1543. @code{void starpu_worker_get_name(int id, char *dst, size_t maxlen);}
  1544. @end table
  1545. @node starpu_worker_get_memory_node
  1546. @subsection @code{starpu_worker_get_memory_node} -- Get the memory node of a worker
  1547. @table @asis
  1548. @item @emph{Description}:
  1549. This function returns the identifier of the memory node associated to the
  1550. worker identified by @code{workerid}.
  1551. @item @emph{Prototype}:
  1552. @code{unsigned starpu_worker_get_memory_node(unsigned workerid);}
  1553. @end table
  1554. @node Data Library
  1555. @section Data Library
  1556. This section describes the data management facilities provided by StarPU.
  1557. We show how to use existing data interfaces in @ref{Data Interfaces}, but developers can
  1558. design their own data interfaces if required.
  1559. @menu
  1560. * starpu_access_mode:: starpu_access_mode
  1561. * unsigned memory_node:: Memory node
  1562. * starpu_data_handle:: StarPU opaque data handle
  1563. * void *interface:: StarPU data interface
  1564. * starpu_data_register:: Register a piece of data to StarPU
  1565. * starpu_data_unregister:: Unregister a piece of data from StarPU
  1566. * starpu_data_invalidate:: Invalidate all data replicates
  1567. * starpu_data_acquire:: Access registered data from the application
  1568. * starpu_data_acquire_cb:: Access registered data from the application asynchronously
  1569. * starpu_data_release:: Release registered data from the application
  1570. @end menu
  1571. @node starpu_access_mode
  1572. @subsection @code{starpu_access_mode} -- Data access mode
  1573. This datatype describes a data access mode. The different available modes are:
  1574. @table @asis
  1575. @table @asis
  1576. @item @code{STARPU_R} read-only mode.
  1577. @item @code{STARPU_W} write-only mode.
  1578. @item @code{STARPU_RW} read-write mode. This is equivalent to @code{STARPU_R|STARPU_W}.
  1579. @item @code{STARPU_SCRATCH} scratch memory. A temporary buffer is allocated for the task, but StarPU does not enforce data consistency.
  1580. @end table
  1581. @end table
  1582. @node unsigned memory_node
  1583. @subsection @code{unsigned memory_node} -- Memory node
  1584. @table @asis
  1585. @item @emph{Description}:
  1586. Every worker is associated to a memory node which is a logical abstraction of
  1587. the address space from which the processing unit gets its data. For instance,
  1588. the memory node associated to the different CPU workers represents main memory
  1589. (RAM), the memory node associated to a GPU is DRAM embedded on the device.
  1590. Every memory node is identified by a logical index which is accessible from the
  1591. @code{starpu_worker_get_memory_node} function. When registering a piece of data
  1592. to StarPU, the specified memory node indicates where the piece of data
  1593. initially resides (we also call this memory node the home node of a piece of
  1594. data).
  1595. @end table
  1596. @node starpu_data_handle
  1597. @subsection @code{starpu_data_handle} -- StarPU opaque data handle
  1598. @table @asis
  1599. @item @emph{Description}:
  1600. StarPU uses @code{starpu_data_handle} as an opaque handle to manage a piece of
  1601. data. Once a piece of data has been registered to StarPU, it is associated to a
  1602. @code{starpu_data_handle} which keeps track of the state of the piece of data
  1603. over the entire machine, so that we can maintain data consistency and locate
  1604. data replicates for instance.
  1605. @end table
  1606. @node void *interface
  1607. @subsection @code{void *interface} -- StarPU data interface
  1608. @table @asis
  1609. @item @emph{Description}:
  1610. Data management is done at a high-level in StarPU: rather than accessing a mere
  1611. list of contiguous buffers, the tasks may manipulate data that are described by
  1612. a high-level construct which we call data interface.
  1613. An example of data interface is the "vector" interface which describes a
  1614. contiguous data array on a spefic memory node. This interface is a simple
  1615. structure containing the number of elements in the array, the size of the
  1616. elements, and the address of the array in the appropriate address space (this
  1617. address may be invalid if there is no valid copy of the array in the memory
  1618. node). More informations on the data interfaces provided by StarPU are
  1619. given in @ref{Data Interfaces}.
  1620. When a piece of data managed by StarPU is used by a task, the task
  1621. implementation is given a pointer to an interface describing a valid copy of
  1622. the data that is accessible from the current processing unit.
  1623. @end table
  1624. @node starpu_data_register
  1625. @subsection @code{starpu_data_register} -- Register a piece of data to StarPU
  1626. @table @asis
  1627. @item @emph{Description}:
  1628. Register a piece of data into the handle located at the @code{handleptr}
  1629. address. The @code{interface} buffer contains the initial description of the
  1630. data in the home node. The @code{ops} argument is a pointer to a structure
  1631. describing the different methods used to manipulate this type of interface. See
  1632. @ref{struct starpu_data_interface_ops_t} for more details on this structure.
  1633. If @code{home_node} is not a valid memory node, StarPU will automatically
  1634. allocate the memory described by the interface the data handle is used for the
  1635. first time in write-only mode. Once such data handle has been automatically
  1636. allocated, it is possible to access it using any access mode.
  1637. Note that StarPU supplies a set of predefined types of interface (e.g. vector or
  1638. matrix) which can be registered by the means of helper functions (e.g.
  1639. @code{starpu_vector_data_register} or @code{starpu_matrix_data_register}).
  1640. @item @emph{Prototype}:
  1641. @code{void starpu_data_register(starpu_data_handle *handleptr,
  1642. uint32_t home_node,
  1643. void *interface,
  1644. struct starpu_data_interface_ops_t *ops);}
  1645. @end table
  1646. @node starpu_data_unregister
  1647. @subsection @code{starpu_data_unregister} -- Unregister a piece of data from StarPU
  1648. @table @asis
  1649. @item @emph{Description}:
  1650. This function unregisters a data handle from StarPU. If the data was
  1651. automatically allocated by StarPU because the home node was not valid, all
  1652. automatically allocated buffers are freed. Otherwise, a valid copy of the data
  1653. is put back into the home node in the buffer that was initially registered.
  1654. Using a data handle that has been unregistered from StarPU results in an
  1655. undefined behaviour.
  1656. @item @emph{Prototype}:
  1657. @code{void starpu_data_unregister(starpu_data_handle handle);}
  1658. @end table
  1659. @node starpu_data_invalidate
  1660. @subsection @code{starpu_data_invalidate} -- Invalidate all data replicates
  1661. @table @asis
  1662. @item @emph{Description}:
  1663. Destroy all replicates of the data handle. After data invalidation, the first
  1664. access to the handle must be performed in write-only mode. Accessing an
  1665. invalidated data in read-mode results in undefined behaviour.
  1666. @item @emph{Prototype}:
  1667. @code{void starpu_data_invalidate(starpu_data_handle handle);}
  1668. @end table
  1669. @c TODO create a specific sections about user interaction with the DSM ?
  1670. @node starpu_data_acquire
  1671. @subsection @code{starpu_data_acquire} -- Access registered data from the application
  1672. @table @asis
  1673. @item @emph{Description}:
  1674. The application must call this function prior to accessing registered data from
  1675. main memory outside tasks. StarPU ensures that the application will get an
  1676. up-to-date copy of the data in main memory located where the data was
  1677. originally registered, and that all concurrent accesses (e.g. from tasks) will
  1678. be consistent with the access mode specified in the @code{mode} argument.
  1679. @code{starpu_data_release} must be called once the application does not need to
  1680. access the piece of data anymore.
  1681. Note that implicit data dependencies are also enforced by
  1682. @code{starpu_data_acquire} in case they are enabled.
  1683. @code{starpu_data_acquire} is a blocking call, so that it cannot be called from
  1684. tasks or from their callbacks (in that case, @code{starpu_data_acquire} returns
  1685. @code{-EDEADLK}). Upon successful completion, this function returns 0.
  1686. @item @emph{Prototype}:
  1687. @code{int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode);}
  1688. @end table
  1689. @node starpu_data_acquire_cb
  1690. @subsection @code{starpu_data_acquire_cb} -- Access registered data from the application asynchronously
  1691. @table @asis
  1692. @item @emph{Description}:
  1693. @code{starpu_data_acquire_cb} is the asynchronous equivalent of
  1694. @code{starpu_data_release}. When the data specified in the first argument is
  1695. available in the appropriate access mode, the callback function is executed.
  1696. The application may access the requested data during the execution of this
  1697. callback. The callback function must call @code{starpu_data_release} once the
  1698. application does not need to access the piece of data anymore.
  1699. Note that implicit data dependencies are also enforced by
  1700. @code{starpu_data_acquire} in case they are enabled.
  1701. Contrary to @code{starpu_data_acquire}, this function is non-blocking and may
  1702. be called from task callbacks. Upon successful completion, this function
  1703. returns 0.
  1704. @item @emph{Prototype}:
  1705. @code{int starpu_data_acquire_cb(starpu_data_handle handle, starpu_access_mode mode, void (*callback)(void *), void *arg);}
  1706. @end table
  1707. @node starpu_data_release
  1708. @subsection @code{starpu_data_release} -- Release registered data from the application
  1709. @table @asis
  1710. @item @emph{Description}:
  1711. This function releases the piece of data acquired by the application either by
  1712. @code{starpu_data_acquire} or by @code{starpu_data_acquire_cb}.
  1713. @item @emph{Prototype}:
  1714. @code{void starpu_data_release(starpu_data_handle handle);}
  1715. @end table
  1716. @node Data Interfaces
  1717. @section Data Interfaces
  1718. @menu
  1719. * Variable Interface::
  1720. * Vector Interface::
  1721. * Matrix Interface::
  1722. * BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)::
  1723. * CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)::
  1724. * Block Interface::
  1725. @end menu
  1726. @node Variable Interface
  1727. @subsection Variable Interface
  1728. @table @asis
  1729. @item @emph{Description}:
  1730. @item @emph{Prototype}:
  1731. @code{void starpu_variable_data_register(starpu_data_handle *handle,
  1732. uint32_t home_node,
  1733. uintptr_t ptr, size_t elemsize);}
  1734. @item @emph{Example}:
  1735. @cartouche
  1736. @smallexample
  1737. float var;
  1738. starpu_data_handle var_handle;
  1739. starpu_variable_data_register(&var_handle, 0, (uintptr_t)&var, sizeof(var));
  1740. @end smallexample
  1741. @end cartouche
  1742. @end table
  1743. @node Vector Interface
  1744. @subsection Vector Interface
  1745. @table @asis
  1746. @item @emph{Description}:
  1747. @item @emph{Prototype}:
  1748. @code{void starpu_vector_data_register(starpu_data_handle *handle, uint32_t home_node,
  1749. uintptr_t ptr, uint32_t nx, size_t elemsize);}
  1750. @item @emph{Example}:
  1751. @cartouche
  1752. @smallexample
  1753. float vector[NX];
  1754. starpu_data_handle vector_handle;
  1755. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector, NX,
  1756. sizeof(vector[0]));
  1757. @end smallexample
  1758. @end cartouche
  1759. @end table
  1760. @node Matrix Interface
  1761. @subsection Matrix Interface
  1762. @table @asis
  1763. @item @emph{Description}:
  1764. @item @emph{Prototype}:
  1765. @code{void starpu_matrix_data_register(starpu_data_handle *handle, uint32_t home_node,
  1766. uintptr_t ptr, uint32_t ld, uint32_t nx,
  1767. uint32_t ny, size_t elemsize);}
  1768. @item @emph{Example}:
  1769. @cartouche
  1770. @smallexample
  1771. float *matrix;
  1772. starpu_data_handle matrix_handle;
  1773. matrix = (float*)malloc(width * height * sizeof(float));
  1774. starpu_matrix_data_register(&matrix_handle, 0, (uintptr_t)matrix,
  1775. width, width, height, sizeof(float));
  1776. @end smallexample
  1777. @end cartouche
  1778. @end table
  1779. @node BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)
  1780. @subsection BCSR Interface for Sparse Matrices (Blocked Compressed Sparse Row Representation)
  1781. @table @asis
  1782. @item @emph{Description}:
  1783. @item @emph{Prototype}:
  1784. @code{void starpu_bcsr_data_register(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  1785. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, uint32_t r, uint32_t c, size_t elemsize);}
  1786. @item @emph{Example}:
  1787. @cartouche
  1788. @smallexample
  1789. @end smallexample
  1790. @end cartouche
  1791. @end table
  1792. @node CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)
  1793. @subsection CSR Interface for Sparse Matrices (Compressed Sparse Row Representation)
  1794. @table @asis
  1795. @item @emph{Description}:
  1796. @item @emph{Prototype}:
  1797. @code{void starpu_csr_data_register(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  1798. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);}
  1799. @item @emph{Example}:
  1800. @cartouche
  1801. @smallexample
  1802. @end smallexample
  1803. @end cartouche
  1804. @end table
  1805. @node Block Interface
  1806. @subsection Block Interface
  1807. @table @asis
  1808. @item @emph{Description}:
  1809. @item @emph{Prototype}:
  1810. @code{void starpu_block_data_register(starpu_data_handle *handle, uint32_t home_node,
  1811. uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx,
  1812. uint32_t ny, uint32_t nz, size_t elemsize);}
  1813. @item @emph{Example}:
  1814. @cartouche
  1815. @smallexample
  1816. float *block;
  1817. starpu_data_handle block_handle;
  1818. block = (float*)malloc(nx*ny*nz*sizeof(float));
  1819. starpu_block_data_register(&block_handle, 0, (uintptr_t)block,
  1820. nx, nx*ny, nx, ny, nz, sizeof(float));
  1821. @end smallexample
  1822. @end cartouche
  1823. @end table
  1824. @node Data Partition
  1825. @section Data Partition
  1826. @menu
  1827. * struct starpu_data_filter:: StarPU filter structure
  1828. * starpu_data_partition:: Partition Data
  1829. * starpu_data_unpartition:: Unpartition Data
  1830. * starpu_data_get_nb_children::
  1831. * starpu_data_get_sub_data::
  1832. * Predefined filter functions::
  1833. @end menu
  1834. @node struct starpu_data_filter
  1835. @subsection @code{struct starpu_data_filter} -- StarPU filter structure
  1836. @table @asis
  1837. @item @emph{Description}:
  1838. The filter structure describes a data partitioning function.
  1839. @item @emph{Fields}:
  1840. @table @asis
  1841. @item @code{filter_func}:
  1842. TODO
  1843. @code{void (*filter_func)(void *father_interface, void* child_interface, struct starpu_data_filter *, unsigned id, unsigned nparts);}
  1844. @item @code{get_nchildren}:
  1845. TODO
  1846. @code{unsigned (*get_nchildren)(struct starpu_data_filter *, starpu_data_handle initial_handle);}
  1847. @item @code{get_child_ops}:
  1848. TODO
  1849. @code{struct starpu_data_interface_ops_t *(*get_child_ops)(struct starpu_data_filter *, unsigned id);}
  1850. @item @code{filter_arg}:
  1851. TODO
  1852. @item @code{nchildren}:
  1853. TODO
  1854. @item @code{filter_arg_ptr}:
  1855. TODO
  1856. @end table
  1857. @end table
  1858. @node starpu_data_partition
  1859. @subsection starpu_data_partition -- Partition Data
  1860. @table @asis
  1861. @item @emph{Description}:
  1862. TODO
  1863. @item @emph{Prototype}:
  1864. @code{void starpu_data_partition(starpu_data_handle initial_handle, struct starpu_data_filter *f);}
  1865. @end table
  1866. @node starpu_data_unpartition
  1867. @subsection starpu_data_unpartition -- Unpartition data
  1868. @table @asis
  1869. @item @emph{Description}:
  1870. TODO
  1871. @item @emph{Prototype}:
  1872. @code{void starpu_data_unpartition(starpu_data_handle root_data, uint32_t gathering_node);}
  1873. @end table
  1874. @node starpu_data_get_nb_children
  1875. @subsection starpu_data_get_nb_children
  1876. @table @asis
  1877. @item @emph{Description}:
  1878. TODO
  1879. @item @emph{Return value}:
  1880. This function returns returns the number of children.
  1881. @item @emph{Prototype}:
  1882. @code{int starpu_data_get_nb_children(starpu_data_handle handle);}
  1883. @end table
  1884. @c starpu_data_handle starpu_data_get_child(starpu_data_handle handle, unsigned i);
  1885. @node starpu_data_get_sub_data
  1886. @subsection starpu_data_get_sub_data
  1887. @table @asis
  1888. @item @emph{Description}:
  1889. TODO
  1890. @item @emph{Return value}:
  1891. TODO
  1892. @item @emph{Prototype}:
  1893. @code{starpu_data_handle starpu_data_get_sub_data(starpu_data_handle root_data, unsigned depth, ... );}
  1894. @end table
  1895. @node Predefined filter functions
  1896. @subsection Predefined filter functions
  1897. @menu
  1898. * Partitioning BCSR Data::
  1899. * Partitioning BLAS interface::
  1900. * Partitioning Vector Data::
  1901. * Partitioning Block Data::
  1902. @end menu
  1903. This section gives a list of the predefined partitioning functions.
  1904. Examples on how to use them are shown in @ref{Partitioning Data}.
  1905. @node Partitioning BCSR Data
  1906. @subsubsection Partitioning BCSR Data
  1907. @itemize
  1908. @item
  1909. TODO
  1910. @code{void starpu_canonical_block_filter_bcsr(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1911. @item
  1912. TODO
  1913. @code{void starpu_vertical_block_filter_func_csr(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1914. @end itemize
  1915. @node Partitioning BLAS interface
  1916. @subsubsection Partitioning BLAS interface
  1917. @itemize
  1918. @item
  1919. TODO
  1920. @code{void starpu_block_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1921. @item
  1922. TODO
  1923. @code{void starpu_vertical_block_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1924. @end itemize
  1925. @node Partitioning Vector Data
  1926. @subsubsection Partitioning Vector Data
  1927. @itemize
  1928. @item
  1929. TODO
  1930. @code{void starpu_block_filter_func_vector(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1931. @item
  1932. TODO
  1933. @code{void starpu_vector_list_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1934. @item
  1935. TODO
  1936. @code{void starpu_vector_divide_in_2_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1937. @end itemize
  1938. @node Partitioning Block Data
  1939. @subsubsection Partitioning Block Data
  1940. @itemize
  1941. @item
  1942. TODO
  1943. @code{void starpu_block_filter_func_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);}
  1944. @end itemize
  1945. @node Codelets and Tasks
  1946. @section Codelets and Tasks
  1947. @menu
  1948. * struct starpu_codelet:: StarPU codelet structure
  1949. * struct starpu_task:: StarPU task structure
  1950. * starpu_task_init:: Initialize a Task
  1951. * starpu_task_create:: Allocate and Initialize a Task
  1952. * starpu_task_deinit:: Release all the resources used by a Task
  1953. * starpu_task_destroy:: Destroy a dynamically allocated Task
  1954. * starpu_task_wait:: Wait for the termination of a Task
  1955. * starpu_task_submit:: Submit a Task
  1956. * starpu_task_wait_for_all:: Wait for the termination of all Tasks
  1957. * starpu_get_current_task:: Return the task currently executed by the worker
  1958. * starpu_display_codelet_stats:: Display statistics
  1959. @end menu
  1960. @node struct starpu_codelet
  1961. @subsection @code{struct starpu_codelet} -- StarPU codelet structure
  1962. @table @asis
  1963. @item @emph{Description}:
  1964. The codelet structure describes a kernel that is possibly implemented on
  1965. various targets.
  1966. @item @emph{Fields}:
  1967. @table @asis
  1968. @item @code{where}:
  1969. Indicates which types of processing units are able to execute the codelet.
  1970. @code{STARPU_CPU|STARPU_CUDA} for instance indicates that the codelet is
  1971. implemented for both CPU cores and CUDA devices while @code{STARPU_GORDON}
  1972. indicates that it is only available on Cell SPUs.
  1973. @item @code{cpu_func} (optional):
  1974. Is a function pointer to the CPU implementation of the codelet. Its prototype
  1975. must be: @code{void cpu_func(void *buffers[], void *cl_arg)}. The first
  1976. argument being the array of data managed by the data management library, and
  1977. the second argument is a pointer to the argument passed from the @code{cl_arg}
  1978. field of the @code{starpu_task} structure.
  1979. The @code{cpu_func} field is ignored if @code{STARPU_CPU} does not appear in
  1980. the @code{where} field, it must be non-null otherwise.
  1981. @item @code{cuda_func} (optional):
  1982. Is a function pointer to the CUDA implementation of the codelet. @emph{This
  1983. must be a host-function written in the CUDA runtime API}. Its prototype must
  1984. be: @code{void cuda_func(void *buffers[], void *cl_arg);}. The @code{cuda_func}
  1985. field is ignored if @code{STARPU_CUDA} does not appear in the @code{where}
  1986. field, it must be non-null otherwise.
  1987. @item @code{opencl_func} (optional):
  1988. Is a function pointer to the OpenCL implementation of the codelet. Its
  1989. prototype must be:
  1990. @code{void opencl_func(starpu_data_interface_t *descr, void *arg);}.
  1991. This pointer is ignored if @code{STARPU_OPENCL} does not appear in the
  1992. @code{where} field, it must be non-null otherwise.
  1993. @item @code{gordon_func} (optional):
  1994. This is the index of the Cell SPU implementation within the Gordon library.
  1995. See Gordon documentation for more details on how to register a kernel and
  1996. retrieve its index.
  1997. @item @code{nbuffers}:
  1998. Specifies the number of arguments taken by the codelet. These arguments are
  1999. managed by the DSM and are accessed from the @code{void *buffers[]}
  2000. array. The constant argument passed with the @code{cl_arg} field of the
  2001. @code{starpu_task} structure is not counted in this number. This value should
  2002. not be above @code{STARPU_NMAXBUFS}.
  2003. @item @code{model} (optional):
  2004. This is a pointer to the performance model associated to this codelet. This
  2005. optional field is ignored when set to @code{NULL}. TODO
  2006. @end table
  2007. @end table
  2008. @node struct starpu_task
  2009. @subsection @code{struct starpu_task} -- StarPU task structure
  2010. @table @asis
  2011. @item @emph{Description}:
  2012. The @code{starpu_task} structure describes a task that can be offloaded on the various
  2013. processing units managed by StarPU. It instantiates a codelet. It can either be
  2014. allocated dynamically with the @code{starpu_task_create} method, or declared
  2015. statically. In the latter case, the programmer has to zero the
  2016. @code{starpu_task} structure and to fill the different fields properly. The
  2017. indicated default values correspond to the configuration of a task allocated
  2018. with @code{starpu_task_create}.
  2019. @item @emph{Fields}:
  2020. @table @asis
  2021. @item @code{cl}:
  2022. Is a pointer to the corresponding @code{starpu_codelet} data structure. This
  2023. describes where the kernel should be executed, and supplies the appropriate
  2024. implementations. When set to @code{NULL}, no code is executed during the tasks,
  2025. such empty tasks can be useful for synchronization purposes.
  2026. @item @code{buffers}:
  2027. Is an array of @code{starpu_buffer_descr_t} structures. It describes the
  2028. different pieces of data accessed by the task, and how they should be accessed.
  2029. The @code{starpu_buffer_descr_t} structure is composed of two fields, the
  2030. @code{handle} field specifies the handle of the piece of data, and the
  2031. @code{mode} field is the required access mode (eg @code{STARPU_RW}). The number
  2032. of entries in this array must be specified in the @code{nbuffers} field of the
  2033. @code{starpu_codelet} structure, and should not excede @code{STARPU_NMAXBUFS}.
  2034. If unsufficient, this value can be set with the @code{--enable-maxbuffers}
  2035. option when configuring StarPU.
  2036. @item @code{cl_arg} (optional) (default = NULL):
  2037. This pointer is passed to the codelet through the second argument
  2038. of the codelet implementation (e.g. @code{cpu_func} or @code{cuda_func}).
  2039. In the specific case of the Cell processor, see the @code{cl_arg_size}
  2040. argument.
  2041. @item @code{cl_arg_size} (optional, Cell specific):
  2042. In the case of the Cell processor, the @code{cl_arg} pointer is not directly
  2043. given to the SPU function. A buffer of size @code{cl_arg_size} is allocated on
  2044. the SPU. This buffer is then filled with the @code{cl_arg_size} bytes starting
  2045. at address @code{cl_arg}. In this case, the argument given to the SPU codelet
  2046. is therefore not the @code{cl_arg} pointer, but the address of the buffer in
  2047. local store (LS) instead. This field is ignored for CPU, CUDA and OpenCL
  2048. codelets.
  2049. @item @code{callback_func} (optional) (default = @code{NULL}):
  2050. This is a function pointer of prototype @code{void (*f)(void *)} which
  2051. specifies a possible callback. If this pointer is non-null, the callback
  2052. function is executed @emph{on the host} after the execution of the task. The
  2053. callback is passed the value contained in the @code{callback_arg} field. No
  2054. callback is executed if the field is set to @code{NULL}.
  2055. @item @code{callback_arg} (optional) (default = @code{NULL}):
  2056. This is the pointer passed to the callback function. This field is ignored if
  2057. the @code{callback_func} is set to @code{NULL}.
  2058. @item @code{use_tag} (optional) (default = 0):
  2059. If set, this flag indicates that the task should be associated with the tag
  2060. contained in the @code{tag_id} field. Tag allow the application to synchronize
  2061. with the task and to express task dependencies easily.
  2062. @item @code{tag_id}:
  2063. This fields contains the tag associated to the task if the @code{use_tag} field
  2064. was set, it is ignored otherwise.
  2065. @item @code{synchronous}:
  2066. If this flag is set, the @code{starpu_task_submit} function is blocking and
  2067. returns only when the task has been executed (or if no worker is able to
  2068. process the task). Otherwise, @code{starpu_task_submit} returns immediately.
  2069. @item @code{priority} (optional) (default = @code{STARPU_DEFAULT_PRIO}):
  2070. This field indicates a level of priority for the task. This is an integer value
  2071. that must be set between @code{STARPU_MIN_PRIO} (for the least important
  2072. tasks) and @code{STARPU_MAX_PRIO} (for the most important tasks) included.
  2073. Default priority is @code{STARPU_DEFAULT_PRIO}. Scheduling strategies that
  2074. take priorities into account can use this parameter to take better scheduling
  2075. decisions, but the scheduling policy may also ignore it.
  2076. @item @code{execute_on_a_specific_worker} (default = 0):
  2077. If this flag is set, StarPU will bypass the scheduler and directly affect this
  2078. task to the worker specified by the @code{workerid} field.
  2079. @item @code{workerid} (optional):
  2080. If the @code{execute_on_a_specific_worker} field is set, this field indicates
  2081. which is the identifier of the worker that should process this task (as
  2082. returned by @code{starpu_worker_get_id}). This field is ignored if
  2083. @code{execute_on_a_specific_worker} field is set to 0.
  2084. @item @code{detach} (optional) (default = 1):
  2085. If this flag is set, it is not possible to synchronize with the task
  2086. by the means of @code{starpu_task_wait} later on. Internal data structures
  2087. are only guaranteed to be freed once @code{starpu_task_wait} is called if the
  2088. flag is not set.
  2089. @item @code{destroy} (optional) (default = 1):
  2090. If this flag is set, the task structure will automatically be freed, either
  2091. after the execution of the callback if the task is detached, or during
  2092. @code{starpu_task_wait} otherwise. If this flag is not set, dynamically
  2093. allocated data structures will not be freed until @code{starpu_task_destroy} is
  2094. called explicitly. Setting this flag for a statically allocated task structure
  2095. will result in undefined behaviour.
  2096. @item @code{predicted} (output field):
  2097. Predicted duration of the task. This field is only set if the scheduling
  2098. strategy used performance models.
  2099. @end table
  2100. @end table
  2101. @node starpu_task_init
  2102. @subsection @code{starpu_task_init} -- Initialize a Task
  2103. @table @asis
  2104. @item @emph{Description}:
  2105. Initialize a task structure with default values. This function is implicitly
  2106. called by @code{starpu_task_create}. By default, tasks initialized with
  2107. @code{starpu_task_init} must be deinitialized explicitly with
  2108. @code{starpu_task_deinit}. Tasks can also be initialized statically, using the
  2109. constant @code{STARPU_TASK_INITIALIZER}.
  2110. @item @emph{Prototype}:
  2111. @code{void starpu_task_init(struct starpu_task *task);}
  2112. @end table
  2113. @node starpu_task_create
  2114. @subsection @code{starpu_task_create} -- Allocate and Initialize a Task
  2115. @table @asis
  2116. @item @emph{Description}:
  2117. Allocate a task structure and initialize it with default values. Tasks
  2118. allocated dynamically with @code{starpu_task_create} are automatically freed when the
  2119. task is terminated. If the destroy flag is explicitly unset, the resources used
  2120. by the task are freed by calling
  2121. @code{starpu_task_destroy}.
  2122. @item @emph{Prototype}:
  2123. @code{struct starpu_task *starpu_task_create(void);}
  2124. @end table
  2125. @node starpu_task_deinit
  2126. @subsection @code{starpu_task_deinit} -- Release all the resources used by a Task
  2127. @table @asis
  2128. @item @emph{Description}:
  2129. Release all the structures automatically allocated to execute the task. This is
  2130. called automatically by @code{starpu_task_destroy}, but the task structure itself is not
  2131. freed. This should be used for statically allocated tasks for instance.
  2132. @item @emph{Prototype}:
  2133. @code{void starpu_task_deinit(struct starpu_task *task);}
  2134. @end table
  2135. @node starpu_task_destroy
  2136. @subsection @code{starpu_task_destroy} -- Destroy a dynamically allocated Task
  2137. @table @asis
  2138. @item @emph{Description}:
  2139. Free the resource allocated during @code{starpu_task_create}. This function can be
  2140. called automatically after the execution of a task by setting the
  2141. @code{destroy} flag of the @code{starpu_task} structure (default behaviour).
  2142. Calling this function on a statically allocated task results in an undefined
  2143. behaviour.
  2144. @item @emph{Prototype}:
  2145. @code{void starpu_task_destroy(struct starpu_task *task);}
  2146. @end table
  2147. @node starpu_task_wait
  2148. @subsection @code{starpu_task_wait} -- Wait for the termination of a Task
  2149. @table @asis
  2150. @item @emph{Description}:
  2151. This function blocks until the task has been executed. It is not possible to
  2152. synchronize with a task more than once. It is not possible to wait for
  2153. synchronous or detached tasks.
  2154. @item @emph{Return value}:
  2155. Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
  2156. indicates that the specified task was either synchronous or detached.
  2157. @item @emph{Prototype}:
  2158. @code{int starpu_task_wait(struct starpu_task *task);}
  2159. @end table
  2160. @node starpu_task_submit
  2161. @subsection @code{starpu_task_submit} -- Submit a Task
  2162. @table @asis
  2163. @item @emph{Description}:
  2164. This function submits a task to StarPU. Calling this function does
  2165. not mean that the task will be executed immediately as there can be data or task
  2166. (tag) dependencies that are not fulfilled yet: StarPU will take care of
  2167. scheduling this task with respect to such dependencies.
  2168. This function returns immediately if the @code{synchronous} field of the
  2169. @code{starpu_task} structure was set to 0, and block until the termination of
  2170. the task otherwise. It is also possible to synchronize the application with
  2171. asynchronous tasks by the means of tags, using the @code{starpu_tag_wait}
  2172. function for instance.
  2173. @item @emph{Return value}:
  2174. In case of success, this function returns 0, a return value of @code{-ENODEV}
  2175. means that there is no worker able to process this task (e.g. there is no GPU
  2176. available and this task is only implemented for CUDA devices).
  2177. @item @emph{Prototype}:
  2178. @code{int starpu_task_submit(struct starpu_task *task);}
  2179. @end table
  2180. @node starpu_task_wait_for_all
  2181. @subsection @code{starpu_task_wait_for_all} -- Wait for the termination of all Tasks
  2182. @table @asis
  2183. @item @emph{Description}:
  2184. This function blocks until all the tasks that were submitted are terminated.
  2185. @item @emph{Prototype}:
  2186. @code{void starpu_task_wait_for_all(void);}
  2187. @end table
  2188. @node starpu_get_current_task
  2189. @subsection @code{starpu_get_current_task} -- Return the task currently executed by the worker
  2190. @table @asis
  2191. @item @emph{Description}:
  2192. This function returns the task currently executed by the worker, or
  2193. NULL if it is called either from a thread that is not a task or simply
  2194. because there is no task being executed at the moment.
  2195. @item @emph{Prototype}:
  2196. @code{struct starpu_task *starpu_get_current_task(void);}
  2197. @end table
  2198. @node starpu_display_codelet_stats
  2199. @subsection @code{starpu_display_codelet_stats} -- Display statistics
  2200. @table @asis
  2201. @item @emph{Description}:
  2202. TODO
  2203. @item @emph{Prototype}:
  2204. @code{void starpu_display_codelet_stats(struct starpu_codelet_t *cl);}
  2205. @end table
  2206. @c Callbacks : what can we put in callbacks ?
  2207. @node Explicit Dependencies
  2208. @section Explicit Dependencies
  2209. @menu
  2210. * starpu_task_declare_deps_array:: starpu_task_declare_deps_array
  2211. * starpu_tag_t:: Task logical identifier
  2212. * starpu_tag_declare_deps:: Declare the Dependencies of a Tag
  2213. * starpu_tag_declare_deps_array:: Declare the Dependencies of a Tag
  2214. * starpu_tag_wait:: Block until a Tag is terminated
  2215. * starpu_tag_wait_array:: Block until a set of Tags is terminated
  2216. * starpu_tag_remove:: Destroy a Tag
  2217. * starpu_tag_notify_from_apps:: Feed a tag explicitly
  2218. @end menu
  2219. @node starpu_task_declare_deps_array
  2220. @subsection @code{starpu_task_declare_deps_array} -- Declare task dependencies
  2221. @table @asis
  2222. @item @emph{Description}:
  2223. Declare task dependencies between a @code{task} and an array of tasks of length
  2224. @code{ndeps}. This function must be called prior to the submission of the task,
  2225. but it may called after the submission or the execution of the tasks in the
  2226. array provided the tasks are still valid (ie. they were not automatically
  2227. destroyed). Calling this function on a task that was already submitted or with
  2228. an entry of @code{task_array} that is not a valid task anymore results in an
  2229. undefined behaviour. If @code{ndeps} is null, no dependency is added. It is
  2230. possible to call @code{starpu_task_declare_deps_array} multiple times on the
  2231. same task, in this case, the dependencies are added. It is possible to have
  2232. redundancy in the task dependencies.
  2233. @item @emph{Prototype}:
  2234. @code{void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[]);}
  2235. @end table
  2236. @node starpu_tag_t
  2237. @subsection @code{starpu_tag_t} -- Task logical identifier
  2238. @table @asis
  2239. @item @emph{Description}:
  2240. It is possible to associate a task with a unique ``tag'' and to express
  2241. dependencies between tasks by the means of those tags. To do so, fill the
  2242. @code{tag_id} field of the @code{starpu_task} structure with a tag number (can
  2243. be arbitrary) and set the @code{use_tag} field to 1.
  2244. If @code{starpu_tag_declare_deps} is called with this tag number, the task will
  2245. not be started until the tasks which holds the declared dependency tags are
  2246. completed.
  2247. @end table
  2248. @node starpu_tag_declare_deps
  2249. @subsection @code{starpu_tag_declare_deps} -- Declare the Dependencies of a Tag
  2250. @table @asis
  2251. @item @emph{Description}:
  2252. Specify the dependencies of the task identified by tag @code{id}. The first
  2253. argument specifies the tag which is configured, the second argument gives the
  2254. number of tag(s) on which @code{id} depends. The following arguments are the
  2255. tags which have to be terminated to unlock the task.
  2256. This function must be called before the associated task is submitted to StarPU
  2257. with @code{starpu_task_submit}.
  2258. @item @emph{Remark}
  2259. Because of the variable arity of @code{starpu_tag_declare_deps}, note that the
  2260. last arguments @emph{must} be of type @code{starpu_tag_t}: constant values
  2261. typically need to be explicitly casted. Using the
  2262. @code{starpu_tag_declare_deps_array} function avoids this hazard.
  2263. @item @emph{Prototype}:
  2264. @code{void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);}
  2265. @item @emph{Example}:
  2266. @cartouche
  2267. @example
  2268. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  2269. starpu_tag_declare_deps((starpu_tag_t)0x1,
  2270. 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  2271. @end example
  2272. @end cartouche
  2273. @end table
  2274. @node starpu_tag_declare_deps_array
  2275. @subsection @code{starpu_tag_declare_deps_array} -- Declare the Dependencies of a Tag
  2276. @table @asis
  2277. @item @emph{Description}:
  2278. This function is similar to @code{starpu_tag_declare_deps}, except that its
  2279. does not take a variable number of arguments but an array of tags of size
  2280. @code{ndeps}.
  2281. @item @emph{Prototype}:
  2282. @code{void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);}
  2283. @item @emph{Example}:
  2284. @cartouche
  2285. @example
  2286. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  2287. starpu_tag_t tag_array[2] = @{0x32, 0x52@};
  2288. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  2289. @end example
  2290. @end cartouche
  2291. @end table
  2292. @node starpu_tag_wait
  2293. @subsection @code{starpu_tag_wait} -- Block until a Tag is terminated
  2294. @table @asis
  2295. @item @emph{Description}:
  2296. This function blocks until the task associated to tag @code{id} has been
  2297. executed. This is a blocking call which must therefore not be called within
  2298. tasks or callbacks, but only from the application directly. It is possible to
  2299. synchronize with the same tag multiple times, as long as the
  2300. @code{starpu_tag_remove} function is not called. Note that it is still
  2301. possible to synchronize with a tag associated to a task which @code{starpu_task}
  2302. data structure was freed (e.g. if the @code{destroy} flag of the
  2303. @code{starpu_task} was enabled).
  2304. @item @emph{Prototype}:
  2305. @code{void starpu_tag_wait(starpu_tag_t id);}
  2306. @end table
  2307. @node starpu_tag_wait_array
  2308. @subsection @code{starpu_tag_wait_array} -- Block until a set of Tags is terminated
  2309. @table @asis
  2310. @item @emph{Description}:
  2311. This function is similar to @code{starpu_tag_wait} except that it blocks until
  2312. @emph{all} the @code{ntags} tags contained in the @code{id} array are
  2313. terminated.
  2314. @item @emph{Prototype}:
  2315. @code{void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);}
  2316. @end table
  2317. @node starpu_tag_remove
  2318. @subsection @code{starpu_tag_remove} -- Destroy a Tag
  2319. @table @asis
  2320. @item @emph{Description}:
  2321. This function releases the resources associated to tag @code{id}. It can be
  2322. called once the corresponding task has been executed and when there is
  2323. no other tag that depend on this tag anymore.
  2324. @item @emph{Prototype}:
  2325. @code{void starpu_tag_remove(starpu_tag_t id);}
  2326. @end table
  2327. @node starpu_tag_notify_from_apps
  2328. @subsection @code{starpu_tag_notify_from_apps} -- Feed a Tag explicitly
  2329. @table @asis
  2330. @item @emph{Description}:
  2331. This function explicitly unlocks tag @code{id}. It may be useful in the
  2332. case of applications which execute part of their computation outside StarPU
  2333. tasks (e.g. third-party libraries). It is also provided as a
  2334. convenient tool for the programmer, for instance to entirely construct the task
  2335. DAG before actually giving StarPU the opportunity to execute the tasks.
  2336. @item @emph{Prototype}:
  2337. @code{void starpu_tag_notify_from_apps(starpu_tag_t id);}
  2338. @end table
  2339. @node Implicit Data Dependencies
  2340. @section Implicit Data Dependencies
  2341. @menu
  2342. * starpu_data_set_default_sequential_consistency_flag:: starpu_data_set_default_sequential_consistency_flag
  2343. * starpu_data_get_default_sequential_consistency_flag:: starpu_data_get_default_sequential_consistency_flag
  2344. * starpu_data_set_sequential_consistency_flag:: starpu_data_set_sequential_consistency_flag
  2345. @end menu
  2346. In this section, we describe how StarPU makes it possible to insert implicit
  2347. task dependencies in order to enforce sequential data consistency. When this
  2348. data consistency is enabled on a specific data handle, any data access will
  2349. appear as sequentially consistent from the application. For instance, if the
  2350. application submits two tasks that access the same piece of data in read-only
  2351. mode, and then a third task that access it in write mode, dependencies will be
  2352. added between the two first tasks and the third one. Implicit data dependencies
  2353. are also inserted in the case of data accesses from the application.
  2354. @node starpu_data_set_default_sequential_consistency_flag
  2355. @subsection @code{starpu_data_set_default_sequential_consistency_flag} -- Set default sequential consistency flag
  2356. @table @asis
  2357. @item @emph{Description}:
  2358. Set the default sequential consistency flag. If a non-zero value is passed, a
  2359. sequential data consistency will be enforced for all handles registered after
  2360. this function call, otherwise it is disabled. By default, StarPU enables
  2361. sequential data consistency. It is also possible to select the data consistency
  2362. mode of a specific data handle with the
  2363. @code{starpu_data_set_sequential_consistency_flag} function.
  2364. @item @emph{Prototype}:
  2365. @code{void starpu_data_set_default_sequential_consistency_flag(unsigned flag);}
  2366. @end table
  2367. @node starpu_data_get_default_sequential_consistency_flag
  2368. @subsection @code{starpu_data_get_default_sequential_consistency_flag} -- Get current default sequential consistency flag
  2369. @table @asis
  2370. @item @emph{Description}:
  2371. This function returns the current default sequential consistency flag.
  2372. @item @emph{Prototype}:
  2373. @code{unsigned starpu_data_set_default_sequential_consistency_flag(void);}
  2374. @end table
  2375. @node starpu_data_set_sequential_consistency_flag
  2376. @subsection @code{starpu_data_set_sequential_consistency_flag} -- Set data sequential consistency mode
  2377. @table @asis
  2378. @item @emph{Description}:
  2379. Select the data consistency mode associated to a data handle. The consistency
  2380. mode set using this function has the priority over the default mode which can
  2381. be set with @code{starpu_data_set_sequential_consistency_flag}.
  2382. @item @emph{Prototype}:
  2383. @code{void starpu_data_set_sequential_consistency_flag(starpu_data_handle handle, unsigned flag);}
  2384. @end table
  2385. @node Performance Model API
  2386. @section Performance Model API
  2387. @menu
  2388. * starpu_load_history_debug::
  2389. * starpu_perfmodel_debugfilepath::
  2390. * starpu_perfmodel_get_arch_name::
  2391. * starpu_force_bus_sampling::
  2392. @end menu
  2393. @node starpu_load_history_debug
  2394. @subsection @code{starpu_load_history_debug}
  2395. @table @asis
  2396. @item @emph{Description}:
  2397. TODO
  2398. @item @emph{Prototype}:
  2399. @code{int starpu_load_history_debug(const char *symbol, struct starpu_perfmodel_t *model);}
  2400. @end table
  2401. @node starpu_perfmodel_debugfilepath
  2402. @subsection @code{starpu_perfmodel_debugfilepath}
  2403. @table @asis
  2404. @item @emph{Description}:
  2405. TODO
  2406. @item @emph{Prototype}:
  2407. @code{void starpu_perfmodel_debugfilepath(struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch, char *path, size_t maxlen);}
  2408. @end table
  2409. @node starpu_perfmodel_get_arch_name
  2410. @subsection @code{starpu_perfmodel_get_arch_name}
  2411. @table @asis
  2412. @item @emph{Description}:
  2413. TODO
  2414. @item @emph{Prototype}:
  2415. @code{void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch, char *archname, size_t maxlen);}
  2416. @end table
  2417. @node starpu_force_bus_sampling
  2418. @subsection @code{starpu_force_bus_sampling}
  2419. @table @asis
  2420. @item @emph{Description}:
  2421. TODO
  2422. @item @emph{Prototype}:
  2423. @code{void starpu_force_bus_sampling(void);}
  2424. @end table
  2425. @node Profiling API
  2426. @section Profiling API
  2427. @menu
  2428. * starpu_profiling_status_set:: starpu_profiling_status_set
  2429. * starpu_profiling_status_get:: starpu_profiling_status_get
  2430. * struct starpu_task_profiling_info:: task profiling information
  2431. * struct starpu_worker_profiling_info:: worker profiling information
  2432. * starpu_worker_get_profiling_info:: starpu_worker_get_profiling_info
  2433. * struct starpu_bus_profiling_info:: bus profiling information
  2434. * starpu_bus_get_count::
  2435. * starpu_bus_get_id::
  2436. * starpu_bus_get_src::
  2437. * starpu_bus_get_dst::
  2438. * starpu_timing_timespec_delay_us::
  2439. * starpu_timing_timespec_to_us::
  2440. * starpu_bus_profiling_helper_display_summary::
  2441. @end menu
  2442. @node starpu_profiling_status_set
  2443. @subsection @code{starpu_profiling_status_set} -- Set current profiling status
  2444. @table @asis
  2445. @item @emph{Description}:
  2446. Thie function sets the profiling status. Profiling is activated by passing
  2447. @code{STARPU_PROFILING_ENABLE} in @code{status}. Passing
  2448. @code{STARPU_PROFILING_DISABLE} disables profiling. Calling this function
  2449. resets all profiling measurements. When profiling is enabled, the
  2450. @code{profiling_info} field of the @code{struct starpu_task} structure points
  2451. to a valid @code{struct starpu_task_profiling_info} structure containing
  2452. information about the execution of the task.
  2453. @item @emph{Return value}:
  2454. Negative return values indicate an error, otherwise the previous status is
  2455. returned.
  2456. @item @emph{Prototype}:
  2457. @code{int starpu_profiling_status_set(int status);}
  2458. @end table
  2459. @node starpu_profiling_status_get
  2460. @subsection @code{starpu_profiling_status_get} -- Get current profiling status
  2461. @table @asis
  2462. @item @emph{Description}:
  2463. Return the current profiling status or a negative value in case there was an error.
  2464. @item @emph{Prototype}:
  2465. @code{int starpu_profiling_status_get(void);}
  2466. @end table
  2467. @node struct starpu_task_profiling_info
  2468. @subsection @code{struct starpu_task_profiling_info} -- Task profiling information
  2469. @table @asis
  2470. @item @emph{Description}:
  2471. This structure contains information about the execution of a task. It is
  2472. accessible from the @code{.profiling_info} field of the @code{starpu_task}
  2473. structure if profiling was enabled.
  2474. @item @emph{Fields}:
  2475. @table @asis
  2476. @item @code{submit_time}:
  2477. Date of task submission (relative to the initialization of StarPU).
  2478. @item @code{start_time}:
  2479. Date of task execution beginning (relative to the initialization of StarPU).
  2480. @item @code{end_time}:
  2481. Date of task execution termination (relative to the initialization of StarPU).
  2482. @item @code{workerid}:
  2483. Identifier of the worker which has executed the task.
  2484. @end table
  2485. @end table
  2486. @node struct starpu_worker_profiling_info
  2487. @subsection @code{struct starpu_worker_profiling_info} -- Worker profiling information
  2488. @table @asis
  2489. @item @emph{Description}:
  2490. This structure contains the profiling information associated to a worker.
  2491. @item @emph{Fields}:
  2492. @table @asis
  2493. @item @code{start_time}:
  2494. Starting date for the reported profiling measurements.
  2495. @item @code{total_time}:
  2496. Duration of the profiling measurement interval.
  2497. @item @code{executing_time}:
  2498. Time spent by the worker to execute tasks during the profiling measurement interval.
  2499. @item @code{sleeping_time}:
  2500. Time spent idling by the worker during the profiling measurement interval.
  2501. @item @code{executed_tasks}:
  2502. Number of tasks executed by the worker during the profiling measurement interval.
  2503. @end table
  2504. @end table
  2505. @node starpu_worker_get_profiling_info
  2506. @subsection @code{starpu_worker_get_profiling_info} -- Get worker profiling info
  2507. @table @asis
  2508. @item @emph{Description}:
  2509. Get the profiling info associated to the worker identified by @code{workerid},
  2510. and reset the profiling measurements. If the @code{worker_info} argument is
  2511. NULL, only reset the counters associated to worker @code{workerid}.
  2512. @item @emph{Return value}:
  2513. Upon successful completion, this function returns 0. Otherwise, a negative
  2514. value is returned.
  2515. @item @emph{Prototype}:
  2516. @code{int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profiling_info *worker_info);}
  2517. @end table
  2518. @node struct starpu_bus_profiling_info
  2519. @subsection @code{struct starpu_bus_profiling_info} -- Bus profiling information
  2520. @table @asis
  2521. @item @emph{Description}:
  2522. TODO
  2523. @item @emph{Fields}:
  2524. @table @asis
  2525. @item @code{start_time}:
  2526. TODO
  2527. @item @code{total_time}:
  2528. TODO
  2529. @item @code{transferred_bytes}:
  2530. TODO
  2531. @item @code{transfer_count}:
  2532. TODO
  2533. @end table
  2534. @end table
  2535. @node starpu_bus_get_count
  2536. @subsection @code{starpu_bus_get_count}
  2537. @table @asis
  2538. @item @emph{Description}:
  2539. TODO
  2540. @item @emph{Prototype}:
  2541. @code{int starpu_bus_get_count(void);}
  2542. @end table
  2543. @node starpu_bus_get_id
  2544. @subsection @code{starpu_bus_get_id}
  2545. @table @asis
  2546. @item @emph{Description}:
  2547. TODO
  2548. @item @emph{Prototype}:
  2549. @code{int starpu_bus_get_id(int src, int dst);}
  2550. @end table
  2551. @node starpu_bus_get_src
  2552. @subsection @code{starpu_bus_get_src}
  2553. @table @asis
  2554. @item @emph{Description}:
  2555. TODO
  2556. @item @emph{Prototype}:
  2557. @code{int starpu_bus_get_src(int busid);}
  2558. @end table
  2559. @node starpu_bus_get_dst
  2560. @subsection @code{starpu_bus_get_dst}
  2561. @table @asis
  2562. @item @emph{Description}:
  2563. TODO
  2564. @item @emph{Prototype}:
  2565. @code{int starpu_bus_get_dst(int busid);}
  2566. @end table
  2567. @node starpu_timing_timespec_delay_us
  2568. @subsection @code{starpu_timing_timespec_delay_us}
  2569. @table @asis
  2570. @item @emph{Description}:
  2571. TODO
  2572. @item @emph{Prototype}:
  2573. @code{double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);}
  2574. @end table
  2575. @node starpu_timing_timespec_to_us
  2576. @subsection @code{starpu_timing_timespec_to_us}
  2577. @table @asis
  2578. @item @emph{Description}:
  2579. TODO
  2580. @item @emph{Prototype}:
  2581. @code{double starpu_timing_timespec_to_us(struct timespec *ts);}
  2582. @end table
  2583. @node starpu_bus_profiling_helper_display_summary
  2584. @subsection @code{starpu_bus_profiling_helper_display_summary}
  2585. @table @asis
  2586. @item @emph{Description}:
  2587. TODO
  2588. @item @emph{Prototype}:
  2589. @code{void starpu_bus_profiling_helper_display_summary(void);}
  2590. @end table
  2591. @node CUDA extensions
  2592. @section CUDA extensions
  2593. @c void starpu_data_malloc_pinned_if_possible(float **A, size_t dim);
  2594. @menu
  2595. * starpu_cuda_get_local_stream:: Get current worker's CUDA stream
  2596. * starpu_helper_cublas_init:: Initialize CUBLAS on every CUDA device
  2597. * starpu_helper_cublas_shutdown:: Deinitialize CUBLAS on every CUDA device
  2598. @end menu
  2599. @node starpu_cuda_get_local_stream
  2600. @subsection @code{starpu_cuda_get_local_stream} -- Get current worker's CUDA stream
  2601. @table @asis
  2602. @item @emph{Description}:
  2603. StarPU provides a stream for every CUDA device controlled by StarPU. This
  2604. function is only provided for convenience so that programmers can easily use
  2605. asynchronous operations within codelets without having to create a stream by
  2606. hand. Note that the application is not forced to use the stream provided by
  2607. @code{starpu_cuda_get_local_stream} and may also create its own streams.
  2608. @item @emph{Prototype}:
  2609. @code{cudaStream_t *starpu_cuda_get_local_stream(void);}
  2610. @end table
  2611. @node starpu_helper_cublas_init
  2612. @subsection @code{starpu_helper_cublas_init} -- Initialize CUBLAS on every CUDA device
  2613. @table @asis
  2614. @item @emph{Description}:
  2615. The CUBLAS library must be initialized prior to any CUBLAS call. Calling
  2616. @code{starpu_helper_cublas_init} will initialize CUBLAS on every CUDA device
  2617. controlled by StarPU. This call blocks until CUBLAS has been properly
  2618. initialized on every device.
  2619. @item @emph{Prototype}:
  2620. @code{void starpu_helper_cublas_init(void);}
  2621. @end table
  2622. @node starpu_helper_cublas_shutdown
  2623. @subsection @code{starpu_helper_cublas_shutdown} -- Deinitialize CUBLAS on every CUDA device
  2624. @table @asis
  2625. @item @emph{Description}:
  2626. This function synchronously deinitializes the CUBLAS library on every CUDA device.
  2627. @item @emph{Prototype}:
  2628. @code{void starpu_helper_cublas_shutdown(void);}
  2629. @end table
  2630. @node OpenCL extensions
  2631. @section OpenCL extensions
  2632. @menu
  2633. * Enabling OpenCL:: Enabling OpenCL
  2634. * Compiling OpenCL codelets:: Compiling OpenCL codelets
  2635. * Loading OpenCL codelets:: Loading OpenCL codelets
  2636. @end menu
  2637. @node Enabling OpenCL
  2638. @subsection Enabling OpenCL
  2639. On GPU devices which can run both CUDA and OpenCL, CUDA will be
  2640. enabled by default. To enable OpenCL, you need either to disable CUDA
  2641. when configuring StarPU:
  2642. @example
  2643. % ./configure --disable-cuda
  2644. @end example
  2645. or when running applications:
  2646. @example
  2647. % STARPU_NCUDA=0 ./application
  2648. @end example
  2649. OpenCL will automatically be started on any device not yet used by
  2650. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  2651. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  2652. so:
  2653. @example
  2654. % STARPU_NCUDA=2 ./application
  2655. @end example
  2656. @node Compiling OpenCL codelets
  2657. @subsection Compiling OpenCL codelets
  2658. Source codes for OpenCL codelets can be stored in a file or in a
  2659. string. StarPU provides functions to build the program executable for
  2660. each available OpenCL device as a @code{cl_program} object. This
  2661. program executable can then be loaded within a specific queue as
  2662. explained in the next section. These are only helpers, Applications
  2663. can also fill a @code{starpu_opencl_program} array by hand for more advanced
  2664. use (e.g. different programs on the different OpenCL devices, for
  2665. relocation purpose for instance).
  2666. @menu
  2667. * starpu_opencl_load_opencl_from_file:: Compiling OpenCL source code
  2668. * starpu_opencl_load_opencl_from_string:: Compiling OpenCL source code
  2669. * starpu_opencl_unload_opencl:: Releasing OpenCL code
  2670. @end menu
  2671. @node starpu_opencl_load_opencl_from_file
  2672. @subsubsection @code{starpu_opencl_load_opencl_from_file} -- Compiling OpenCL source code
  2673. @table @asis
  2674. @item @emph{Description}:
  2675. TODO
  2676. @item @emph{Prototype}:
  2677. @code{int starpu_opencl_load_opencl_from_file(char *source_file_name, struct starpu_opencl_program *opencl_programs);}
  2678. @end table
  2679. @node starpu_opencl_load_opencl_from_string
  2680. @subsubsection @code{starpu_opencl_load_opencl_from_string} -- Compiling OpenCL source code
  2681. @table @asis
  2682. @item @emph{Description}:
  2683. TODO
  2684. @item @emph{Prototype}:
  2685. @code{int starpu_opencl_load_opencl_from_string(char *opencl_program_source, struct starpu_opencl_program *opencl_programs);}
  2686. @end table
  2687. @node starpu_opencl_unload_opencl
  2688. @subsubsection @code{starpu_opencl_unload_opencl} -- Releasing OpenCL code
  2689. @table @asis
  2690. @item @emph{Description}:
  2691. TODO
  2692. @item @emph{Prototype}:
  2693. @code{int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs);}
  2694. @end table
  2695. @node Loading OpenCL codelets
  2696. @subsection Loading OpenCL codelets
  2697. @menu
  2698. * starpu_opencl_load_kernel:: Loading a kernel
  2699. * starpu_opencl_relase_kernel:: Releasing a kernel
  2700. @end menu
  2701. @node starpu_opencl_load_kernel
  2702. @subsubsection @code{starpu_opencl_load_kernel} -- Loading a kernel
  2703. @table @asis
  2704. @item @emph{Description}:
  2705. TODO
  2706. @item @emph{Prototype}:
  2707. @code{int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, char *kernel_name, int devid)
  2708. }
  2709. @end table
  2710. @node starpu_opencl_relase_kernel
  2711. @subsubsection @code{starpu_opencl_release_kernel} -- Releasing a kernel
  2712. @table @asis
  2713. @item @emph{Description}:
  2714. TODO
  2715. @item @emph{Prototype}:
  2716. @code{int starpu_opencl_release_kernel(cl_kernel kernel);}
  2717. @end table
  2718. @node Cell extensions
  2719. @section Cell extensions
  2720. nothing yet.
  2721. @node Miscellaneous helpers
  2722. @section Miscellaneous helpers
  2723. @menu
  2724. * starpu_execute_on_each_worker:: Execute a function on a subset of workers
  2725. @end menu
  2726. @node starpu_execute_on_each_worker
  2727. @subsection @code{starpu_execute_on_each_worker} -- Execute a function on a subset of workers
  2728. @table @asis
  2729. @item @emph{Description}:
  2730. When calling this method, the offloaded function specified by the first argument is
  2731. executed by every StarPU worker that may execute the function.
  2732. The second argument is passed to the offloaded function.
  2733. The last argument specifies on which types of processing units the function
  2734. should be executed. Similarly to the @code{where} field of the
  2735. @code{starpu_codelet} structure, it is possible to specify that the function
  2736. should be executed on every CUDA device and every CPU by passing
  2737. @code{STARPU_CPU|STARPU_CUDA}.
  2738. This function blocks until the function has been executed on every appropriate
  2739. processing units, so that it may not be called from a callback function for
  2740. instance.
  2741. @item @emph{Prototype}:
  2742. @code{void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);}
  2743. @end table
  2744. @c ---------------------------------------------------------------------
  2745. @c Advanced Topics
  2746. @c ---------------------------------------------------------------------
  2747. @node Advanced Topics
  2748. @chapter Advanced Topics
  2749. @menu
  2750. * Defining a new data interface::
  2751. * Defining a new scheduling policy::
  2752. @end menu
  2753. @node Defining a new data interface
  2754. @section Defining a new data interface
  2755. @menu
  2756. * struct starpu_data_interface_ops_t:: Per-interface methods
  2757. * struct starpu_data_copy_methods:: Per-interface data transfer methods
  2758. * An example of data interface:: An example of data interface
  2759. @end menu
  2760. @c void *starpu_data_get_interface_on_node(starpu_data_handle handle, unsigned memory_node); TODO
  2761. @node struct starpu_data_interface_ops_t
  2762. @subsection @code{struct starpu_data_interface_ops_t} -- Per-interface methods
  2763. @table @asis
  2764. @item @emph{Description}:
  2765. TODO describe all the different fields
  2766. @end table
  2767. @node struct starpu_data_copy_methods
  2768. @subsection @code{struct starpu_data_copy_methods} -- Per-interface data transfer methods
  2769. @table @asis
  2770. @item @emph{Description}:
  2771. TODO describe all the different fields
  2772. @end table
  2773. @node An example of data interface
  2774. @subsection An example of data interface
  2775. @table @asis
  2776. TODO
  2777. @end table
  2778. @node Defining a new scheduling policy
  2779. @section Defining a new scheduling policy
  2780. TODO
  2781. A full example showing how to define a new scheduling policy is available in
  2782. the StarPU sources in the directory @code{examples/scheduler/}.
  2783. @menu
  2784. * struct starpu_sched_policy_s::
  2785. * starpu_worker_set_sched_condition::
  2786. * Source code::
  2787. @end menu
  2788. @node struct starpu_sched_policy_s
  2789. @subsection @code{struct starpu_sched_policy_s} -- Scheduler methods
  2790. @table @asis
  2791. @item @emph{Description}:
  2792. This structure contains all the methods that implement a scheduling policy. An
  2793. application may specify which scheduling strategy in the @code{sched_policy}
  2794. field of the @code{starpu_conf} structure passed to the @code{starpu_init}
  2795. function.
  2796. @item @emph{Fields}:
  2797. @table @asis
  2798. @item @code{init_sched}:
  2799. Initialize the scheduling policy.
  2800. @item @code{deinit_sched}:
  2801. Cleanup the scheduling policy.
  2802. @item @code{push_task}:
  2803. Insert a task into the scheduler.
  2804. @item @code{push_prio_task}:
  2805. Insert a priority task into the scheduler.
  2806. @item @code{pop_task}:
  2807. Get a task from the scheduler. The mutex associated to the worker is already
  2808. taken when this method is called.
  2809. @item @code{pop_every_task}:
  2810. Remove all available tasks from the scheduler (tasks are chained by the means
  2811. of the prev and next fields of the starpu_task structure). The mutex associated
  2812. to the worker is already taken when this method is called.
  2813. @item @code{post_exec_hook} (optionnal):
  2814. This method is called every time a task has been executed.
  2815. @item @code{policy_name}:
  2816. Name of the policy (optionnal).
  2817. @item @code{policy_description}:
  2818. Description of the policy (optionnal).
  2819. @end table
  2820. @end table
  2821. @node starpu_worker_set_sched_condition
  2822. @subsection @code{starpu_worker_set_sched_condition} -- Specify the condition variable associated to a worker
  2823. @table @asis
  2824. @item @emph{Description}:
  2825. When there is no available task for a worker, StarPU blocks this worker on a
  2826. condition variable. This function specifies which condition variable (and the
  2827. associated mutex) should be used to block (and to wake up) a worker. Note that
  2828. multiple workers may use the same condition variable. For instance, in the case
  2829. of a scheduling strategy with a single task queue, the same condition variable
  2830. would be used to block and wake up all workers.
  2831. The initialization method of a scheduling strategy (@code{init_sched}) must
  2832. call this function once per worker.
  2833. @item @emph{Prototype}:
  2834. @code{void starpu_worker_set_sched_condition(int workerid, pthread_cond_t *sched_cond, pthread_mutex_t *sched_mutex);}
  2835. @end table
  2836. @node Source code
  2837. @subsection Source code
  2838. @cartouche
  2839. @smallexample
  2840. static struct starpu_sched_policy_s dummy_sched_policy = @{
  2841. .init_sched = init_dummy_sched,
  2842. .deinit_sched = deinit_dummy_sched,
  2843. .push_task = push_task_dummy,
  2844. .push_prio_task = NULL,
  2845. .pop_task = pop_task_dummy,
  2846. .post_exec_hook = NULL,
  2847. .pop_every_task = NULL,
  2848. .policy_name = "dummy",
  2849. .policy_description = "dummy scheduling strategy"
  2850. @};
  2851. @end smallexample
  2852. @end cartouche
  2853. @c ---------------------------------------------------------------------
  2854. @c Appendices
  2855. @c ---------------------------------------------------------------------
  2856. @c ---------------------------------------------------------------------
  2857. @c Full source code for the 'Scaling a Vector' example
  2858. @c ---------------------------------------------------------------------
  2859. @node Full source code for the 'Scaling a Vector' example
  2860. @appendix Full source code for the 'Scaling a Vector' example
  2861. @menu
  2862. * Main application::
  2863. * CPU Codelet::
  2864. * CUDA Codelet::
  2865. * OpenCL Codelet::
  2866. @end menu
  2867. @node Main application
  2868. @section Main application
  2869. @smallexample
  2870. @include vector_scal_c.texi
  2871. @end smallexample
  2872. @node CPU Codelet
  2873. @section CPU Codelet
  2874. @smallexample
  2875. @include vector_scal_cpu.texi
  2876. @end smallexample
  2877. @node CUDA Codelet
  2878. @section CUDA Codelet
  2879. @smallexample
  2880. @include vector_scal_cuda.texi
  2881. @end smallexample
  2882. @node OpenCL Codelet
  2883. @section OpenCL Codelet
  2884. @menu
  2885. * Invoking the kernel::
  2886. * Source of the kernel::
  2887. @end menu
  2888. @node Invoking the kernel
  2889. @subsection Invoking the kernel
  2890. @smallexample
  2891. @include vector_scal_opencl.texi
  2892. @end smallexample
  2893. @node Source of the kernel
  2894. @subsection Source of the kernel
  2895. @smallexample
  2896. @include vector_scal_opencl_codelet.texi
  2897. @end smallexample
  2898. @bye