starpu.texi 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421
  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. * Configuring StarPU:: How to configure StarPU
  30. * StarPU API:: The API to use StarPU
  31. * Advanced Topics:: Advanced use of StarPU
  32. * Basic Examples:: Basic examples of the 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. * Configuration of StarPU::
  115. * Building and Installing StarPU::
  116. @end menu
  117. StarPU can be built and installed by the standard means of the GNU
  118. autotools. The following chapter is intended to briefly remind how these tools
  119. can be used to install StarPU.
  120. @node Configuration of StarPU
  121. @section Configuration of StarPU
  122. @menu
  123. * Generating Makefiles and configuration scripts::
  124. * Running the configuration::
  125. @end menu
  126. @node Generating Makefiles and configuration scripts
  127. @subsection Generating Makefiles and configuration scripts
  128. This step is not necessary when using the tarball releases of StarPU. If you
  129. are using the source code from the svn repository, you first need to generate
  130. the configure scripts and the Makefiles.
  131. @example
  132. % autoreconf -vfi
  133. @end example
  134. @node Running the configuration
  135. @subsection Running the configuration
  136. @example
  137. % ./configure
  138. @end example
  139. Details about options that are useful to give to @code{./configure} are given in
  140. @ref{Compilation configuration}.
  141. @node Building and Installing StarPU
  142. @section Building and Installing StarPU
  143. @menu
  144. * Building::
  145. * Sanity Checks::
  146. * Installing::
  147. @end menu
  148. @node Building
  149. @subsection Building
  150. @example
  151. % make
  152. @end example
  153. @node Sanity Checks
  154. @subsection Sanity Checks
  155. In order to make sure that StarPU is working properly on the system, it is also
  156. possible to run a test suite.
  157. @example
  158. % make check
  159. @end example
  160. @node Installing
  161. @subsection Installing
  162. In order to install StarPU at the location that was specified during
  163. configuration:
  164. @example
  165. % make install
  166. @end example
  167. @c ---------------------------------------------------------------------
  168. @c Using StarPU
  169. @c ---------------------------------------------------------------------
  170. @node Using StarPU
  171. @chapter Using StarPU
  172. @menu
  173. * Setting flags for compiling and linking applications::
  174. * Running a basic StarPU application::
  175. @end menu
  176. @node Setting flags for compiling and linking applications
  177. @section Setting flags for compiling and linking applications
  178. Compiling and linking an application against StarPU may require to use
  179. specific flags or libraries (for instance @code{CUDA} or @code{libspe2}).
  180. To this end, it is possible to use the @code{pkg-config} tool.
  181. If StarPU was not installed at some standard location, the path of StarPU's
  182. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  183. that @code{pkg-config} can find it. For example if StarPU was installed in
  184. @code{$prefix_dir}:
  185. @example
  186. % PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$prefix_dir/lib/pkgconfig
  187. @end example
  188. The flags required to compile or link against StarPU are then
  189. accessible with the following commands:
  190. @example
  191. % pkg-config --cflags libstarpu # options for the compiler
  192. % pkg-config --libs libstarpu # options for the linker
  193. @end example
  194. @node Running a basic StarPU application
  195. @section Running a basic StarPU application
  196. Basic examples using StarPU have been built in the directory
  197. @code{$prefix_dir/lib/starpu/examples/}. You can for example run the
  198. example @code{vector_scal}.
  199. @example
  200. % $prefix_dir/lib/starpu/examples/vector_scal
  201. BEFORE : First element was 1.000000
  202. AFTER First element is 3.140000
  203. %
  204. @end example
  205. @c ---------------------------------------------------------------------
  206. @c Configuration options
  207. @c ---------------------------------------------------------------------
  208. @node Configuring StarPU
  209. @chapter Configuring StarPU
  210. @menu
  211. * Compilation configuration::
  212. * Execution configuration through environment variables::
  213. @end menu
  214. @node Compilation configuration
  215. @section Compilation configuration
  216. The following arguments can be given to the @code{configure} script.
  217. @menu
  218. * Common configuration::
  219. * Configuring workers::
  220. * Advanced configuration::
  221. @end menu
  222. @node Common configuration
  223. @subsection Common configuration
  224. @menu
  225. * --enable-debug::
  226. * --enable-fast::
  227. * --enable-verbose::
  228. * --enable-coverage::
  229. @end menu
  230. @node --enable-debug
  231. @subsubsection @code{--enable-debug}
  232. @table @asis
  233. @item @emph{Description}:
  234. Enable debugging messages.
  235. @end table
  236. @node --enable-fast
  237. @subsubsection @code{--enable-fast}
  238. @table @asis
  239. @item @emph{Description}:
  240. Do not enforce assertions, saves a lot of time spent to compute them otherwise.
  241. @end table
  242. @node --enable-verbose
  243. @subsubsection @code{--enable-verbose}
  244. @table @asis
  245. @item @emph{Description}:
  246. Augment the verbosity of the debugging messages.
  247. @end table
  248. @node --enable-coverage
  249. @subsubsection @code{--enable-coverage}
  250. @table @asis
  251. @item @emph{Description}:
  252. Enable flags for the coverage tool.
  253. @end table
  254. @node Configuring workers
  255. @subsection Configuring workers
  256. @menu
  257. * --disable-cpu::
  258. * --enable-maxcudadev::
  259. * --disable-cuda::
  260. * --with-cuda-dir::
  261. * --enable-maxopencldev::
  262. * --disable-opencl::
  263. * --with-opencl-dir::
  264. * --enable-gordon::
  265. * --with-gordon-dir::
  266. @end menu
  267. @node --disable-cpu
  268. @subsubsection @code{--disable-cpu}
  269. @table @asis
  270. @item @emph{Description}:
  271. Disable the use of CPUs of the machine. Only GPUs etc. will be used.
  272. @end table
  273. @node --enable-maxcudadev
  274. @subsubsection @code{--enable-maxcudadev=<number>}
  275. @table @asis
  276. @item @emph{Description}:
  277. Defines the maximum number of CUDA devices that StarPU will support, then
  278. available as the @code{STARPU_MAXCUDADEVS} macro.
  279. @end table
  280. @node --disable-cuda
  281. @subsubsection @code{--disable-cuda}
  282. @table @asis
  283. @item @emph{Description}:
  284. Disable the use of CUDA, even if a valid CUDA installation was detected.
  285. @end table
  286. @node --with-cuda-dir
  287. @subsubsection @code{--with-cuda-dir=<path>}
  288. @table @asis
  289. @item @emph{Description}:
  290. Specify the directory where CUDA is installed. This directory should notably contain
  291. @code{include/cuda.h}.
  292. @end table
  293. @node --enable-maxopencldev
  294. @subsubsection @code{--enable-maxopencldev=<number>}
  295. @table @asis
  296. @item @emph{Description}:
  297. Defines the maximum number of OpenCL devices that StarPU will support, then
  298. available as the @code{STARPU_MAXOPENCLDEVS} macro.
  299. @end table
  300. @node --disable-opencl
  301. @subsubsection @code{--disable-opencl}
  302. @table @asis
  303. @item @emph{Description}:
  304. Disable the use of OpenCL, even if the SDK is detected.
  305. @end table
  306. @node --with-opencl-dir
  307. @subsubsection @code{--with-opencl-dir=<path>}
  308. @table @asis
  309. @item @emph{Description}:
  310. Specify the location of the OpenCL SDK. This directory should notably contain
  311. @code{include/CL/cl.h}.
  312. @end table
  313. @node --enable-gordon
  314. @subsubsection @code{--enable-gordon}
  315. @table @asis
  316. @item @emph{Description}:
  317. Enable the use of the Gordon runtime for Cell SPUs.
  318. @c TODO: rather default to enabled when detected
  319. @end table
  320. @node --with-gordon-dir
  321. @subsubsection @code{--with-gordon-dir=<path>}
  322. @table @asis
  323. @item @emph{Description}:
  324. Specify the location of the Gordon SDK.
  325. @end table
  326. @node Advanced configuration
  327. @subsection Advanced configuration
  328. @menu
  329. * --enable-perf-debug::
  330. * --enable-model-debug::
  331. * --enable-stats::
  332. * --enable-maxbuffers::
  333. * --enable-allocation-cache::
  334. * --enable-opengl-render::
  335. * --enable-blas-lib::
  336. * --with-magma::
  337. * --with-fxt::
  338. * --with-perf-model-dir::
  339. * --with-mpicc::
  340. * --with-mpi::
  341. * --with-goto-dir::
  342. * --with-atlas-dir::
  343. @end menu
  344. @node --enable-perf-debug
  345. @subsubsection @code{--enable-perf-debug}
  346. @table @asis
  347. @item @emph{Description}:
  348. Enable performance debugging.
  349. @end table
  350. @node --enable-model-debug
  351. @subsubsection @code{--enable-model-debug}
  352. @table @asis
  353. @item @emph{Description}:
  354. Enable performance model debugging.
  355. @end table
  356. @node --enable-stats
  357. @subsubsection @code{--enable-stats}
  358. @table @asis
  359. @item @emph{Description}:
  360. Enable statistics.
  361. @end table
  362. @node --enable-maxbuffers
  363. @subsubsection @code{--enable-maxbuffers=<nbuffers>}
  364. @table @asis
  365. @item @emph{Description}:
  366. Define the maximum number of buffers that tasks will be able to take
  367. as parameters, then available as the @code{STARPU_NMAXBUFS} macro.
  368. @end table
  369. @node --enable-allocation-cache
  370. @subsubsection @code{--enable-allocation-cache}
  371. @table @asis
  372. @item @emph{Description}:
  373. Enable the use of a data allocation cache to avoid the cost of it with
  374. CUDA. Still experimental.
  375. @end table
  376. @node --enable-opengl-render
  377. @subsubsection @code{--enable-opengl-render}
  378. @table @asis
  379. @item @emph{Description}:
  380. Enable the use of OpenGL for the rendering of some examples.
  381. @c TODO: rather default to enabled when detected
  382. @end table
  383. @node --enable-blas-lib
  384. @subsubsection @code{--enable-blas-lib=<name>}
  385. @table @asis
  386. @item @emph{Description}:
  387. Specify the blas library to be used by some of the examples. The
  388. library has to be 'atlas' or 'goto'.
  389. @end table
  390. @node --with-magma
  391. @subsubsection @code{--with-magma=<path>}
  392. @table @asis
  393. @item @emph{Description}:
  394. Specify where magma is installed.
  395. @end table
  396. @node --with-fxt
  397. @subsubsection @code{--with-fxt=<path>}
  398. @table @asis
  399. @item @emph{Description}:
  400. Specify the location of FxT (for generating traces and rendering them
  401. using ViTE). This directory should notably contain
  402. @code{include/fxt/fxt.h}.
  403. @end table
  404. @node --with-perf-model-dir
  405. @subsubsection @code{--with-perf-model-dir=<dir>}
  406. @table @asis
  407. @item @emph{Description}:
  408. Specify where performance models should be stored (instead of defaulting to the
  409. current user's home).
  410. @end table
  411. @node --with-mpicc
  412. @subsubsection @code{--with-mpicc=<path to mpicc>}
  413. @table @asis
  414. @item @emph{Description}:
  415. Specify the location of the @code{mpicc} compiler to be used for starpumpi.
  416. @c TODO: also just use AC_PROG
  417. @end table
  418. @node --with-mpi
  419. @subsubsection @code{--with-mpi}
  420. @table @asis
  421. @item @emph{Description}:
  422. Enable building libstarpumpi.
  423. @c TODO: rather just use the availability of mpicc instead of a second option
  424. @end table
  425. @node --with-goto-dir
  426. @subsubsection @code{--with-goto-dir=<dir>}
  427. @table @asis
  428. @item @emph{Description}:
  429. Specify the location of GotoBLAS.
  430. @end table
  431. @node --with-atlas-dir
  432. @subsubsection @code{--with-atlas-dir=<dir>}
  433. @table @asis
  434. @item @emph{Description}:
  435. Specify the location of ATLAS. This directory should notably contain
  436. @code{include/cblas.h}.
  437. @end table
  438. @c ---------------------------------------------------------------------
  439. @c Environment variables
  440. @c ---------------------------------------------------------------------
  441. @node Execution configuration through environment variables
  442. @section Execution configuration through environment variables
  443. @menu
  444. * Workers:: Configuring workers
  445. * Scheduling:: Configuring the Scheduling engine
  446. * Misc:: Miscellaneous and debug
  447. @end menu
  448. Note: the values given in @code{starpu_conf} structure passed when
  449. calling @code{starpu_init} will override the values of the environment
  450. variables.
  451. @node Workers
  452. @subsection Configuring workers
  453. @menu
  454. * STARPU_NCPUS:: Number of CPU workers
  455. * STARPU_NCUDA:: Number of CUDA workers
  456. * STARPU_NOPENCL:: Number of OpenCL workers
  457. * STARPU_NGORDON:: Number of SPU workers (Cell)
  458. * STARPU_WORKERS_CPUID:: Bind workers to specific CPUs
  459. * STARPU_WORKERS_CUDAID:: Select specific CUDA devices
  460. * STARPU_WORKERS_OPENCLID:: Select specific OpenCL devices
  461. @end menu
  462. @node STARPU_NCPUS
  463. @subsubsection @code{STARPU_NCPUS} -- Number of CPU workers
  464. @table @asis
  465. @item @emph{Description}:
  466. Specify the maximum number of CPU workers. Note that StarPU will not allocate
  467. more CPUs than there are physical CPUs, and that some CPUs are used to control
  468. the accelerators.
  469. @end table
  470. @node STARPU_NCUDA
  471. @subsubsection @code{STARPU_NCUDA} -- Number of CUDA workers
  472. @table @asis
  473. @item @emph{Description}:
  474. Specify the maximum number of CUDA devices that StarPU can use. If
  475. @code{STARPU_NCUDA} is lower than the number of physical devices, it is
  476. possible to select which CUDA devices should be used by the means of the
  477. @code{STARPU_WORKERS_CUDAID} environment variable.
  478. @end table
  479. @node STARPU_NOPENCL
  480. @subsubsection @code{STARPU_NOPENCL} -- Number of OpenCL workers
  481. @table @asis
  482. @item @emph{Description}:
  483. OpenCL equivalent of the @code{STARPU_NCUDA} environment variable.
  484. @end table
  485. @node STARPU_NGORDON
  486. @subsubsection @code{STARPU_NGORDON} -- Number of SPU workers (Cell)
  487. @table @asis
  488. @item @emph{Description}:
  489. Specify the maximum number of SPUs that StarPU can use.
  490. @end table
  491. @node STARPU_WORKERS_CPUID
  492. @subsubsection @code{STARPU_WORKERS_CPUID} -- Bind workers to specific CPUs
  493. @table @asis
  494. @item @emph{Description}:
  495. Passing an array of integers (starting from 0) in @code{STARPU_WORKERS_CPUID}
  496. specifies on which logical CPU the different workers should be
  497. bound. For instance, if @code{STARPU_WORKERS_CPUID = "1 3 0 2"}, the first
  498. worker will be bound to logical CPU #1, the second CPU worker will be bound to
  499. logical CPU #3 and so on. Note that the logical ordering of the CPUs is either
  500. determined by the OS, or provided by the @code{hwloc} library in case it is
  501. available.
  502. Note that the first workers correspond to the CUDA workers, then come the
  503. OpenCL and the SPU, and finally the CPU workers. For example if
  504. we have @code{STARPU_NCUDA=1}, @code{STARPU_NOPENCL=1}, @code{STARPU_NCPUS=2}
  505. and @code{STARPU_WORKERS_CPUID = "0 2 1 3"}, the CUDA device will be controlled
  506. by logical CPU #0, the OpenCL device will be controlled by logical CPU #2, and
  507. the logical CPUs #1 and #3 will be used by the CPU workers.
  508. If the number of workers is larger than the array given in
  509. @code{STARPU_WORKERS_CPUID}, the workers are bound to the logical CPUs in a
  510. round-robin fashion: if @code{STARPU_WORKERS_CPUID = "0 1"}, the first and the
  511. third (resp. second and fourth) workers will be put on CPU #0 (resp. CPU #1).
  512. @end table
  513. @node STARPU_WORKERS_CUDAID
  514. @subsubsection @code{STARPU_WORKERS_CUDAID} -- Select specific CUDA devices
  515. @table @asis
  516. @item @emph{Description}:
  517. Similarly to the @code{STARPU_WORKERS_CPUID} environment variable, it is
  518. possible to select which CUDA devices should be used by StarPU. On a machine
  519. equipped with 4 GPUs, setting @code{STARPU_WORKERS_CUDAID = "1 3"} and
  520. @code{STARPU_NCUDA=2} specifies that 2 CUDA workers should be created, and that
  521. they should use CUDA devices #1 and #3 (the logical ordering of the devices is
  522. the one reported by CUDA).
  523. @end table
  524. @node STARPU_WORKERS_OPENCLID
  525. @subsubsection @code{STARPU_WORKERS_OPENCLID} -- Select specific OpenCL devices
  526. @table @asis
  527. @item @emph{Description}:
  528. OpenCL equivalent of the @code{STARPU_WORKERS_CUDAID} environment variable.
  529. @end table
  530. @node Scheduling
  531. @subsection Configuring the Scheduling engine
  532. @menu
  533. * STARPU_SCHED:: Scheduling policy
  534. * STARPU_CALIBRATE:: Calibrate performance models
  535. * STARPU_PREFETCH:: Use data prefetch
  536. * STARPU_SCHED_ALPHA:: Computation factor
  537. * STARPU_SCHED_BETA:: Communication factor
  538. @end menu
  539. @node STARPU_SCHED
  540. @subsubsection @code{STARPU_SCHED} -- Scheduling policy
  541. @table @asis
  542. @item @emph{Description}:
  543. This chooses between the different scheduling policies proposed by StarPU: work
  544. random, stealing, greedy, with performance models, etc.
  545. Use @code{STARPU_SCHED=help} to get the list of available schedulers.
  546. @end table
  547. @node STARPU_CALIBRATE
  548. @subsubsection @code{STARPU_CALIBRATE} -- Calibrate performance models
  549. @table @asis
  550. @item @emph{Description}:
  551. If this variable is set to 1, the performance models are calibrated during
  552. the execution. If it is set to 2, the previous values are dropped to restart
  553. calibration from scratch.
  554. Note: this currently only applies to dm and dmda scheduling policies.
  555. @end table
  556. @node STARPU_PREFETCH
  557. @subsubsection @code{STARPU_PREFETCH} -- Use data prefetch
  558. @table @asis
  559. @item @emph{Description}:
  560. If this variable is set, data prefetching will be enabled, that is when a task is
  561. scheduled to be executed e.g. on a GPU, StarPU will request an asynchronous
  562. transfer in advance, so that data is already present on the GPU when the task
  563. starts. As a result, computation and data transfers are overlapped.
  564. @end table
  565. @node STARPU_SCHED_ALPHA
  566. @subsubsection @code{STARPU_SCHED_ALPHA} -- Computation factor
  567. @table @asis
  568. @item @emph{Description}:
  569. To estimate the cost of a task StarPU takes into account the estimated
  570. computation time (obtained thanks to performance models). The alpha factor is
  571. the coefficient to be applied to it before adding it to the communication part.
  572. @end table
  573. @node STARPU_SCHED_BETA
  574. @subsubsection @code{STARPU_SCHED_BETA} -- Communication factor
  575. @table @asis
  576. @item @emph{Description}:
  577. To estimate the cost of a task StarPU takes into account the estimated
  578. data transfer time (obtained thanks to performance models). The beta factor is
  579. the coefficient to be applied to it before adding it to the computation part.
  580. @end table
  581. @node Misc
  582. @subsection Miscellaneous and debug
  583. @menu
  584. * STARPU_LOGFILENAME:: Select debug file name
  585. @end menu
  586. @node STARPU_LOGFILENAME
  587. @subsubsection @code{STARPU_LOGFILENAME} -- Select debug file name
  588. @table @asis
  589. @item @emph{Description}:
  590. This variable specify in which file the debugging output should be saved to.
  591. @end table
  592. @c ---------------------------------------------------------------------
  593. @c StarPU API
  594. @c ---------------------------------------------------------------------
  595. @node StarPU API
  596. @chapter StarPU API
  597. @menu
  598. * Initialization and Termination:: Initialization and Termination methods
  599. * Workers' Properties:: Methods to enumerate workers' properties
  600. * Data Library:: Methods to manipulate data
  601. * Codelets and Tasks:: Methods to construct tasks
  602. * Tags:: Task dependencies
  603. * Profiling API:: Profiling API
  604. * CUDA extensions:: CUDA extensions
  605. * OpenCL extensions:: OpenCL extensions
  606. * Cell extensions:: Cell extensions
  607. * Miscellaneous helpers::
  608. @end menu
  609. @node Initialization and Termination
  610. @section Initialization and Termination
  611. @menu
  612. * starpu_init:: Initialize StarPU
  613. * struct starpu_conf:: StarPU runtime configuration
  614. * starpu_shutdown:: Terminate StarPU
  615. @end menu
  616. @node starpu_init
  617. @subsection @code{starpu_init} -- Initialize StarPU
  618. @table @asis
  619. @item @emph{Description}:
  620. This is StarPU initialization method, which must be called prior to any other
  621. StarPU call. It is possible to specify StarPU's configuration (e.g. scheduling
  622. policy, number of cores, ...) by passing a non-null argument. Default
  623. configuration is used if the passed argument is @code{NULL}.
  624. @item @emph{Return value}:
  625. Upon successful completion, this function returns 0. Otherwise, @code{-ENODEV}
  626. indicates that no worker was available (so that StarPU was not initialized).
  627. @item @emph{Prototype}:
  628. @code{int starpu_init(struct starpu_conf *conf);}
  629. @end table
  630. @node struct starpu_conf
  631. @subsection @code{struct starpu_conf} -- StarPU runtime configuration
  632. @table @asis
  633. @item @emph{Description}:
  634. This structure is passed to the @code{starpu_init} function in order
  635. to configure StarPU.
  636. When the default value is used, StarPU automatically selects the number
  637. of processing units and takes the default scheduling policy. This parameter
  638. overwrites the equivalent environment variables.
  639. @item @emph{Fields}:
  640. @table @asis
  641. @item @code{sched_policy_name} (default = NULL):
  642. This is the name of the scheduling policy. This can also be specified with the
  643. @code{STARPU_SCHED} environment variable.
  644. @item @code{sched_policy} (default = NULL):
  645. This is the definition of the scheduling policy. This field is ignored
  646. if @code{sched_policy_name} is set.
  647. @item @code{ncpus} (default = -1):
  648. This is the maximum number of CPU cores that StarPU can use. This can also be
  649. specified with the @code{STARPU_NCPUS} environment variable.
  650. @item @code{ncuda} (default = -1):
  651. This is the maximum number of CUDA devices that StarPU can use. This can also be
  652. specified with the @code{STARPU_NCUDA} environment variable.
  653. @item @code{nopencl} (default = -1):
  654. This is the maximum number of OpenCL devices that StarPU can use. This can also be
  655. specified with the @code{STARPU_NOPENCL} environment variable.
  656. @item @code{nspus} (default = -1):
  657. This is the maximum number of Cell SPUs that StarPU can use. This can also be
  658. specified with the @code{STARPU_NGORDON} environment variable.
  659. @item @code{use_explicit_workers_bindid} (default = 0)
  660. If this flag is set, the @code{workers_bindid} array indicates where the
  661. different workers are bound, otherwise StarPU automatically selects where to
  662. bind the different workers unless the @code{STARPU_WORKERS_CPUID} environment
  663. variable is set. The @code{STARPU_WORKERS_CPUID} environment variable is
  664. ignored if the @code{use_explicit_workers_bindid} flag is set.
  665. @item @code{workers_bindid[STARPU_NMAXWORKERS]}
  666. If the @code{use_explicit_workers_bindid} flag is set, this array indicates
  667. where to bind the different workers. The i-th entry of the
  668. @code{workers_bindid} indicates the logical identifier of the processor which
  669. should execute the i-th worker. Note that the logical ordering of the CPUs is
  670. either determined by the OS, or provided by the @code{hwloc} library in case it
  671. is available.
  672. @item @code{use_explicit_workers_cuda_gpuid} (default = 0)
  673. @item @code{workers_cuda_gpuid[STARPU_NMAXWORKERS]}
  674. @item @code{use_explicit_workers_opencl_gpuid} (default = 0)
  675. @item @code{workers_opencl_gpuid[STARPU_NMAXWORKERS]}:
  676. These fields are explained in @ref{STARPU_WORKERS_CPUID}.
  677. @item @code{calibrate} (default = 0):
  678. If this flag is set, StarPU will calibrate the performance models when
  679. executing tasks. This can also be specified with the @code{STARPU_CALIBRATE}
  680. environment variable.
  681. @end table
  682. @end table
  683. @node starpu_shutdown
  684. @subsection @code{starpu_shutdown} -- Terminate StarPU
  685. @table @asis
  686. @item @emph{Description}:
  687. This is StarPU termination method. It must be called at the end of the
  688. application: statistics and other post-mortem debugging information are not
  689. guaranteed to be available until this method has been called.
  690. @item @emph{Prototype}:
  691. @code{void starpu_shutdown(void);}
  692. @end table
  693. @node Workers' Properties
  694. @section Workers' Properties
  695. @menu
  696. * starpu_worker_get_count:: Get the number of processing units
  697. * starpu_cpu_worker_get_count:: Get the number of CPU controlled by StarPU
  698. * starpu_cuda_worker_get_count:: Get the number of CUDA devices controlled by StarPU
  699. * starpu_opencl_worker_get_count:: Get the number of OpenCL devices controlled by StarPU
  700. * starpu_spu_worker_get_count:: Get the number of Cell SPUs controlled by StarPU
  701. * starpu_worker_get_id:: Get the identifier of the current worker
  702. * starpu_worker_get_type:: Get the type of processing unit associated to a worker
  703. * starpu_worker_get_name:: Get the name of a worker
  704. @end menu
  705. @node starpu_worker_get_count
  706. @subsection @code{starpu_worker_get_count} -- Get the number of processing units
  707. @table @asis
  708. @item @emph{Description}:
  709. This function returns the number of workers (i.e. processing units executing
  710. StarPU tasks). The returned value should be at most @code{STARPU_NMAXWORKERS}.
  711. @item @emph{Prototype}:
  712. @code{unsigned starpu_worker_get_count(void);}
  713. @end table
  714. @node starpu_cpu_worker_get_count
  715. @subsection @code{starpu_cpu_worker_get_count} -- Get the number of CPU controlled by StarPU
  716. @table @asis
  717. @item @emph{Description}:
  718. This function returns the number of CPUs controlled by StarPU. The returned
  719. value should be at most @code{STARPU_NMAXCPUS}.
  720. @item @emph{Prototype}:
  721. @code{unsigned starpu_cpu_worker_get_count(void);}
  722. @end table
  723. @node starpu_cuda_worker_get_count
  724. @subsection @code{starpu_cuda_worker_get_count} -- Get the number of CUDA devices controlled by StarPU
  725. @table @asis
  726. @item @emph{Description}:
  727. This function returns the number of CUDA devices controlled by StarPU. The returned
  728. value should be at most @code{STARPU_MAXCUDADEVS}.
  729. @item @emph{Prototype}:
  730. @code{unsigned starpu_cuda_worker_get_count(void);}
  731. @end table
  732. @node starpu_opencl_worker_get_count
  733. @subsection @code{starpu_opencl_worker_get_count} -- Get the number of OpenCL devices controlled by StarPU
  734. @table @asis
  735. @item @emph{Description}:
  736. This function returns the number of OpenCL devices controlled by StarPU. The returned
  737. value should be at most @code{STARPU_MAXOPENCLDEVS}.
  738. @item @emph{Prototype}:
  739. @code{unsigned starpu_opencl_worker_get_count(void);}
  740. @end table
  741. @node starpu_spu_worker_get_count
  742. @subsection @code{starpu_spu_worker_get_count} -- Get the number of Cell SPUs controlled by StarPU
  743. @table @asis
  744. @item @emph{Description}:
  745. This function returns the number of Cell SPUs controlled by StarPU.
  746. @item @emph{Prototype}:
  747. @code{unsigned starpu_opencl_worker_get_count(void);}
  748. @end table
  749. @node starpu_worker_get_id
  750. @subsection @code{starpu_worker_get_id} -- Get the identifier of the current worker
  751. @table @asis
  752. @item @emph{Description}:
  753. This function returns the identifier of the worker associated to the calling
  754. thread. The returned value is either -1 if the current context is not a StarPU
  755. worker (i.e. when called from the application outside a task or a callback), or
  756. an integer between 0 and @code{starpu_worker_get_count() - 1}.
  757. @item @emph{Prototype}:
  758. @code{int starpu_worker_get_id(void);}
  759. @end table
  760. @node starpu_worker_get_type
  761. @subsection @code{starpu_worker_get_type} -- Get the type of processing unit associated to a worker
  762. @table @asis
  763. @item @emph{Description}:
  764. This function returns the type of worker associated to an identifier (as
  765. returned by the @code{starpu_worker_get_id} function). The returned value
  766. indicates the architecture of the worker: @code{STARPU_CPU_WORKER} for a CPU
  767. core, @code{STARPU_CUDA_WORKER} for a CUDA device,
  768. @code{STARPU_OPENCL_WORKER} for a OpenCL device, and
  769. @code{STARPU_GORDON_WORKER} for a Cell SPU. The value returned for an invalid
  770. identifier is unspecified.
  771. @item @emph{Prototype}:
  772. @code{enum starpu_archtype starpu_worker_get_type(int id);}
  773. @end table
  774. @node starpu_worker_get_name
  775. @subsection @code{starpu_worker_get_name} -- Get the name of a worker
  776. @table @asis
  777. @item @emph{Description}:
  778. StarPU associates a unique human readable string to each processing unit. This
  779. function copies at most the @code{maxlen} first bytes of the unique string
  780. associated to a worker identified by its identifier @code{id} into the
  781. @code{dst} buffer. The caller is responsible for ensuring that the @code{dst}
  782. is a valid pointer to a buffer of @code{maxlen} bytes at least. Calling this
  783. function on an invalid identifier results in an unspecified behaviour.
  784. @item @emph{Prototype}:
  785. @code{void starpu_worker_get_name(int id, char *dst, size_t maxlen);}
  786. @end table
  787. @node Data Library
  788. @section Data Library
  789. This section describes the data management facilities provided by StarPU.
  790. TODO: We show how to use existing data interfaces in [ref], but developers can
  791. design their own data interfaces if required.
  792. @menu
  793. * unsigned memory_node:: Memory node
  794. * starpu_data_handle:: StarPU opaque data handle
  795. * void *interface:: StarPU data interface
  796. * starpu_data_register:: Register a piece of data to StarPU
  797. * starpu_data_unregister:: Unregister a piece of data from StarPU
  798. @end menu
  799. @node unsigned memory_node
  800. @subsection @code{unsigned memory_node} -- Memory node
  801. @table @asis
  802. @item @emph{Description}:
  803. Every worker is associated to a memory node which is a logical abstraction of
  804. the address space from which the processing unit gets its data. For instance,
  805. the memory node associated to the different CPU workers represents main memory
  806. (RAM), the memory node associated to a GPU is DRAM embedded on the device.
  807. Every memory node is identified by a logical index which is accessible from the
  808. @code{starpu_worker_get_memory_node} function. When registering a piece of data
  809. to StarPU, the specified memory node indicates where the piece of data
  810. initially resides (we also call this memory node the home node of a piece of
  811. data).
  812. @end table
  813. @node starpu_data_handle
  814. @subsection @code{starpu_data_handle} -- StarPU opaque data handle
  815. @table @asis
  816. @item @emph{Description}:
  817. StarPU uses @code{starpu_data_handle} as an opaque handle to manage a piece of
  818. data. Once a piece of data has been registered to StarPU, it is associated to a
  819. @code{starpu_data_handle} which keeps track of the state of the piece of data
  820. over the entire machine, so that we can maintain data consistency and locate
  821. data replicates for instance.
  822. @end table
  823. @node void *interface
  824. @subsection @code{void *interface} -- StarPU data interface
  825. @table @asis
  826. @item @emph{Description}:
  827. Data management is done at a high-level in StarPU: rather than accessing a mere
  828. list of contiguous buffers, the tasks may manipulate data that are described by
  829. a high-level construct which we call data interface.
  830. An example of data interface is the "vector" interface which describes a
  831. contiguous data array on a spefic memory node. This interface is a simple
  832. structure containing the number of elements in the array, the size of the
  833. elements, and the address of the array in the appropriate address space (this
  834. address may be invalid if there is no valid copy of the array in the memory
  835. node).
  836. When a piece of data managed by StarPU is used by a task, the task
  837. implementation is given a pointer to an interface describing a valid copy of
  838. the data that is accessible from the current processing unit.
  839. @end table
  840. @node starpu_data_register
  841. @subsection @code{starpu_data_register} -- Register a piece of data to StarPU
  842. @table @asis
  843. @item @emph{Description}:
  844. TODO
  845. @item @emph{Prototype}:
  846. @code{void starpu_data_register(starpu_data_handle *handleptr,
  847. uint32_t home_node,
  848. void *interface,
  849. struct starpu_data_interface_ops_t *ops);}
  850. @end table
  851. @node starpu_data_unregister
  852. @subsection @code{starpu_data_unregister} -- Unregister a piece of data from StarPU
  853. @table @asis
  854. @item @emph{Description}:
  855. @item @emph{Prototype}:
  856. @code{void starpu_data_unregister(starpu_data_handle handle);}
  857. @end table
  858. @c starpu_worker_get_memory_node TODO
  859. @c void *starpu_data_get_interface_on_node(starpu_data_handle handle, unsigned memory_node); TODO
  860. @c user interaction with the DSM
  861. @c void starpu_data_sync_with_mem(struct starpu_data_state_t *state);
  862. @c void starpu_notify_data_modification(struct starpu_data_state_t *state, uint32_t modifying_node);
  863. @c struct starpu_data_interface_ops_t *ops
  864. @node Codelets and Tasks
  865. @section Codelets and Tasks
  866. @menu
  867. * struct starpu_codelet:: StarPU codelet structure
  868. * struct starpu_task:: StarPU task structure
  869. * starpu_task_init:: Initialize a Task
  870. * starpu_task_create:: Allocate and Initialize a Task
  871. * starpu_task_deinit:: Release all the resources used by a Task
  872. * starpu_task_destroy:: Destroy a dynamically allocated Task
  873. * starpu_task_wait:: Wait for the termination of a Task
  874. * starpu_task_submit:: Submit a Task
  875. * starpu_task_wait_for_all:: Wait for the termination of all Tasks
  876. @end menu
  877. @node struct starpu_codelet
  878. @subsection @code{struct starpu_codelet} -- StarPU codelet structure
  879. @table @asis
  880. @item @emph{Description}:
  881. The codelet structure describes a kernel that is possibly implemented on
  882. various targets.
  883. @item @emph{Fields}:
  884. @table @asis
  885. @item @code{where}:
  886. Indicates which types of processing units are able to execute the codelet.
  887. @code{STARPU_CPU|STARPU_CUDA} for instance indicates that the codelet is
  888. implemented for both CPU cores and CUDA devices while @code{STARPU_GORDON}
  889. indicates that it is only available on Cell SPUs.
  890. @item @code{cpu_func} (optional):
  891. Is a function pointer to the CPU implementation of the codelet. Its prototype
  892. must be: @code{void cpu_func(void *buffers[], void *cl_arg)}. The first
  893. argument being the array of data managed by the data management library, and
  894. the second argument is a pointer to the argument passed from the @code{cl_arg}
  895. field of the @code{starpu_task} structure.
  896. The @code{cpu_func} field is ignored if @code{STARPU_CPU} does not appear in
  897. the @code{where} field, it must be non-null otherwise.
  898. @item @code{cuda_func} (optional):
  899. Is a function pointer to the CUDA implementation of the codelet. @emph{This
  900. must be a host-function written in the CUDA runtime API}. Its prototype must
  901. be: @code{void cuda_func(void *buffers[], void *cl_arg);}. The @code{cuda_func}
  902. field is ignored if @code{STARPU_CUDA} does not appear in the @code{where}
  903. field, it must be non-null otherwise.
  904. @item @code{opencl_func} (optional):
  905. Is a function pointer to the OpenCL implementation of the codelet. Its
  906. prototype must be:
  907. @code{void opencl_func(starpu_data_interface_t *descr, void *arg);}.
  908. This pointer is ignored if @code{STARPU_OPENCL} does not appear in the
  909. @code{where} field, it must be non-null otherwise.
  910. @item @code{gordon_func} (optional):
  911. This is the index of the Cell SPU implementation within the Gordon library.
  912. See Gordon documentation for more details on how to register a kernel and
  913. retrieve its index.
  914. @item @code{nbuffers}:
  915. Specifies the number of arguments taken by the codelet. These arguments are
  916. managed by the DSM and are accessed from the @code{void *buffers[]}
  917. array. The constant argument passed with the @code{cl_arg} field of the
  918. @code{starpu_task} structure is not counted in this number. This value should
  919. not be above @code{STARPU_NMAXBUFS}.
  920. @item @code{model} (optional):
  921. This is a pointer to the performance model associated to this codelet. This
  922. optional field is ignored when set to @code{NULL}. TODO
  923. @end table
  924. @end table
  925. @node struct starpu_task
  926. @subsection @code{struct starpu_task} -- StarPU task structure
  927. @table @asis
  928. @item @emph{Description}:
  929. The @code{starpu_task} structure describes a task that can be offloaded on the various
  930. processing units managed by StarPU. It instantiates a codelet. It can either be
  931. allocated dynamically with the @code{starpu_task_create} method, or declared
  932. statically. In the latter case, the programmer has to zero the
  933. @code{starpu_task} structure and to fill the different fields properly. The
  934. indicated default values correspond to the configuration of a task allocated
  935. with @code{starpu_task_create}.
  936. @item @emph{Fields}:
  937. @table @asis
  938. @item @code{cl}:
  939. Is a pointer to the corresponding @code{starpu_codelet} data structure. This
  940. describes where the kernel should be executed, and supplies the appropriate
  941. implementations. When set to @code{NULL}, no code is executed during the tasks,
  942. such empty tasks can be useful for synchronization purposes.
  943. @item @code{buffers}:
  944. TODO
  945. @item @code{cl_arg} (optional) (default = NULL):
  946. This pointer is passed to the codelet through the second argument
  947. of the codelet implementation (e.g. @code{cpu_func} or @code{cuda_func}).
  948. In the specific case of the Cell processor, see the @code{cl_arg_size}
  949. argument.
  950. @item @code{cl_arg_size} (optional, Cell specific):
  951. In the case of the Cell processor, the @code{cl_arg} pointer is not directly
  952. given to the SPU function. A buffer of size @code{cl_arg_size} is allocated on
  953. the SPU. This buffer is then filled with the @code{cl_arg_size} bytes starting
  954. at address @code{cl_arg}. In this case, the argument given to the SPU codelet
  955. is therefore not the @code{cl_arg} pointer, but the address of the buffer in
  956. local store (LS) instead. This field is ignored for CPU, CUDA and OpenCL
  957. codelets.
  958. @item @code{callback_func} (optional) (default = @code{NULL}):
  959. This is a function pointer of prototype @code{void (*f)(void *)} which
  960. specifies a possible callback. If this pointer is non-null, the callback
  961. function is executed @emph{on the host} after the execution of the task. The
  962. callback is passed the value contained in the @code{callback_arg} field. No
  963. callback is executed if the field is set to @code{NULL}.
  964. @item @code{callback_arg} (optional) (default = @code{NULL}):
  965. This is the pointer passed to the callback function. This field is ignored if
  966. the @code{callback_func} is set to @code{NULL}.
  967. @item @code{use_tag} (optional) (default = 0):
  968. If set, this flag indicates that the task should be associated with the tag
  969. contained in the @code{tag_id} field. Tag allow the application to synchronize
  970. with the task and to express task dependencies easily.
  971. @item @code{tag_id}:
  972. This fields contains the tag associated to the task if the @code{use_tag} field
  973. was set, it is ignored otherwise.
  974. @item @code{synchronous}:
  975. If this flag is set, the @code{starpu_task_submit} function is blocking and
  976. returns only when the task has been executed (or if no worker is able to
  977. process the task). Otherwise, @code{starpu_task_submit} returns immediately.
  978. @item @code{priority} (optional) (default = @code{STARPU_DEFAULT_PRIO}):
  979. This field indicates a level of priority for the task. This is an integer value
  980. that must be set between @code{STARPU_MIN_PRIO} (for the least important
  981. tasks) and @code{STARPU_MAX_PRIO} (for the most important tasks) included.
  982. Default priority is @code{STARPU_DEFAULT_PRIO}. Scheduling strategies that
  983. take priorities into account can use this parameter to take better scheduling
  984. decisions, but the scheduling policy may also ignore it.
  985. @item @code{execute_on_a_specific_worker} (default = 0):
  986. If this flag is set, StarPU will bypass the scheduler and directly affect this
  987. task to the worker specified by the @code{workerid} field.
  988. @item @code{workerid} (optional):
  989. If the @code{execute_on_a_specific_worker} field is set, this field indicates
  990. which is the identifier of the worker that should process this task (as
  991. returned by @code{starpu_worker_get_id}). This field is ignored if
  992. @code{execute_on_a_specific_worker} field is set to 0.
  993. @item @code{detach} (optional) (default = 1):
  994. If this flag is set, it is not possible to synchronize with the task
  995. by the means of @code{starpu_task_wait} later on. Internal data structures
  996. are only guaranteed to be freed once @code{starpu_task_wait} is called if the
  997. flag is not set.
  998. @item @code{destroy} (optional) (default = 1):
  999. If this flag is set, the task structure will automatically be freed, either
  1000. after the execution of the callback if the task is detached, or during
  1001. @code{starpu_task_wait} otherwise. If this flag is not set, dynamically
  1002. allocated data structures will not be freed until @code{starpu_task_destroy} is
  1003. called explicitly. Setting this flag for a statically allocated task structure
  1004. will result in undefined behaviour.
  1005. @end table
  1006. @end table
  1007. @node starpu_task_init
  1008. @subsection @code{starpu_task_init} -- Initialize a Task
  1009. @table @asis
  1010. @item @emph{Description}:
  1011. Initialize a task structure with default values. This function is implicitly
  1012. called by @code{starpu_task_create}. By default, tasks initialized with
  1013. @code{starpu_task_init} must be deinitialized explicitly with
  1014. @code{starpu_task_deinit}. Tasks can also be initialized statically, using the
  1015. constant @code{STARPU_TASK_INITIALIZER}.
  1016. @item @emph{Prototype}:
  1017. @code{void starpu_task_init(struct starpu_task *task);}
  1018. @end table
  1019. @node starpu_task_create
  1020. @subsection @code{starpu_task_create} -- Allocate and Initialize a Task
  1021. @table @asis
  1022. @item @emph{Description}:
  1023. Allocate a task structure and initialize it with default values. Tasks
  1024. allocated dynamically with @code{starpu_task_create} are automatically freed when the
  1025. task is terminated. If the destroy flag is explicitly unset, the resources used
  1026. by the task are freed by calling
  1027. @code{starpu_task_destroy}.
  1028. @item @emph{Prototype}:
  1029. @code{struct starpu_task *starpu_task_create(void);}
  1030. @end table
  1031. @node starpu_task_deinit
  1032. @subsection @code{starpu_task_deinit} -- Release all the resources used by a Task
  1033. @table @asis
  1034. @item @emph{Description}:
  1035. Release all the structures automatically allocated to execute the task. This is
  1036. called automatically by @code{starpu_task_destroy}, but the task structure itself is not
  1037. freed. This should be used for statically allocated tasks for instance.
  1038. @item @emph{Prototype}:
  1039. @code{void starpu_task_deinit(struct starpu_task *task);}
  1040. @end table
  1041. @node starpu_task_destroy
  1042. @subsection @code{starpu_task_destroy} -- Destroy a dynamically allocated Task
  1043. @table @asis
  1044. @item @emph{Description}:
  1045. Free the resource allocated during @code{starpu_task_create}. This function can be
  1046. called automatically after the execution of a task by setting the
  1047. @code{destroy} flag of the @code{starpu_task} structure (default behaviour).
  1048. Calling this function on a statically allocated task results in an undefined
  1049. behaviour.
  1050. @item @emph{Prototype}:
  1051. @code{void starpu_task_destroy(struct starpu_task *task);}
  1052. @end table
  1053. @node starpu_task_wait
  1054. @subsection @code{starpu_task_wait} -- Wait for the termination of a Task
  1055. @table @asis
  1056. @item @emph{Description}:
  1057. This function blocks until the task has been executed. It is not possible to
  1058. synchronize with a task more than once. It is not possible to wait for
  1059. synchronous or detached tasks.
  1060. @item @emph{Return value}:
  1061. Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
  1062. indicates that the specified task was either synchronous or detached.
  1063. @item @emph{Prototype}:
  1064. @code{int starpu_task_wait(struct starpu_task *task);}
  1065. @end table
  1066. @node starpu_task_submit
  1067. @subsection @code{starpu_task_submit} -- Submit a Task
  1068. @table @asis
  1069. @item @emph{Description}:
  1070. This function submits a task to StarPU. Calling this function does
  1071. not mean that the task will be executed immediately as there can be data or task
  1072. (tag) dependencies that are not fulfilled yet: StarPU will take care of
  1073. scheduling this task with respect to such dependencies.
  1074. This function returns immediately if the @code{synchronous} field of the
  1075. @code{starpu_task} structure was set to 0, and block until the termination of
  1076. the task otherwise. It is also possible to synchronize the application with
  1077. asynchronous tasks by the means of tags, using the @code{starpu_tag_wait}
  1078. function for instance.
  1079. @item @emph{Return value}:
  1080. In case of success, this function returns 0, a return value of @code{-ENODEV}
  1081. means that there is no worker able to process this task (e.g. there is no GPU
  1082. available and this task is only implemented for CUDA devices).
  1083. @item @emph{Prototype}:
  1084. @code{int starpu_task_submit(struct starpu_task *task);}
  1085. @end table
  1086. @node starpu_task_wait_for_all
  1087. @subsection @code{starpu_task_wait_for_all} -- Wait for the termination of all Tasks
  1088. @table @asis
  1089. @item @emph{Description}:
  1090. This function blocks until all the tasks that were submitted are terminated.
  1091. @item @emph{Prototype}:
  1092. @code{void starpu_task_wait_for_all(void);}
  1093. @end table
  1094. @c Callbacks : what can we put in callbacks ?
  1095. @node Tags
  1096. @section Tags
  1097. @menu
  1098. * starpu_tag_t:: Task identifier
  1099. * starpu_tag_declare_deps:: Declare the Dependencies of a Tag
  1100. * starpu_tag_declare_deps_array:: Declare the Dependencies of a Tag
  1101. * starpu_tag_wait:: Block until a Tag is terminated
  1102. * starpu_tag_wait_array:: Block until a set of Tags is terminated
  1103. * starpu_tag_remove:: Destroy a Tag
  1104. * starpu_tag_notify_from_apps:: Feed a tag explicitly
  1105. @end menu
  1106. @node starpu_tag_t
  1107. @subsection @code{starpu_tag_t} -- Task identifier
  1108. @table @asis
  1109. @item @emph{Description}:
  1110. It is possible to associate a task with a unique ``tag'' and to express
  1111. dependencies between tasks by the means of those tags. To do so, fill the
  1112. @code{tag_id} field of the @code{starpu_task} structure with a tag number (can
  1113. be arbitrary) and set the @code{use_tag} field to 1.
  1114. If @code{starpu_tag_declare_deps} is called with this tag number, the task will
  1115. not be started until the tasks which holds the declared dependency tags are
  1116. completed.
  1117. @end table
  1118. @node starpu_tag_declare_deps
  1119. @subsection @code{starpu_tag_declare_deps} -- Declare the Dependencies of a Tag
  1120. @table @asis
  1121. @item @emph{Description}:
  1122. Specify the dependencies of the task identified by tag @code{id}. The first
  1123. argument specifies the tag which is configured, the second argument gives the
  1124. number of tag(s) on which @code{id} depends. The following arguments are the
  1125. tags which have to be terminated to unlock the task.
  1126. This function must be called before the associated task is submitted to StarPU
  1127. with @code{starpu_task_submit}.
  1128. @item @emph{Remark}
  1129. Because of the variable arity of @code{starpu_tag_declare_deps}, note that the
  1130. last arguments @emph{must} be of type @code{starpu_tag_t}: constant values
  1131. typically need to be explicitly casted. Using the
  1132. @code{starpu_tag_declare_deps_array} function avoids this hazard.
  1133. @item @emph{Prototype}:
  1134. @code{void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);}
  1135. @item @emph{Example}:
  1136. @cartouche
  1137. @example
  1138. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  1139. starpu_tag_declare_deps((starpu_tag_t)0x1,
  1140. 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  1141. @end example
  1142. @end cartouche
  1143. @end table
  1144. @node starpu_tag_declare_deps_array
  1145. @subsection @code{starpu_tag_declare_deps_array} -- Declare the Dependencies of a Tag
  1146. @table @asis
  1147. @item @emph{Description}:
  1148. This function is similar to @code{starpu_tag_declare_deps}, except that its
  1149. does not take a variable number of arguments but an array of tags of size
  1150. @code{ndeps}.
  1151. @item @emph{Prototype}:
  1152. @code{void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);}
  1153. @item @emph{Example}:
  1154. @cartouche
  1155. @example
  1156. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  1157. starpu_tag_t tag_array[2] = @{0x32, 0x52@};
  1158. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  1159. @end example
  1160. @end cartouche
  1161. @end table
  1162. @node starpu_tag_wait
  1163. @subsection @code{starpu_tag_wait} -- Block until a Tag is terminated
  1164. @table @asis
  1165. @item @emph{Description}:
  1166. This function blocks until the task associated to tag @code{id} has been
  1167. executed. This is a blocking call which must therefore not be called within
  1168. tasks or callbacks, but only from the application directly. It is possible to
  1169. synchronize with the same tag multiple times, as long as the
  1170. @code{starpu_tag_remove} function is not called. Note that it is still
  1171. possible to synchronize with a tag associated to a task which @code{starpu_task}
  1172. data structure was freed (e.g. if the @code{destroy} flag of the
  1173. @code{starpu_task} was enabled).
  1174. @item @emph{Prototype}:
  1175. @code{void starpu_tag_wait(starpu_tag_t id);}
  1176. @end table
  1177. @node starpu_tag_wait_array
  1178. @subsection @code{starpu_tag_wait_array} -- Block until a set of Tags is terminated
  1179. @table @asis
  1180. @item @emph{Description}:
  1181. This function is similar to @code{starpu_tag_wait} except that it blocks until
  1182. @emph{all} the @code{ntags} tags contained in the @code{id} array are
  1183. terminated.
  1184. @item @emph{Prototype}:
  1185. @code{void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);}
  1186. @end table
  1187. @node starpu_tag_remove
  1188. @subsection @code{starpu_tag_remove} -- Destroy a Tag
  1189. @table @asis
  1190. @item @emph{Description}:
  1191. This function releases the resources associated to tag @code{id}. It can be
  1192. called once the corresponding task has been executed and when there is
  1193. no other tag that depend on this tag anymore.
  1194. @item @emph{Prototype}:
  1195. @code{void starpu_tag_remove(starpu_tag_t id);}
  1196. @end table
  1197. @node starpu_tag_notify_from_apps
  1198. @subsection @code{starpu_tag_notify_from_apps} -- Feed a Tag explicitly
  1199. @table @asis
  1200. @item @emph{Description}:
  1201. This function explicitly unlocks tag @code{id}. It may be useful in the
  1202. case of applications which execute part of their computation outside StarPU
  1203. tasks (e.g. third-party libraries). It is also provided as a
  1204. convenient tool for the programmer, for instance to entirely construct the task
  1205. DAG before actually giving StarPU the opportunity to execute the tasks.
  1206. @item @emph{Prototype}:
  1207. @code{void starpu_tag_notify_from_apps(starpu_tag_t id);}
  1208. @end table
  1209. @node Profiling API
  1210. @section Profiling API
  1211. @menu
  1212. * starpu_profiling_status_set:: starpu_profiling_status_set
  1213. * starpu_profiling_status_get:: starpu_profiling_status_get
  1214. * struct starpu_task_profiling_info:: task profiling information
  1215. * struct starpu_worker_profiling_info:: worker profiling information
  1216. * starpu_worker_get_profiling_info:: starpu_worker_get_profiling_info
  1217. * struct starpu_bus_profiling_info:: bus profiling information
  1218. @end menu
  1219. @node starpu_profiling_status_set
  1220. @subsection @code{starpu_profiling_status_set} -- Set current profiling status
  1221. @table @asis
  1222. @item @emph{Description}:
  1223. Thie function sets the profiling status. Profiling is activated by passing
  1224. @code{STARPU_PROFILING_ENABLE} in @code{status}. Passing
  1225. @code{STARPU_PROFILING_DISABLE} disables profiling. Calling this function
  1226. resets all profiling measurements. When profiling is enabled, the
  1227. @code{profiling_info} field of the @code{struct starpu_task} structure points
  1228. to a valid @code{struct starpu_task_profiling_info} structure containing
  1229. information about the execution of the task.
  1230. @item @emph{Return value}:
  1231. Negative return values indicate an error, otherwise the previous status is
  1232. returned.
  1233. @item @emph{Prototype}:
  1234. @code{int starpu_profiling_status_set(int status);}
  1235. @end table
  1236. @node starpu_profiling_status_get
  1237. @subsection @code{starpu_profiling_status_get} -- Get current profiling status
  1238. @table @asis
  1239. @item @emph{Description}:
  1240. Return the current profiling status or a negative value in case there was an error.
  1241. @item @emph{Prototype}:
  1242. @code{int starpu_profiling_status_get(void);}
  1243. @end table
  1244. @node struct starpu_task_profiling_info
  1245. @subsection @code{struct starpu_task_profiling_info} -- Task profiling information
  1246. @table @asis
  1247. @item @emph{Description}:
  1248. This structure contains information about the execution of a task. It is
  1249. accessible from the @code{.profiling_info} field of the @code{starpu_task}
  1250. structure if profiling was enabled.
  1251. @item @emph{Fields}:
  1252. @table @asis
  1253. @item @code{submit_time}:
  1254. Date of task submission (relative to the initialization of StarPU).
  1255. @item @code{start_time}:
  1256. Date of task execution beginning (relative to the initialization of StarPU).
  1257. @item @code{end_time}:
  1258. Date of task execution termination (relative to the initialization of StarPU).
  1259. @item @code{workerid}:
  1260. Identifier of the worker which has executed the task.
  1261. @end table
  1262. @end table
  1263. @node struct starpu_worker_profiling_info
  1264. @subsection @code{struct starpu_worker_profiling_info} -- Worker profiling information
  1265. @table @asis
  1266. @item @emph{Description}:
  1267. This structure contains the profiling information associated to a worker.
  1268. @item @emph{Fields}:
  1269. @table @asis
  1270. @item @code{start_time}:
  1271. Starting date for the reported profiling measurements.
  1272. @item @code{total_time}:
  1273. Duration of the profiling measurement interval.
  1274. @item @code{executing_time}:
  1275. Time spent by the worker to execute tasks during the profiling measurement interval.
  1276. @item @code{sleeping_time}:
  1277. Time spent idling by the worker during the profiling measurement interval.
  1278. @item @code{executed_tasks}:
  1279. Number of tasks executed by the worker during the profiling measurement interval.
  1280. @end table
  1281. @end table
  1282. @node starpu_worker_get_profiling_info
  1283. @subsection @code{starpu_worker_get_profiling_info} -- Get worker profiling info
  1284. @table @asis
  1285. @item @emph{Description}:
  1286. Get the profiling info associated to the worker identified by @code{workerid},
  1287. and reset the profiling measurements. If the @code{worker_info} argument is
  1288. NULL, only reset the counters associated to worker @code{workerid}.
  1289. @item @emph{Return value}:
  1290. Upon successful completion, this function returns 0. Otherwise, a negative
  1291. value is returned.
  1292. @item @emph{Prototype}:
  1293. @code{int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profiling_info *worker_info);}
  1294. @end table
  1295. @node struct starpu_bus_profiling_info
  1296. @subsection @code{struct starpu_bus_profiling_info} -- Bus profiling information
  1297. @table @asis
  1298. @item @emph{Description}:
  1299. TODO
  1300. @item @emph{Fields}:
  1301. @table @asis
  1302. @item @code{start_time}:
  1303. TODO
  1304. @item @code{total_time}:
  1305. TODO
  1306. @item @code{transferred_bytes}:
  1307. TODO
  1308. @item @code{transfer_count}:
  1309. TODO
  1310. @end table
  1311. @end table
  1312. @node CUDA extensions
  1313. @section CUDA extensions
  1314. @c void starpu_data_malloc_pinned_if_possible(float **A, size_t dim);
  1315. @menu
  1316. * starpu_cuda_get_local_stream:: Get current worker's CUDA stream
  1317. * starpu_helper_cublas_init:: Initialize CUBLAS on every CUDA device
  1318. * starpu_helper_cublas_shutdown:: Deinitialize CUBLAS on every CUDA device
  1319. @end menu
  1320. @node starpu_cuda_get_local_stream
  1321. @subsection @code{starpu_cuda_get_local_stream} -- Get current worker's CUDA stream
  1322. @table @asis
  1323. @item @emph{Description}:
  1324. StarPU provides a stream for every CUDA device controlled by StarPU. This
  1325. function is only provided for convenience so that programmers can easily use
  1326. asynchronous operations within codelets without having to create a stream by
  1327. hand. Note that the application is not forced to use the stream provided by
  1328. @code{starpu_cuda_get_local_stream} and may also create its own streams.
  1329. @item @emph{Prototype}:
  1330. @code{cudaStream_t *starpu_cuda_get_local_stream(void);}
  1331. @end table
  1332. @node starpu_helper_cublas_init
  1333. @subsection @code{starpu_helper_cublas_init} -- Initialize CUBLAS on every CUDA device
  1334. @table @asis
  1335. @item @emph{Description}:
  1336. The CUBLAS library must be initialized prior to any CUBLAS call. Calling
  1337. @code{starpu_helper_cublas_init} will initialize CUBLAS on every CUDA device
  1338. controlled by StarPU. This call blocks until CUBLAS has been properly
  1339. initialized on every device.
  1340. @item @emph{Prototype}:
  1341. @code{void starpu_helper_cublas_init(void);}
  1342. @end table
  1343. @node starpu_helper_cublas_shutdown
  1344. @subsection @code{starpu_helper_cublas_shutdown} -- Deinitialize CUBLAS on every CUDA device
  1345. @table @asis
  1346. @item @emph{Description}:
  1347. This function synchronously deinitializes the CUBLAS library on every CUDA device.
  1348. @item @emph{Prototype}:
  1349. @code{void starpu_helper_cublas_shutdown(void);}
  1350. @end table
  1351. @node OpenCL extensions
  1352. @section OpenCL extensions
  1353. @menu
  1354. * Enabling OpenCL:: Enabling OpenCL
  1355. * Compiling OpenCL codelets:: Compiling OpenCL codelets
  1356. @end menu
  1357. @node Enabling OpenCL
  1358. @subsection Enabling OpenCL
  1359. On GPU devices which can run both CUDA and OpenCL, CUDA will be
  1360. enabled by default. To enable OpenCL, you need either to disable CUDA
  1361. when configuring StarPU:
  1362. @example
  1363. % ./configure --disable-cuda
  1364. @end example
  1365. or when running applications:
  1366. @example
  1367. % STARPU_NCUDA=0 ./application
  1368. @end example
  1369. OpenCL will automatically be started on any device not yet used by
  1370. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  1371. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  1372. so:
  1373. @example
  1374. % STARPU_NCUDA=2 ./application
  1375. @end example
  1376. @node Compiling OpenCL codelets
  1377. @subsection Compiling OpenCL codelets
  1378. TODO
  1379. @node Cell extensions
  1380. @section Cell extensions
  1381. nothing yet.
  1382. @node Miscellaneous helpers
  1383. @section Miscellaneous helpers
  1384. @menu
  1385. * starpu_execute_on_each_worker:: Execute a function on a subset of workers
  1386. @end menu
  1387. @node starpu_execute_on_each_worker
  1388. @subsection @code{starpu_execute_on_each_worker} -- Execute a function on a subset of workers
  1389. @table @asis
  1390. @item @emph{Description}:
  1391. When calling this method, the offloaded function specified by the first argument is
  1392. executed by every StarPU worker that may execute the function.
  1393. The second argument is passed to the offloaded function.
  1394. The last argument specifies on which types of processing units the function
  1395. should be executed. Similarly to the @code{where} field of the
  1396. @code{starpu_codelet} structure, it is possible to specify that the function
  1397. should be executed on every CUDA device and every CPU by passing
  1398. @code{STARPU_CPU|STARPU_CUDA}.
  1399. This function blocks until the function has been executed on every appropriate
  1400. processing units, so that it may not be called from a callback function for
  1401. instance.
  1402. @item @emph{Prototype}:
  1403. @code{void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);}
  1404. @end table
  1405. @c ---------------------------------------------------------------------
  1406. @c Basic Examples
  1407. @c ---------------------------------------------------------------------
  1408. @node Basic Examples
  1409. @chapter Basic Examples
  1410. @menu
  1411. * Compiling and linking options::
  1412. * Hello World:: Submitting Tasks
  1413. * Scaling a Vector:: Manipulating Data
  1414. * Vector Scaling on an Hybrid CPU/GPU Machine:: Handling Heterogeneous Architectures
  1415. @end menu
  1416. @node Compiling and linking options
  1417. @section Compiling and linking options
  1418. Let's suppose StarPU has been installed in the directory
  1419. @code{$STARPU_DIR}. As explained in @ref{Setting flags for compiling and linking applications},
  1420. the variable @code{PKG_CONFIG_PATH} needs to be set. It is also
  1421. necessary to set the variable @code{LD_LIBRARY_PATH} to locate dynamic
  1422. libraries at runtime.
  1423. @example
  1424. % PKG_CONFIG_PATH=$STARPU_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
  1425. % LD_LIBRARY_PATH=$STARPU_DIR/lib:$LD_LIBRARY_PATH
  1426. @end example
  1427. The Makefile could for instance contain the following lines to define which
  1428. options must be given to the compiler and to the linker:
  1429. @cartouche
  1430. @example
  1431. CFLAGS += $$(pkg-config --cflags libstarpu)
  1432. LDFLAGS += $$(pkg-config --libs libstarpu)
  1433. @end example
  1434. @end cartouche
  1435. @node Hello World
  1436. @section Hello World
  1437. @menu
  1438. * Required Headers::
  1439. * Defining a Codelet::
  1440. * Submitting a Task::
  1441. * Execution of Hello World::
  1442. @end menu
  1443. In this section, we show how to implement a simple program that submits a task to StarPU.
  1444. @node Required Headers
  1445. @subsection Required Headers
  1446. The @code{starpu.h} header should be included in any code using StarPU.
  1447. @cartouche
  1448. @smallexample
  1449. #include <starpu.h>
  1450. @end smallexample
  1451. @end cartouche
  1452. @node Defining a Codelet
  1453. @subsection Defining a Codelet
  1454. @cartouche
  1455. @smallexample
  1456. void cpu_func(void *buffers[], void *cl_arg)
  1457. @{
  1458. float *array = cl_arg;
  1459. printf("Hello world (array = @{%f, %f@} )\n", array[0], array[1]);
  1460. @}
  1461. starpu_codelet cl =
  1462. @{
  1463. .where = STARPU_CPU,
  1464. .cpu_func = cpu_func,
  1465. .nbuffers = 0
  1466. @};
  1467. @end smallexample
  1468. @end cartouche
  1469. A codelet is a structure that represents a computational kernel. Such a codelet
  1470. may contain an implementation of the same kernel on different architectures
  1471. (e.g. CUDA, Cell's SPU, x86, ...).
  1472. The @code{nbuffers} field specifies the number of data buffers that are
  1473. manipulated by the codelet: here the codelet does not access or modify any data
  1474. that is controlled by our data management library. Note that the argument
  1475. passed to the codelet (the @code{cl_arg} field of the @code{starpu_task}
  1476. structure) does not count as a buffer since it is not managed by our data
  1477. management library.
  1478. @c TODO need a crossref to the proper description of "where" see bla for more ...
  1479. We create a codelet which may only be executed on the CPUs. The @code{where}
  1480. field is a bitmask that defines where the codelet may be executed. Here, the
  1481. @code{STARPU_CPU} value means that only CPUs can execute this codelet
  1482. (@pxref{Codelets and Tasks} for more details on this field).
  1483. When a CPU core executes a codelet, it calls the @code{cpu_func} function,
  1484. which @emph{must} have the following prototype:
  1485. @code{void (*cpu_func)(void *buffers[], void *cl_arg);}
  1486. In this example, we can ignore the first argument of this function which gives a
  1487. description of the input and output buffers (e.g. the size and the location of
  1488. the matrices). The second argument is a pointer to a buffer passed as an
  1489. argument to the codelet by the means of the @code{cl_arg} field of the
  1490. @code{starpu_task} structure.
  1491. @c TODO rewrite so that it is a little clearer ?
  1492. Be aware that this may be a pointer to a
  1493. @emph{copy} of the actual buffer, and not the pointer given by the programmer:
  1494. if the codelet modifies this buffer, there is no guarantee that the initial
  1495. buffer will be modified as well: this for instance implies that the buffer
  1496. cannot be used as a synchronization medium.
  1497. @node Submitting a Task
  1498. @subsection Submitting a Task
  1499. @cartouche
  1500. @smallexample
  1501. void callback_func(void *callback_arg)
  1502. @{
  1503. printf("Callback function (arg %x)\n", callback_arg);
  1504. @}
  1505. int main(int argc, char **argv)
  1506. @{
  1507. /* @b{initialize StarPU} */
  1508. starpu_init(NULL);
  1509. struct starpu_task *task = starpu_task_create();
  1510. task->cl = &cl; /* @b{Pointer to the codelet defined above} */
  1511. float array[2] = @{1.0f, -1.0f@};
  1512. task->cl_arg = &array;
  1513. task->cl_arg_size = sizeof(array);
  1514. task->callback_func = callback_func;
  1515. task->callback_arg = 0x42;
  1516. /* @b{starpu_task_submit will be a blocking call} */
  1517. task->synchronous = 1;
  1518. /* @b{submit the task to StarPU} */
  1519. starpu_task_submit(task);
  1520. /* @b{terminate StarPU} */
  1521. starpu_shutdown();
  1522. return 0;
  1523. @}
  1524. @end smallexample
  1525. @end cartouche
  1526. Before submitting any tasks to StarPU, @code{starpu_init} must be called. The
  1527. @code{NULL} argument specifies that we use default configuration. Tasks cannot
  1528. be submitted after the termination of StarPU by a call to
  1529. @code{starpu_shutdown}.
  1530. In the example above, a task structure is allocated by a call to
  1531. @code{starpu_task_create}. This function only allocates and fills the
  1532. corresponding structure with the default settings (@pxref{starpu_task_create}),
  1533. but it does not submit the task to StarPU.
  1534. @c not really clear ;)
  1535. The @code{cl} field is a pointer to the codelet which the task will
  1536. execute: in other words, the codelet structure describes which computational
  1537. kernel should be offloaded on the different architectures, and the task
  1538. structure is a wrapper containing a codelet and the piece of data on which the
  1539. codelet should operate.
  1540. The optional @code{cl_arg} field is a pointer to a buffer (of size
  1541. @code{cl_arg_size}) with some parameters for the kernel
  1542. described by the codelet. For instance, if a codelet implements a computational
  1543. kernel that multiplies its input vector by a constant, the constant could be
  1544. specified by the means of this buffer.
  1545. Once a task has been executed, an optional callback function can be called.
  1546. While the computational kernel could be offloaded on various architectures, the
  1547. callback function is always executed on a CPU. The @code{callback_arg}
  1548. pointer is passed as an argument of the callback. The prototype of a callback
  1549. function must be:
  1550. @code{void (*callback_function)(void *);}
  1551. If the @code{synchronous} field is non-null, task submission will be
  1552. synchronous: the @code{starpu_task_submit} function will not return until the
  1553. task was executed. Note that the @code{starpu_shutdown} method does not
  1554. guarantee that asynchronous tasks have been executed before it returns.
  1555. @node Execution of Hello World
  1556. @subsection Execution of Hello World
  1557. @smallexample
  1558. % make helloWorld
  1559. cc $(pkg-config --cflags libstarpu) $(pkg-config --libs libstarpu) helloWorld.c -o helloWorld
  1560. % ./helloWorld
  1561. Hello world (array = @{1.000000, -1.000000@} )
  1562. Callback function (arg 42)
  1563. @end smallexample
  1564. @node Scaling a Vector
  1565. @section Manipulating Data: Scaling a Vector
  1566. The previous example has shown how to submit tasks. In this section,
  1567. we show how StarPU tasks can manipulate data. The full source code for
  1568. this example is given in @ref{Full source code for the 'Scaling a Vector' example}.
  1569. @menu
  1570. * Source code of Vector Scaling::
  1571. * Execution of Vector Scaling::
  1572. @end menu
  1573. @node Source code of Vector Scaling
  1574. @subsection Source code of Vector Scaling
  1575. Programmers can describe the data layout of their application so that StarPU is
  1576. responsible for enforcing data coherency and availability across the machine.
  1577. Instead of handling complex (and non-portable) mechanisms to perform data
  1578. movements, programmers only declare which piece of data is accessed and/or
  1579. modified by a task, and StarPU makes sure that when a computational kernel
  1580. starts somewhere (e.g. on a GPU), its data are available locally.
  1581. Before submitting those tasks, the programmer first needs to declare the
  1582. different pieces of data to StarPU using the @code{starpu_*_data_register}
  1583. functions. To ease the development of applications for StarPU, it is possible
  1584. to describe multiple types of data layout. A type of data layout is called an
  1585. @b{interface}. By default, there are different interfaces available in StarPU:
  1586. here we will consider the @b{vector interface}.
  1587. The following lines show how to declare an array of @code{NX} elements of type
  1588. @code{float} using the vector interface:
  1589. @cartouche
  1590. @smallexample
  1591. float vector[NX];
  1592. starpu_data_handle vector_handle;
  1593. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector, NX,
  1594. sizeof(float));
  1595. @end smallexample
  1596. @end cartouche
  1597. The first argument, called the @b{data handle}, is an opaque pointer which
  1598. designates the array in StarPU. This is also the structure which is used to
  1599. describe which data is used by a task. The second argument is the node number
  1600. where the data currently resides. Here it is 0 since the @code{vector} array is in
  1601. the main memory. Then comes the pointer @code{vector} where the data can be found,
  1602. the number of elements in the vector and the size of each element.
  1603. It is possible to construct a StarPU task that will manipulate the
  1604. vector and a constant factor.
  1605. @cartouche
  1606. @smallexample
  1607. float factor = 3.14;
  1608. struct starpu_task *task = starpu_task_create();
  1609. task->cl = &cl; /* @b{Pointer to the codelet defined below} */
  1610. task->buffers[0].handle = vector_handle; /* @b{First parameter of the codelet} */
  1611. task->buffers[0].mode = STARPU_RW;
  1612. task->cl_arg = &factor;
  1613. task->cl_arg_size = sizeof(factor);
  1614. task->synchronous = 1;
  1615. starpu_task_submit(task);
  1616. @end smallexample
  1617. @end cartouche
  1618. Since the factor is constant, it does not need a preliminary declaration, and
  1619. can just be passed through the @code{cl_arg} pointer like in the previous
  1620. example. The vector parameter is described by its handle.
  1621. There are two fields in each element of the @code{buffers} array.
  1622. @code{handle} is the handle of the data, and @code{mode} specifies how the
  1623. kernel will access the data (@code{STARPU_R} for read-only, @code{STARPU_W} for
  1624. write-only and @code{STARPU_RW} for read and write access).
  1625. The definition of the codelet can be written as follows:
  1626. @cartouche
  1627. @smallexample
  1628. void scal_cpu_func(void *buffers[], void *cl_arg)
  1629. @{
  1630. unsigned i;
  1631. float *factor = cl_arg;
  1632. struct starpu_vector_interface_s *vector = buffers[0];
  1633. /* length of the vector */
  1634. unsigned n = STARPU_GET_VECTOR_NX(vector);
  1635. /* local copy of the vector pointer */
  1636. float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
  1637. for (i = 0; i < n; i++)
  1638. val[i] *= *factor;
  1639. @}
  1640. starpu_codelet cl = @{
  1641. .where = STARPU_CPU,
  1642. .cpu_func = scal_cpu_func,
  1643. .nbuffers = 1
  1644. @};
  1645. @end smallexample
  1646. @end cartouche
  1647. The second argument of the @code{scal_cpu_func} function contains a pointer to the
  1648. parameters of the codelet (given in @code{task->cl_arg}), so that we read the
  1649. constant factor from this pointer. The first argument is an array that gives
  1650. a description of all the buffers passed in the @code{task->buffers}@ array. The
  1651. size of this array is given by the @code{nbuffers} field of the codelet
  1652. structure. For the sake of generality, this array contains pointers to the
  1653. different interfaces describing each buffer. In the case of the @b{vector
  1654. interface}, the location of the vector (resp. its length) is accessible in the
  1655. @code{ptr} (resp. @code{nx}) of this array. Since the vector is accessed in a
  1656. read-write fashion, any modification will automatically affect future accesses
  1657. to this vector made by other tasks.
  1658. @node Execution of Vector Scaling
  1659. @subsection Execution of Vector Scaling
  1660. @smallexample
  1661. % make vector
  1662. cc $(pkg-config --cflags libstarpu) $(pkg-config --libs libstarpu) vector.c -o vector
  1663. % ./vector
  1664. 0.000000 3.000000 6.000000 9.000000 12.000000
  1665. @end smallexample
  1666. @node Vector Scaling on an Hybrid CPU/GPU Machine
  1667. @section Vector Scaling on an Hybrid CPU/GPU Machine
  1668. Contrary to the previous examples, the task submitted in this example may not
  1669. only be executed by the CPUs, but also by a CUDA device.
  1670. @menu
  1671. * Definition of the CUDA Codelet::
  1672. * Definition of the OpenCL Codelet::
  1673. * Definition of the Main Code::
  1674. * Compilation and execution of Hybrid Vector Scaling::
  1675. @end menu
  1676. @node Definition of the CUDA Codelet
  1677. @subsection Definition of the CUDA Codelet
  1678. The CUDA implementation can be written as follows. It needs to be
  1679. compiled with a CUDA compiler such as nvcc, the NVIDIA CUDA compiler
  1680. driver.
  1681. @cartouche
  1682. @smallexample
  1683. #include <starpu.h>
  1684. static __global__ void vector_mult_cuda(float *val, unsigned n,
  1685. float factor)
  1686. @{
  1687. unsigned i;
  1688. for(i = 0 ; i < n ; i++)
  1689. val[i] *= factor;
  1690. @}
  1691. extern "C" void scal_cuda_func(void *buffers[], void *_args)
  1692. @{
  1693. float *factor = (float *)_args;
  1694. struct starpu_vector_interface_s *vector = (struct starpu_vector_interface_s *) buffers[0];
  1695. /* length of the vector */
  1696. unsigned n = STARPU_GET_VECTOR_NX(vector);
  1697. /* local copy of the vector pointer */
  1698. float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
  1699. @i{ vector_mult_cuda<<<1,1>>>(val, n, *factor);}
  1700. @i{ cudaThreadSynchronize();}
  1701. @}
  1702. @end smallexample
  1703. @end cartouche
  1704. @node Definition of the OpenCL Codelet
  1705. @subsection Definition of the OpenCL Codelet
  1706. The OpenCL implementation can be written as follows. StarPU provides
  1707. tools to compile a OpenCL codelet stored in a file.
  1708. @cartouche
  1709. @smallexample
  1710. __kernel void vector_mult_opencl(__global float* val, int nx, float factor)
  1711. @{
  1712. const int i = get_global_id(0);
  1713. if (i < nx) @{
  1714. val[i] *= factor;
  1715. @}
  1716. @}
  1717. @end smallexample
  1718. @end cartouche
  1719. @cartouche
  1720. @smallexample
  1721. #include <starpu.h>
  1722. @i{#include <starpu_opencl.h>}
  1723. @i{extern struct starpu_opencl_codelet codelet;}
  1724. void scal_opencl_func(void *buffers[], void *_args)
  1725. @{
  1726. float *factor = (float *)_args;
  1727. struct starpu_vector_interface_s *vector = (struct starpu_vector_interface_s *) buffers[0];
  1728. @i{ int id, devid, err;}
  1729. @i{ cl_kernel kernel;}
  1730. @i{ cl_command_queue queue;}
  1731. /* length of the vector */
  1732. unsigned n = STARPU_GET_VECTOR_NX(vector);
  1733. /* local copy of the vector pointer */
  1734. float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
  1735. @i{ id = starpu_worker_get_id();}
  1736. @i{ devid = starpu_worker_get_devid(id);}
  1737. @i{ err = starpu_opencl_load_kernel(&kernel, &queue, &codelet,}
  1738. @i{ "vector_mult_opencl", devid); /* @b{Name of the codelet defined above} */}
  1739. @i{ if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);}
  1740. @i{ err = 0;}
  1741. @i{ err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &val);}
  1742. @i{ err = clSetKernelArg(kernel, 1, sizeof(int), &n);}
  1743. @i{ err |= clSetKernelArg(kernel, 2, sizeof(float), (void*)factor);}
  1744. @i{ if (err) STARPU_OPENCL_REPORT_ERROR(err);}
  1745. @i{ @{}
  1746. @i{ size_t global=1;}
  1747. @i{ size_t local=1;}
  1748. @i{ err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, &local, 0, NULL, NULL);}
  1749. @i{ if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);}
  1750. @i{ @}}
  1751. @i{ clFinish(queue);}
  1752. @i{ starpu_opencl_release_kernel(kernel);}
  1753. @}
  1754. @end smallexample
  1755. @end cartouche
  1756. @node Definition of the Main Code
  1757. @subsection Definition of the Main Code
  1758. The CPU implementation is the same as in the previous section.
  1759. Here is the source of the main application. You can notice the value of the
  1760. field @code{where} for the codelet. We specify
  1761. @code{STARPU_CPU|STARPU_CUDA|STARPU_OPENCL} to indicate to StarPU that the codelet
  1762. can be executed either on a CPU or on a CUDA or an OpenCL device.
  1763. @cartouche
  1764. @smallexample
  1765. #include <starpu.h>
  1766. #define NX 2048
  1767. extern void scal_cuda_func(void *buffers[], void *_args);
  1768. extern void scal_cpu_func(void *buffers[], void *_args);
  1769. /* @b{Definition of the codelet} */
  1770. static starpu_codelet cl = @{
  1771. .where = STARPU_CPU|STARPU_CUDA; /* @b{It can be executed on a CPU} */
  1772. /* @b{or on a CUDA device} */
  1773. .cuda_func = scal_cuda_func;
  1774. .cpu_func = scal_cpu_func;
  1775. .nbuffers = 1;
  1776. @}
  1777. int main(int argc, char **argv)
  1778. @{
  1779. float *vector;
  1780. int i, ret;
  1781. float factor=3.0;
  1782. struct starpu_task *task;
  1783. starpu_data_handle vector_handle;
  1784. starpu_init(NULL); /* @b{Initialising StarPU} */
  1785. vector = (float*)malloc(NX*sizeof(float));
  1786. assert(vector);
  1787. for(i=0 ; i<NX ; i++) vector[i] = i;
  1788. @end smallexample
  1789. @end cartouche
  1790. @cartouche
  1791. @smallexample
  1792. /* @b{Registering data within StarPU} */
  1793. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector,
  1794. NX, sizeof(float));
  1795. /* @b{Definition of the task} */
  1796. task = starpu_task_create();
  1797. task->cl = &cl;
  1798. task->buffers[0].handle = vector_handle;
  1799. task->buffers[0].mode = STARPU_RW;
  1800. task->cl_arg = &factor;
  1801. task->cl_arg_size = sizeof(factor);
  1802. @end smallexample
  1803. @end cartouche
  1804. @cartouche
  1805. @smallexample
  1806. /* @b{Submitting the task} */
  1807. ret = starpu_task_submit(task);
  1808. if (ret == -ENODEV) @{
  1809. fprintf(stderr, "No worker may execute this task\n");
  1810. return 1;
  1811. @}
  1812. /* @b{Waiting for its termination} */
  1813. starpu_task_wait_for_all();
  1814. /* @b{Update the vector in RAM} */
  1815. starpu_data_sync_with_mem(vector_handle, STARPU_R);
  1816. @end smallexample
  1817. @end cartouche
  1818. @cartouche
  1819. @smallexample
  1820. /* @b{Access the data} */
  1821. for(i=0 ; i<NX; i++) @{
  1822. fprintf(stderr, "%f ", vector[i]);
  1823. @}
  1824. fprintf(stderr, "\n");
  1825. /* @b{Release the data and shutdown StarPU} */
  1826. starpu_data_release_from_mem(vector_handle);
  1827. starpu_shutdown();
  1828. return 0;
  1829. @}
  1830. @end smallexample
  1831. @end cartouche
  1832. @node Compilation and execution of Hybrid Vector Scaling
  1833. @subsection Compilation and execution of Hybrid Vector Scaling
  1834. The Makefile given at the beginning of the section must be extended to
  1835. give the rules to compile the CUDA source code.
  1836. @cartouche
  1837. @smallexample
  1838. CFLAGS += $(shell pkg-config --cflags libstarpu)
  1839. LDFLAGS += $(shell pkg-config --libs libstarpu)
  1840. CC = gcc
  1841. vector: vector.o vector_cpu.o vector_cuda.o
  1842. %.o: %.cu
  1843. nvcc $(CFLAGS) $< -c $@
  1844. clean:
  1845. rm -f vector *.o
  1846. @end smallexample
  1847. @end cartouche
  1848. @smallexample
  1849. % make
  1850. @end smallexample
  1851. and to execute it, with the default configuration:
  1852. @smallexample
  1853. % ./vector
  1854. 0.000000 3.000000 6.000000 9.000000 12.000000
  1855. @end smallexample
  1856. or for example, by disabling CPU devices:
  1857. @smallexample
  1858. % STARPU_NCPUS=0 ./vector
  1859. 0.000000 3.000000 6.000000 9.000000 12.000000
  1860. @end smallexample
  1861. or by disabling CUDA devices:
  1862. @smallexample
  1863. % STARPU_NCUDA=0 ./vector
  1864. 0.000000 3.000000 6.000000 9.000000 12.000000
  1865. @end smallexample
  1866. @c TODO: Add performance model example (and update basic_examples)
  1867. @c ---------------------------------------------------------------------
  1868. @c Advanced Topics
  1869. @c ---------------------------------------------------------------------
  1870. @node Advanced Topics
  1871. @chapter Advanced Topics
  1872. @menu
  1873. * Defining a new data interface::
  1874. * Defining a new scheduling policy::
  1875. @end menu
  1876. @node Defining a new data interface
  1877. @section Defining a new data interface
  1878. @menu
  1879. * struct starpu_data_interface_ops_t:: Per-interface methods
  1880. * struct starpu_data_copy_methods:: Per-interface data transfer methods
  1881. * An example of data interface:: An example of data interface
  1882. @end menu
  1883. @node struct starpu_data_interface_ops_t
  1884. @subsection @code{struct starpu_data_interface_ops_t} -- Per-interface methods
  1885. @table @asis
  1886. @item @emph{Description}:
  1887. TODO describe all the different fields
  1888. @end table
  1889. @node struct starpu_data_copy_methods
  1890. @subsection @code{struct starpu_data_copy_methods} -- Per-interface data transfer methods
  1891. @table @asis
  1892. @item @emph{Description}:
  1893. TODO describe all the different fields
  1894. @end table
  1895. @node An example of data interface
  1896. @subsection An example of data interface
  1897. @table @asis
  1898. TODO
  1899. @end table
  1900. @node Defining a new scheduling policy
  1901. @section Defining a new scheduling policy
  1902. TODO
  1903. @c ---------------------------------------------------------------------
  1904. @c Appendices
  1905. @c ---------------------------------------------------------------------
  1906. @c ---------------------------------------------------------------------
  1907. @c Full source code for the 'Scaling a Vector' example
  1908. @c ---------------------------------------------------------------------
  1909. @node Full source code for the 'Scaling a Vector' example
  1910. @appendix Full source code for the 'Scaling a Vector' example
  1911. @menu
  1912. * Main application::
  1913. * CPU Codelet::
  1914. * CUDA Codelet::
  1915. * OpenCL Codelet::
  1916. @end menu
  1917. @node Main application
  1918. @section Main application
  1919. @smallexample
  1920. @include vector_scal_c.texi
  1921. @end smallexample
  1922. @node CPU Codelet
  1923. @section CPU Codelet
  1924. @smallexample
  1925. @include vector_scal_cpu.texi
  1926. @end smallexample
  1927. @node CUDA Codelet
  1928. @section CUDA Codelet
  1929. @smallexample
  1930. @include vector_scal_cuda.texi
  1931. @end smallexample
  1932. @node OpenCL Codelet
  1933. @section OpenCL Codelet
  1934. @menu
  1935. * Invoking the kernel::
  1936. * Source of the kernel::
  1937. @end menu
  1938. @node Invoking the kernel
  1939. @subsection Invoking the kernel
  1940. @smallexample
  1941. @include vector_scal_opencl.texi
  1942. @end smallexample
  1943. @node Source of the kernel
  1944. @subsection Source of the kernel
  1945. @smallexample
  1946. @include vector_scal_opencl_codelet.texi
  1947. @end smallexample
  1948. @bye