starpu.texi 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841
  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. * Configuration options:: Configurations options
  29. * Environment variables:: Environment variables used by StarPU
  30. * StarPU API:: The API to use StarPU
  31. * Basic Examples:: Basic examples of the use of StarPU
  32. * Advanced Topics:: Advanced use of StarPU
  33. @end menu
  34. @c ---------------------------------------------------------------------
  35. @c Introduction to StarPU
  36. @c ---------------------------------------------------------------------
  37. @node Introduction
  38. @chapter Introduction to StarPU
  39. @menu
  40. * Motivation:: Why StarPU ?
  41. * StarPU in a Nutshell:: The Fundamentals of StarPU
  42. @end menu
  43. @node Motivation
  44. @section Motivation
  45. @c complex machines with heterogeneous cores/devices
  46. The use of specialized hardware such as accelerators or coprocessors offers an
  47. interesting approach to overcome the physical limits encountered by processor
  48. architects. As a result, many machines are now equipped with one or several
  49. accelerators (e.g. a GPU), in addition to the usual processor(s). While a lot of
  50. efforts have been devoted to offload computation onto such accelerators, very
  51. little attention as been paid to portability concerns on the one hand, and to the
  52. possibility of having heterogeneous accelerators and processors to interact on the other hand.
  53. StarPU is a runtime system that offers support for heterogeneous multicore
  54. architectures, it not only offers a unified view of the computational resources
  55. (i.e. CPUs and accelerators at the same time), but it also takes care of
  56. efficiently mapping and executing tasks onto an heterogeneous machine while
  57. transparently handling low-level issues in a portable fashion.
  58. @c this leads to a complicated distributed memory design
  59. @c which is not (easily) manageable by hand
  60. @c added value/benefits of StarPU
  61. @c - portability
  62. @c - scheduling, perf. portability
  63. @node StarPU in a Nutshell
  64. @section StarPU in a Nutshell
  65. From a programming point of view, StarPU is not a new language but a library
  66. that executes tasks explicitly submitted by the application. The data that a
  67. task manipulates are automatically transferred onto the accelerator so that the
  68. programmer does not have to take care of complex data movements. StarPU also
  69. takes particular care of scheduling those tasks efficiently and allows
  70. scheduling experts to implement custom scheduling policies in a portable
  71. fashion.
  72. @c explain the notion of codelet and task (i.e. g(A, B)
  73. @subsection Codelet and Tasks
  74. One of StarPU primary data structure is the @b{codelet}. A codelet describes a
  75. computational kernel that can possibly be implemented on multiple architectures
  76. such as a CPU, a CUDA device or a Cell's SPU.
  77. @c TODO insert illustration f : f_spu, f_cpu, ...
  78. Another important data structure is the @b{task}. Executing a StarPU task
  79. consists in applying a codelet on a data set, on one of the architectures on
  80. which the codelet is implemented. In addition to the codelet that a task
  81. implements, it also describes which data are accessed, and how they are
  82. accessed during the computation (read and/or write).
  83. StarPU tasks are asynchronous: submitting a task to StarPU is a non-blocking
  84. operation. The task structure can also specify a @b{callback} function that is
  85. called once StarPU has properly executed the task. It also contains optional
  86. fields that the application may use to give hints to the scheduler (such as
  87. priority levels).
  88. A task may be identified by a unique 64-bit number which we refer as a @b{tag}.
  89. Task dependencies can be enforced either by the means of callback functions, or
  90. by expressing dependencies between tags.
  91. @c TODO insert illustration f(Ar, Brw, Cr) + ..
  92. @c DSM
  93. @subsection StarPU Data Management Library
  94. Because StarPU schedules tasks at runtime, data transfers have to be
  95. done automatically and ``just-in-time'' between processing units,
  96. relieving the application programmer from explicit data transfers.
  97. Moreover, to avoid unnecessary transfers, StarPU keeps data
  98. where it was last needed, even if was modified there, and it
  99. allows multiple copies of the same data to reside at the same time on
  100. several processing units as long as it is not modified.
  101. @c ---------------------------------------------------------------------
  102. @c Installing StarPU
  103. @c ---------------------------------------------------------------------
  104. @node Installing StarPU
  105. @chapter Installing StarPU
  106. @menu
  107. * Configuration of StarPU::
  108. * Building and Installing StarPU::
  109. @end menu
  110. StarPU can be built and installed by the standard means of the GNU
  111. autotools. The following chapter is intended to briefly remind how these tools
  112. can be used to install StarPU.
  113. @node Configuration of StarPU
  114. @section Configuration of StarPU
  115. @menu
  116. * Generating Makefiles and configuration scripts::
  117. * Configuring StarPU::
  118. @end menu
  119. @node Generating Makefiles and configuration scripts
  120. @subsection Generating Makefiles and configuration scripts
  121. This step is not necessary when using the tarball releases of StarPU. If you
  122. are using the source code from the svn repository, you first need to generate
  123. the configure scripts and the Makefiles.
  124. @example
  125. $ autoreconf -vfi
  126. @end example
  127. @node Configuring StarPU
  128. @subsection Configuring StarPU
  129. @example
  130. $ ./configure
  131. @end example
  132. Details about options that are useful to give to @code{./configure} are given in
  133. @ref{Configuration options}.
  134. @node Building and Installing StarPU
  135. @section Building and Installing StarPU
  136. @menu
  137. * Building::
  138. * Sanity Checks::
  139. * Installing::
  140. * pkg-config configuration::
  141. @end menu
  142. @node Building
  143. @subsection Building
  144. @example
  145. $ make
  146. @end example
  147. @node Sanity Checks
  148. @subsection Sanity Checks
  149. In order to make sure that StarPU is working properly on the system, it is also
  150. possible to run a test suite.
  151. @example
  152. $ make check
  153. @end example
  154. @node Installing
  155. @subsection Installing
  156. In order to install StarPU at the location that was specified during
  157. configuration:
  158. @example
  159. $ make install
  160. @end example
  161. @node pkg-config configuration
  162. @subsection pkg-config configuration
  163. It is possible that compiling and linking an application against StarPU
  164. requires to use specific flags or libraries (for instance @code{CUDA} or
  165. @code{libspe2}). To this end, it is possible to use the @code{pkg-config} tool.
  166. If StarPU was not installed at some standard location, the path of StarPU's
  167. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  168. that @code{pkg-config} can find it. For example if StarPU was installed in
  169. @code{$prefix_dir}:
  170. @example
  171. $ PKG_CONFIG_PATH = $PKG_CONFIG_PATH:$prefix_dir/lib/pkgconfig
  172. @end example
  173. The flags required to compile or link against StarPU are then
  174. accessible with the following commands:
  175. @example
  176. $ pkg-config --cflags libstarpu # options for the compiler
  177. $ pkg-config --libs libstarpu # options for the linker
  178. @end example
  179. @c ---------------------------------------------------------------------
  180. @c Configuration options
  181. @c ---------------------------------------------------------------------
  182. @node Configuration options
  183. @chapter Configuration options
  184. @table @asis
  185. @item @code{--disable-cpu}
  186. Disable the use of CPUs of the machine. Only GPUs etc. will be used.
  187. @item @code{--enable-maxcudadev=<number>}
  188. Defines the maximum number of CUDA devices that StarPU will support, then
  189. available as the STARPU_MAXCUDADEVS macro.
  190. @item @code{--disable-cuda}
  191. Disable the use of CUDA, even if the SDK is detected.
  192. @item @code{--enable-maxopencldev=<number>}
  193. Defines the maximum number of OpenCL devices that StarPU will support, then
  194. available as the STARPU_MAXOPENCLDEVS macro.
  195. @item @code{--disable-opencl}
  196. Disable the use of OpenCL, even if the SDK is detected.
  197. @item @code{--enable-gordon}
  198. Enable the use of the Gordon runtime for Cell SPUs.
  199. @c TODO: rather default to enabled when detected
  200. @item @code{--enable-debug}
  201. Enable debugging messages.
  202. @item @code{--enable-fast}
  203. Do not enforce assertions, saves a lot of time spent to compute them otherwise.
  204. @item @code{--enable-verbose}
  205. Augment the verbosity of the debugging messages.
  206. @item @code{--enable-coverage}
  207. Enable flags for the coverage tool.
  208. @item @code{--enable-perf-debug}
  209. Enable performance debugging.
  210. @item @code{--enable-model-debug}
  211. Enable performance model debugging.
  212. @item @code{--enable-stats}
  213. Enable statistics.
  214. @item @code{--enable-maxbuffers=<nbuffers>}
  215. Define the maximum number of buffers that tasks will be able to take as parameters, then available as the STARPU_NMAXBUFS macro.
  216. @item @code{--disable-priority}
  217. Disable taking priorities into account in scheduling decisions. Mostly for
  218. comparison purposes.
  219. @item @code{--enable-allocation-cache}
  220. Enable the use of a data allocation cache to avoid the cost of it with
  221. CUDA. Still experimental.
  222. @item @code{--enable-opengl-render}
  223. Enable the use of OpenGL for the rendering of some examples.
  224. @c TODO: rather default to enabled when detected
  225. @item @code{--enable-blas-lib=<name>}
  226. Specify the blas library to be used by some of the examples. The
  227. library has to be 'atlas' or 'goto'.
  228. @item @code{--with-cuda-dir=<path>}
  229. Specify the location of the CUDA SDK resides. This directory should notably contain
  230. @code{include/cuda.h}.
  231. @item @code{--with-magma=<path>}
  232. Specify where magma is installed.
  233. @item @code{--with-opencl-dir=<path>}
  234. Specify the location of the OpenCL SDK. This directory should notably contain
  235. @code{include/CL/cl.h}.
  236. @item @code{--with-gordon-dir=<path>}
  237. Specify the location of the Gordon SDK.
  238. @item @code{--with-fxt=<path>}
  239. Specify the location of FxT (for generating traces and rendering them
  240. using ViTE). This directory should notably contain
  241. @code{include/fxt/fxt.h}.
  242. @item @code{--with-perf-model-dir=<dir>}
  243. Specify where performance models should be stored (instead of defaulting to the
  244. current user's home).
  245. @item @code{--with-mpicc=<path to mpicc>}
  246. Specify the location of the @code{mpicc} compiler to be used for starpumpi.
  247. @c TODO: also just use AC_PROG
  248. @item @code{--with-mpi}
  249. Enable building libstarpumpi.
  250. @c TODO: rather just use the availability of mpicc instead of a second option
  251. @item @code{--with-goto-dir=<dir>}
  252. Specify the location of GotoBLAS.
  253. @item @code{--with-atlas-dir=<dir>}
  254. Specify the location of ATLAS. This directory should notably contain
  255. @code{include/cblas.h}.
  256. @end table
  257. @c ---------------------------------------------------------------------
  258. @c Environment variables
  259. @c ---------------------------------------------------------------------
  260. @node Environment variables
  261. @chapter Environment variables
  262. @menu
  263. * Workers:: Configuring workers
  264. * Scheduling:: Configuring the Scheduling engine
  265. * Misc:: Miscellaneous and debug
  266. @end menu
  267. Note: the values given in @code{starpu_conf} structure passed when
  268. calling @code{starpu_init} will override the values of the environment
  269. variables.
  270. @node Workers
  271. @section Configuring workers
  272. @menu
  273. * STARPU_NCPUS :: Number of CPU workers
  274. * STARPU_NCUDA :: Number of CUDA workers
  275. * STARPU_NOPENCL :: Number of OpenCL workers
  276. * STARPU_NGORDON :: Number of SPU workers (Cell)
  277. * STARPU_WORKERS_CPUID :: Bind workers to specific CPUs
  278. * STARPU_WORKERS_CUDAID :: Select specific CUDA devices
  279. * STARPU_WORKERS_OPENCLID :: Select specific OpenCL devices
  280. @end menu
  281. @node STARPU_NCPUS
  282. @subsection @code{STARPU_NCPUS} -- Number of CPU workers
  283. @table @asis
  284. @item @emph{Description}:
  285. Specify the maximum number of CPU workers. Note that StarPU will not allocate
  286. more CPUs than there are physical CPUs, and that some CPUs are used to control
  287. the accelerators.
  288. @end table
  289. @node STARPU_NCUDA
  290. @subsection @code{STARPU_NCUDA} -- Number of CUDA workers
  291. @table @asis
  292. @item @emph{Description}:
  293. Specify the maximum number of CUDA devices that StarPU can use. If
  294. @code{STARPU_NCUDA} is lower than the number of physical devices, it is
  295. possible to select which CUDA devices should be used by the means of the
  296. @code{STARPU_WORKERS_CUDAID} environment variable.
  297. @end table
  298. @node STARPU_NOPENCL
  299. @subsection @code{STARPU_NOPENCL} -- Number of OpenCL workers
  300. @table @asis
  301. @item @emph{Description}:
  302. OpenCL equivalent of the @code{STARPU_NCUDA} environment variable.
  303. @end table
  304. @node STARPU_NGORDON
  305. @subsection @code{STARPU_NGORDON} -- Number of SPU workers (Cell)
  306. @table @asis
  307. @item @emph{Description}:
  308. Specify the maximum number of SPUs that StarPU can use.
  309. @end table
  310. @node STARPU_WORKERS_CPUID
  311. @subsection @code{STARPU_WORKERS_CPUID} -- Bind workers to specific CPUs
  312. @table @asis
  313. @item @emph{Description}:
  314. Passing an array of integers (starting from 0) in @code{STARPU_WORKERS_CPUID}
  315. specifies on which logical CPU the different workers should be
  316. bound. For instance, if @code{STARPU_WORKERS_CPUID = "1 3 0 2"}, the first
  317. worker will be bound to logical CPU #1, the second CPU worker will be bound to
  318. logical CPU #3 and so on. Note that the logical ordering of the CPUs is either
  319. determined by the OS, or provided by the @code{hwloc} library in case it is
  320. available.
  321. Note that the first workers correspond to the CUDA workers, then come the
  322. OpenCL and the SPU, and finally the CPU workers. For example if
  323. we have @code{STARPU_NCUDA=1}, @code{STARPU_NOPENCL=1}, @code{STARPU_NCPUS=2}
  324. and @code{STARPU_WORKERS_CPUID = "0 2 1 3"}, the CUDA device will be controlled
  325. by logical CPU #0, the OpenCL device will be controlled by logical CPU #2, and
  326. the logical CPUs #1 and #3 will be used by the CPU workers.
  327. If the number of workers is larger than the array given in
  328. @code{STARPU_WORKERS_CPUID}, the workers are bound to the logical CPUs in a
  329. round-robin fashion: if @code{STARPU_WORKERS_CPUID = "0 1"}, the first and the
  330. third (resp. second and fourth) workers will be put on CPU #0 (resp. CPU #1).
  331. @end table
  332. @node STARPU_WORKERS_CUDAID
  333. @subsection @code{STARPU_WORKERS_CUDAID} -- Select specific CUDA devices
  334. @table @asis
  335. @item @emph{Description}:
  336. Similarly to the @code{STARPU_WORKERS_CPUID} environment variable, it is
  337. possible to select which CUDA devices should be used by StarPU. On a machine
  338. equipped with 4 GPUs, setting @code{STARPU_WORKERS_CUDAID = "1 3"} and
  339. @code{STARPU_NCUDA=2} specifies that 2 CUDA workers should be created, and that
  340. they should use CUDA devices #1 and #3 (the logical ordering of the devices is
  341. the one reported by CUDA).
  342. @end table
  343. @node STARPU_WORKERS_OPENCLID
  344. @subsection @code{STARPU_WORKERS_OPENCLID} -- Select specific OpenCL devices
  345. @table @asis
  346. @item @emph{Description}:
  347. OpenCL equivalent of the @code{STARPU_WORKERS_CUDAID} environment variable.
  348. @end table
  349. @node Scheduling
  350. @section Configuring the Scheduling engine
  351. @menu
  352. * STARPU_SCHED :: Scheduling policy
  353. * STARPU_CALIBRATE :: Calibrate performance models
  354. * STARPU_PREFETCH :: Use data prefetch
  355. * STARPU_SCHED_ALPHA :: Computation factor
  356. * STARPU_SCHED_BETA :: Communication factor
  357. @end menu
  358. @node STARPU_SCHED
  359. @subsection @code{STARPU_SCHED} -- Scheduling policy
  360. @table @asis
  361. @item @emph{Description}:
  362. This chooses between the different scheduling policies proposed by StarPU: work
  363. random, stealing, greedy, with performance models, etc.
  364. Use @code{STARPU_SCHED=help} to get the list of available schedulers.
  365. @end table
  366. @node STARPU_CALIBRATE
  367. @subsection @code{STARPU_CALIBRATE} -- Calibrate performance models
  368. @table @asis
  369. @item @emph{Description}:
  370. If this variable is set to 1, the performance models are calibrated during
  371. the execution. If it is set to 2, the previous values are dropped to restart
  372. calibration from scratch.
  373. Note: this currently only applies to dm and dmda scheduling policies.
  374. @end table
  375. @node STARPU_PREFETCH
  376. @subsection @code{STARPU_PREFETCH} -- Use data prefetch
  377. @table @asis
  378. @item @emph{Description}:
  379. If this variable is set, data prefetching will be enabled, that is when a task is
  380. scheduled to be executed e.g. on a GPU, StarPU will request an asynchronous
  381. transfer in advance, so that data is already present on the GPU when the task
  382. starts. As a result, computation and data transfers are overlapped.
  383. @end table
  384. @node STARPU_SCHED_ALPHA
  385. @subsection @code{STARPU_SCHED_ALPHA} -- Computation factor
  386. @table @asis
  387. @item @emph{Description}:
  388. To estimate the cost of a task StarPU takes into account the estimated
  389. computation time (obtained thanks to performance models). The alpha factor is
  390. the coefficient to be applied to it before adding it to the communication part.
  391. @end table
  392. @node STARPU_SCHED_BETA
  393. @subsection @code{STARPU_SCHED_BETA} -- Communication factor
  394. @table @asis
  395. @item @emph{Description}:
  396. To estimate the cost of a task StarPU takes into account the estimated
  397. data transfer time (obtained thanks to performance models). The beta factor is
  398. the coefficient to be applied to it before adding it to the computation part.
  399. @end table
  400. @node Misc
  401. @section Miscellaneous and debug
  402. @menu
  403. * STARPU_LOGFILENAME :: Select debug file name
  404. @end menu
  405. @node STARPU_LOGFILENAME
  406. @subsection @code{STARPU_LOGFILENAME} -- Select debug file name
  407. @table @asis
  408. @item @emph{Description}:
  409. This variable specify in which file the debugging output should be saved to.
  410. @end table
  411. @c ---------------------------------------------------------------------
  412. @c StarPU API
  413. @c ---------------------------------------------------------------------
  414. @node StarPU API
  415. @chapter StarPU API
  416. @menu
  417. * Initialization and Termination:: Initialization and Termination methods
  418. * Workers' Properties:: Methods to enumerate workers' properties
  419. * Data Library:: Methods to manipulate data
  420. * Codelets and Tasks:: Methods to construct tasks
  421. * Tags:: Task dependencies
  422. * CUDA extensions:: CUDA extensions
  423. * OpenCL extensions:: OpenCL extensions
  424. * Cell extensions:: Cell extensions
  425. * Miscellaneous:: Miscellaneous helpers
  426. @end menu
  427. @node Initialization and Termination
  428. @section Initialization and Termination
  429. @menu
  430. * starpu_init:: Initialize StarPU
  431. * struct starpu_conf:: StarPU runtime configuration
  432. * starpu_shutdown:: Terminate StarPU
  433. @end menu
  434. @node starpu_init
  435. @subsection @code{starpu_init} -- Initialize StarPU
  436. @table @asis
  437. @item @emph{Description}:
  438. This is StarPU initialization method, which must be called prior to any other
  439. StarPU call. It is possible to specify StarPU's configuration (e.g. scheduling
  440. policy, number of cores, ...) by passing a non-null argument. Default
  441. configuration is used if the passed argument is @code{NULL}.
  442. @item @emph{Return value}:
  443. Upon successful completion, this function returns 0. Otherwise, @code{-ENODEV}
  444. indicates that no worker was available (so that StarPU was not initialized).
  445. @item @emph{Prototype}:
  446. @code{int starpu_init(struct starpu_conf *conf);}
  447. @end table
  448. @node struct starpu_conf
  449. @subsection @code{struct starpu_conf} -- StarPU runtime configuration
  450. @table @asis
  451. @item @emph{Description}:
  452. This structure is passed to the @code{starpu_init} function in order
  453. to configure StarPU.
  454. When the default value is used, StarPU automatically selects the number
  455. of processing units and takes the default scheduling policy. This parameter
  456. overwrites the equivalent environment variables.
  457. @item @emph{Fields}:
  458. @table @asis
  459. @item @code{sched_policy} (default = NULL):
  460. This is the name of the scheduling policy. This can also be specified with the
  461. @code{STARPU_SCHED} environment variable.
  462. @item @code{ncpus} (default = -1):
  463. This is the maximum number of CPU cores that StarPU can use. This can also be
  464. specified with the @code{STARPU_NCPUS} environment variable.
  465. @item @code{ncuda} (default = -1):
  466. This is the maximum number of CUDA devices that StarPU can use. This can also be
  467. specified with the @code{STARPU_NCUDA} environment variable.
  468. @item @code{nopencl} (default = -1):
  469. This is the maximum number of OpenCL devices that StarPU can use. This can also be
  470. specified with the @code{STARPU_NOPENCL} environment variable.
  471. @item @code{nspus} (default = -1):
  472. This is the maximum number of Cell SPUs that StarPU can use. This can also be
  473. specified with the @code{STARPU_NGORDON} environment variable.
  474. @item @code{calibrate} (default = 0):
  475. If this flag is set, StarPU will calibrate the performance models when
  476. executing tasks. This can also be specified with the @code{STARPU_CALIBRATE}
  477. environment variable.
  478. @end table
  479. @end table
  480. @node starpu_shutdown
  481. @subsection @code{starpu_shutdown} -- Terminate StarPU
  482. @table @asis
  483. @item @emph{Description}:
  484. This is StarPU termination method. It must be called at the end of the
  485. application: statistics and other post-mortem debugging information are not
  486. guaranteed to be available until this method has been called.
  487. @item @emph{Prototype}:
  488. @code{void starpu_shutdown(void);}
  489. @end table
  490. @node Workers' Properties
  491. @section Workers' Properties
  492. @menu
  493. * starpu_worker_get_count:: Get the number of processing units
  494. * starpu_cpu_worker_get_count:: Get the number of CPU controlled by StarPU
  495. * starpu_cuda_worker_get_count:: Get the number of CUDA devices controlled by StarPU
  496. * starpu_opencl_worker_get_count:: Get the number of OpenCL devices controlled by StarPU
  497. * starpu_spu_worker_get_count:: Get the number of Cell SPUs controlled by StarPU
  498. * starpu_worker_get_id:: Get the identifier of the current worker
  499. * starpu_worker_get_type:: Get the type of processing unit associated to a worker
  500. * starpu_worker_get_name:: Get the name of a worker
  501. @end menu
  502. @node starpu_worker_get_count
  503. @subsection @code{starpu_worker_get_count} -- Get the number of processing units
  504. @table @asis
  505. @item @emph{Description}:
  506. This function returns the number of workers (i.e. processing units executing
  507. StarPU tasks). The returned value should be at most @code{STARPU_NMAXWORKERS}.
  508. @item @emph{Prototype}:
  509. @code{unsigned starpu_worker_get_count(void);}
  510. @end table
  511. @node starpu_cpu_worker_get_count
  512. @subsection @code{starpu_cpu_worker_get_count} -- Get the number of CPU controlled by StarPU
  513. @table @asis
  514. @item @emph{Description}:
  515. This function returns the number of CPUs controlled by StarPU. The returned
  516. value should be at most @code{STARPU_NMAXCPUS}.
  517. @item @emph{Prototype}:
  518. @code{unsigned starpu_cpu_worker_get_count(void);}
  519. @end table
  520. @node starpu_cuda_worker_get_count
  521. @subsection @code{starpu_cuda_worker_get_count} -- Get the number of CUDA devices controlled by StarPU
  522. @table @asis
  523. @item @emph{Description}:
  524. This function returns the number of CUDA devices controlled by StarPU. The returned
  525. value should be at most @code{STARPU_MAXCUDADEVS}.
  526. @item @emph{Prototype}:
  527. @code{unsigned starpu_cuda_worker_get_count(void);}
  528. @end table
  529. @node starpu_opencl_worker_get_count
  530. @subsection @code{starpu_opencl_worker_get_count} -- Get the number of OpenCL devices controlled by StarPU
  531. @table @asis
  532. @item @emph{Description}:
  533. This function returns the number of OpenCL devices controlled by StarPU. The returned
  534. value should be at most @code{STARPU_MAXOPENCLDEVS}.
  535. @item @emph{Prototype}:
  536. @code{unsigned starpu_opencl_worker_get_count(void);}
  537. @end table
  538. @node starpu_spu_worker_get_count
  539. @subsection @code{starpu_spu_worker_get_count} -- Get the number of Cell SPUs controlled by StarPU
  540. @table @asis
  541. @item @emph{Description}:
  542. This function returns the number of Cell SPUs controlled by StarPU.
  543. @item @emph{Prototype}:
  544. @code{unsigned starpu_opencl_worker_get_count(void);}
  545. @end table
  546. @node starpu_worker_get_id
  547. @subsection @code{starpu_worker_get_id} -- Get the identifier of the current worker
  548. @table @asis
  549. @item @emph{Description}:
  550. This function returns the identifier of the worker associated to the calling
  551. thread. The returned value is either -1 if the current context is not a StarPU
  552. worker (i.e. when called from the application outside a task or a callback), or
  553. an integer between 0 and @code{starpu_worker_get_count() - 1}.
  554. @item @emph{Prototype}:
  555. @code{int starpu_worker_get_id(void);}
  556. @end table
  557. @node starpu_worker_get_type
  558. @subsection @code{starpu_worker_get_type} -- Get the type of processing unit associated to a worker
  559. @table @asis
  560. @item @emph{Description}:
  561. This function returns the type of worker associated to an identifier (as
  562. returned by the @code{starpu_worker_get_id} function). The returned value
  563. indicates the architecture of the worker: @code{STARPU_CPU_WORKER} for a CPU
  564. core, @code{STARPU_CUDA_WORKER} for a CUDA device,
  565. @code{STARPU_OPENCL_WORKER} for a OpenCL device, and
  566. @code{STARPU_GORDON_WORKER} for a Cell SPU. The value returned for an invalid
  567. identifier is unspecified.
  568. @item @emph{Prototype}:
  569. @code{enum starpu_archtype starpu_worker_get_type(int id);}
  570. @end table
  571. @node starpu_worker_get_name
  572. @subsection @code{starpu_worker_get_name} -- Get the name of a worker
  573. @table @asis
  574. @item @emph{Description}:
  575. StarPU associates a unique human readable string to each processing unit. This
  576. function copies at most the @code{maxlen} first bytes of the unique string
  577. associated to a worker identified by its identifier @code{id} into the
  578. @code{dst} buffer. The caller is responsible for ensuring that the @code{dst}
  579. is a valid pointer to a buffer of @code{maxlen} bytes at least. Calling this
  580. function on an invalid identifier results in an unspecified behaviour.
  581. @item @emph{Prototype}:
  582. @code{void starpu_worker_get_name(int id, char *dst, size_t maxlen);}
  583. @end table
  584. @node Data Library
  585. @section Data Library
  586. This section describes the data management facilities provided by StarPU.
  587. TODO: We show how to use existing data interfaces in [ref], but developers can
  588. design their own data interfaces if required.
  589. @menu
  590. * starpu_data_handle:: StarPU opaque data handle
  591. * void *interface:: StarPU data interface
  592. @end menu
  593. @node starpu_data_handle
  594. @subsection @code{starpu_data_handle} -- StarPU opaque data handle
  595. @table @asis
  596. @item @emph{Description}:
  597. StarPU uses @code{starpu_data_handle} as an opaque handle to manage a piece of
  598. data. Once a piece of data has been registered to StarPU, it is associated to a
  599. @code{starpu_data_handle} which keeps track of the state of the piece of data
  600. over the entire machine, so that we can maintain data consistency and locate
  601. data replicates for instance.
  602. @end table
  603. @node void *interface
  604. @subsection @code{void *interface} -- StarPU data interface
  605. @table @asis
  606. @item @emph{Description}:
  607. Data management is done at a high-level in StarPU: rather than accessing a mere
  608. list of contiguous buffers, the tasks may manipulate data that are described by
  609. a high-level construct which we call data interface.
  610. TODO
  611. @end table
  612. @c void starpu_data_unregister(struct starpu_data_state_t *state);
  613. @c starpu_worker_get_memory_node TODO
  614. @c
  615. @c user interaction with the DSM
  616. @c void starpu_data_sync_with_mem(struct starpu_data_state_t *state);
  617. @c void starpu_notify_data_modification(struct starpu_data_state_t *state, uint32_t modifying_node);
  618. @node Codelets and Tasks
  619. @section Codelets and Tasks
  620. @menu
  621. * struct starpu_codelet:: StarPU codelet structure
  622. * struct starpu_task:: StarPU task structure
  623. * starpu_task_init:: Initialize a Task
  624. * starpu_task_create:: Allocate and Initialize a Task
  625. * starpu_task_deinit:: Release all the resources used by a Task
  626. * starpu_task_destroy:: Destroy a dynamically allocated Task
  627. * starpu_task_submit:: Submit a Task
  628. * starpu_task_wait:: Wait for the termination of a Task
  629. * starpu_task_wait_for_all:: Wait for the termination of all Tasks
  630. @end menu
  631. @node struct starpu_codelet
  632. @subsection @code{struct starpu_codelet} -- StarPU codelet structure
  633. @table @asis
  634. @item @emph{Description}:
  635. The codelet structure describes a kernel that is possibly implemented on
  636. various targets.
  637. @item @emph{Fields}:
  638. @table @asis
  639. @item @code{where}:
  640. Indicates which types of processing units are able to execute the codelet.
  641. @code{STARPU_CPU|STARPU_CUDA} for instance indicates that the codelet is
  642. implemented for both CPU cores and CUDA devices while @code{STARPU_GORDON}
  643. indicates that it is only available on Cell SPUs.
  644. @item @code{cpu_func} (optional):
  645. Is a function pointer to the CPU implementation of the codelet. Its prototype
  646. must be: @code{void cpu_func(void *buffers[], void *cl_arg)}. The first
  647. argument being the array of data managed by the data management library, and
  648. the second argument is a pointer to the argument passed from the @code{cl_arg}
  649. field of the @code{starpu_task} structure.
  650. The @code{cpu_func} field is ignored if @code{STARPU_CPU} does not appear in
  651. the @code{where} field, it must be non-null otherwise.
  652. @item @code{cuda_func} (optional):
  653. Is a function pointer to the CUDA implementation of the codelet. @emph{This
  654. must be a host-function written in the CUDA runtime API}. Its prototype must
  655. be: @code{void cuda_func(void *buffers[], void *cl_arg);}. The @code{cuda_func}
  656. field is ignored if @code{STARPU_CUDA} does not appear in the @code{where}
  657. field, it must be non-null otherwise.
  658. @item @code{opencl_func} (optional):
  659. Is a function pointer to the OpenCL implementation of the codelet. Its
  660. prototype must be:
  661. @code{void opencl_func(starpu_data_interface_t *descr, void *arg);}.
  662. This pointer is ignored if @code{OPENCL} does not appear in the
  663. @code{where} field, it must be non-null otherwise.
  664. @item @code{gordon_func} (optional):
  665. This is the index of the Cell SPU implementation within the Gordon library.
  666. TODO
  667. @item @code{nbuffers}:
  668. Specifies the number of arguments taken by the codelet. These arguments are
  669. managed by the DSM and are accessed from the @code{void *buffers[]}
  670. array. The constant argument passed with the @code{cl_arg} field of the
  671. @code{starpu_task} structure is not counted in this number. This value should
  672. not be above @code{STARPU_NMAXBUFS}.
  673. @item @code{model} (optional):
  674. This is a pointer to the performance model associated to this codelet. This
  675. optional field is ignored when null. TODO
  676. @end table
  677. @end table
  678. @node struct starpu_task
  679. @subsection @code{struct starpu_task} -- StarPU task structure
  680. @table @asis
  681. @item @emph{Description}:
  682. The @code{starpu_task} structure describes a task that can be offloaded on the various
  683. processing units managed by StarPU. It instantiates a codelet. It can either be
  684. allocated dynamically with the @code{starpu_task_create} method, or declared
  685. statically. In the latter case, the programmer has to zero the
  686. @code{starpu_task} structure and to fill the different fields properly. The
  687. indicated default values correspond to the configuration of a task allocated
  688. with @code{starpu_task_create}.
  689. @item @emph{Fields}:
  690. @table @asis
  691. @item @code{cl}:
  692. Is a pointer to the corresponding @code{starpu_codelet} data structure. This
  693. describes where the kernel should be executed, and supplies the appropriate
  694. implementations. When set to @code{NULL}, no code is executed during the tasks,
  695. such empty tasks can be useful for synchronization purposes.
  696. @item @code{buffers}:
  697. TODO
  698. @item @code{cl_arg} (optional) (default = NULL):
  699. This pointer is passed to the codelet through the second argument
  700. of the codelet implementation (e.g. @code{cpu_func} or @code{cuda_func}).
  701. In the specific case of the Cell processor, see the @code{cl_arg_size}
  702. argument.
  703. @item @code{cl_arg_size} (optional, Cell specific):
  704. In the case of the Cell processor, the @code{cl_arg} pointer is not directly
  705. given to the SPU function. A buffer of size @code{cl_arg_size} is allocated on
  706. the SPU. This buffer is then filled with the @code{cl_arg_size} bytes starting
  707. at address @code{cl_arg}. In this case, the argument given to the SPU codelet
  708. is therefore not the @code{cl_arg} pointer, but the address of the buffer in
  709. local store (LS) instead. This field is ignored for CPU, CUDA and OpenCL
  710. codelets.
  711. @item @code{callback_func} (optional) (default = @code{NULL}):
  712. This is a function pointer of prototype @code{void (*f)(void *)} which
  713. specifies a possible callback. If this pointer is non-null, the callback
  714. function is executed @emph{on the host} after the execution of the task. The
  715. callback is passed the value contained in the @code{callback_arg} field. No
  716. callback is executed if the field is null.
  717. @item @code{callback_arg} (optional) (default = @code{NULL}):
  718. This is the pointer passed to the callback function. This field is ignored if
  719. the @code{callback_func} is null.
  720. @item @code{use_tag} (optional) (default = 0):
  721. If set, this flag indicates that the task should be associated with the tag
  722. contained in the @code{tag_id} field. Tag allow the application to synchronize
  723. with the task and to express task dependencies easily.
  724. @item @code{tag_id}:
  725. This fields contains the tag associated to the task if the @code{use_tag} field
  726. was set, it is ignored otherwise.
  727. @item @code{synchronous}:
  728. If this flag is set, the @code{starpu_task_submit} function is blocking and
  729. returns only when the task has been executed (or if no worker is able to
  730. process the task). Otherwise, @code{starpu_task_submit} returns immediately.
  731. @item @code{priority} (optional) (default = @code{STARPU_DEFAULT_PRIO}):
  732. This field indicates a level of priority for the task. This is an integer value
  733. that must be set between @code{STARPU_MIN_PRIO} (for the least important
  734. tasks) and @code{STARPU_MAX_PRIO} (for the most important tasks) included.
  735. Default priority is @code{STARPU_DEFAULT_PRIO}. Scheduling strategies that
  736. take priorities into account can use this parameter to take better scheduling
  737. decisions, but the scheduling policy may also ignore it.
  738. @item @code{execute_on_a_specific_worker} (default = 0):
  739. If this flag is set, StarPU will bypass the scheduler and directly affect this
  740. task to the worker specified by the @code{workerid} field.
  741. @item @code{workerid} (optional):
  742. If the @code{execute_on_a_specific_worker} field is set, this field indicates
  743. which is the identifier of the worker that should process this task (as
  744. returned by @code{starpu_worker_get_id}). This field is ignored if
  745. @code{execute_on_a_specific_worker} field is set to 0.
  746. @item @code{detach} (optional) (default = 1):
  747. If this flag is set, it is not possible to synchronize with the task
  748. by the means of @code{starpu_task_wait} later on. Internal data structures
  749. are only guaranteed to be freed once @code{starpu_task_wait} is called if the
  750. flag is not set.
  751. @item @code{destroy} (optional) (default = 1):
  752. If this flag is set, the task structure will automatically be freed, either
  753. after the execution of the callback if the task is detached, or during
  754. @code{starpu_task_wait} otherwise. If this flag is not set, dynamically
  755. allocated data structures will not be freed until @code{starpu_task_destroy} is
  756. called explicitly. Setting this flag for a statically allocated task structure
  757. will result in undefined behaviour.
  758. @end table
  759. @end table
  760. @node starpu_task_init
  761. @subsection @code{starpu_task_init} -- Initialize a Task
  762. @table @asis
  763. @item @emph{Description}:
  764. Initialize a task structure with default values. This function is implicitly
  765. called by @code{starpu_task_create}. By default, tasks initialized with
  766. @code{starpu_task_init} must be deinitialized explicitly with
  767. @code{starpu_task_deinit}. Tasks can also be initialized statically, using the
  768. constant @code{STARPU_TASK_INITIALIZER}.
  769. @item @emph{Prototype}:
  770. @code{void starpu_task_init(struct starpu_task *task);}
  771. @end table
  772. @node starpu_task_create
  773. @subsection @code{starpu_task_create} -- Allocate and Initialize a Task
  774. @table @asis
  775. @item @emph{Description}:
  776. Allocate a task structure and initialize it with default values. Tasks
  777. allocated dynamically with @code{starpu_task_create} are automatically freed when the
  778. task is terminated. If the destroy flag is explicitly unset, the resources used
  779. by the task are freed by calling
  780. @code{starpu_task_destroy}.
  781. @item @emph{Prototype}:
  782. @code{struct starpu_task *starpu_task_create(void);}
  783. @end table
  784. @node starpu_task_deinit
  785. @subsection @code{starpu_task_deinit} -- Release all the resources used by a Task
  786. @table @asis
  787. @item @emph{Description}:
  788. Release all the structures automatically allocated to execute the task. This is
  789. called automatically by @code{starpu_task_destroy}, but the task structure itself is not
  790. freed. This should be used for statically allocated tasks for instance.
  791. @item @emph{Prototype}:
  792. @code{void starpu_task_deinit(struct starpu_task *task);}
  793. @end table
  794. @node starpu_task_destroy
  795. @subsection @code{starpu_task_destroy} -- Destroy a dynamically allocated Task
  796. @table @asis
  797. @item @emph{Description}:
  798. Free the resource allocated during @code{starpu_task_create}. This function can be
  799. called automatically after the execution of a task by setting the
  800. @code{destroy} flag of the @code{starpu_task} structure (default behaviour).
  801. Calling this function on a statically allocated task results in an undefined
  802. behaviour.
  803. @item @emph{Prototype}:
  804. @code{void starpu_task_destroy(struct starpu_task *task);}
  805. @end table
  806. @node starpu_task_wait
  807. @subsection @code{starpu_task_wait} -- Wait for the termination of a Task
  808. @table @asis
  809. @item @emph{Description}:
  810. This function blocks until the task has been executed. It is not possible to
  811. synchronize with a task more than once. It is not possible to wait for
  812. synchronous or detached tasks.
  813. @item @emph{Return value}:
  814. Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
  815. indicates that the specified task was either synchronous or detached.
  816. @item @emph{Prototype}:
  817. @code{int starpu_task_wait(struct starpu_task *task);}
  818. @end table
  819. @node starpu_task_submit
  820. @subsection @code{starpu_task_submit} -- Submit a Task
  821. @table @asis
  822. @item @emph{Description}:
  823. This function submits a task to StarPU. Calling this function does
  824. not mean that the task will be executed immediately as there can be data or task
  825. (tag) dependencies that are not fulfilled yet: StarPU will take care of
  826. scheduling this task with respect to such dependencies.
  827. This function returns immediately if the @code{synchronous} field of the
  828. @code{starpu_task} structure was set to 0, and block until the termination of
  829. the task otherwise. It is also possible to synchronize the application with
  830. asynchronous tasks by the means of tags, using the @code{starpu_tag_wait}
  831. function for instance.
  832. @item @emph{Return value}:
  833. In case of success, this function returns 0, a return value of @code{-ENODEV}
  834. means that there is no worker able to process this task (e.g. there is no GPU
  835. available and this task is only implemented for CUDA devices).
  836. @item @emph{Prototype}:
  837. @code{int starpu_task_submit(struct starpu_task *task);}
  838. @end table
  839. @node starpu_task_wait_for_all
  840. @subsection @code{starpu_task_wait_for_all} -- Wait for the termination of all Tasks
  841. @table @asis
  842. @item @emph{Description}:
  843. This function blocks until all the tasks that were submitted are terminated.
  844. @item @emph{Prototype}:
  845. @code{void starpu_task_wait_for_all(void);}
  846. @end table
  847. @c Callbacks : what can we put in callbacks ?
  848. @node Tags
  849. @section Tags
  850. @menu
  851. * starpu_tag_t:: Task identifier
  852. * starpu_tag_declare_deps:: Declare the Dependencies of a Tag
  853. * starpu_tag_declare_deps_array:: Declare the Dependencies of a Tag
  854. * starpu_tag_wait:: Block until a Tag is terminated
  855. * starpu_tag_wait_array:: Block until a set of Tags is terminated
  856. * starpu_tag_remove:: Destroy a Tag
  857. * starpu_tag_notify_from_apps:: Feed a tag explicitly
  858. @end menu
  859. @node starpu_tag_t
  860. @subsection @code{starpu_tag_t} -- Task identifier
  861. @table @asis
  862. @item @emph{Description}:
  863. It is possible to associate a task with a unique ``tag'' and to express
  864. dependencies between tasks by the means of those tags. To do so, fill the
  865. @code{tag_id} field of the @code{starpu_task} structure with a tag number (can
  866. be arbitrary) and set the @code{use_tag} field to 1.
  867. If @code{starpu_tag_declare_deps} is called with this tag number, the task will
  868. not be started until the tasks which holds the declared dependency tags are
  869. completed.
  870. @end table
  871. @node starpu_tag_declare_deps
  872. @subsection @code{starpu_tag_declare_deps} -- Declare the Dependencies of a Tag
  873. @table @asis
  874. @item @emph{Description}:
  875. Specify the dependencies of the task identified by tag @code{id}. The first
  876. argument specifies the tag which is configured, the second argument gives the
  877. number of tag(s) on which @code{id} depends. The following arguments are the
  878. tags which have to be terminated to unlock the task.
  879. This function must be called before the associated task is submitted to StarPU
  880. with @code{starpu_task_submit}.
  881. @item @emph{Remark}
  882. Because of the variable arity of @code{starpu_tag_declare_deps}, note that the
  883. last arguments @emph{must} be of type @code{starpu_tag_t}: constant values
  884. typically need to be explicitly casted. Using the
  885. @code{starpu_tag_declare_deps_array} function avoids this hazard.
  886. @item @emph{Prototype}:
  887. @code{void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);}
  888. @item @emph{Example}:
  889. @cartouche
  890. @example
  891. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  892. starpu_tag_declare_deps((starpu_tag_t)0x1,
  893. 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  894. @end example
  895. @end cartouche
  896. @end table
  897. @node starpu_tag_declare_deps_array
  898. @subsection @code{starpu_tag_declare_deps_array} -- Declare the Dependencies of a Tag
  899. @table @asis
  900. @item @emph{Description}:
  901. This function is similar to @code{starpu_tag_declare_deps}, except that its
  902. does not take a variable number of arguments but an array of tags of size
  903. @code{ndeps}.
  904. @item @emph{Prototype}:
  905. @code{void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);}
  906. @item @emph{Example}:
  907. @cartouche
  908. @example
  909. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  910. starpu_tag_t tag_array[2] = @{0x32, 0x52@};
  911. starpu_tag_declare_deps_array((starpu_tag_t)0x1, 2, tag_array);
  912. @end example
  913. @end cartouche
  914. @end table
  915. @node starpu_tag_wait
  916. @subsection @code{starpu_tag_wait} -- Block until a Tag is terminated
  917. @table @asis
  918. @item @emph{Description}:
  919. This function blocks until the task associated to tag @code{id} has been
  920. executed. This is a blocking call which must therefore not be called within
  921. tasks or callbacks, but only from the application directly. It is possible to
  922. synchronize with the same tag multiple times, as long as the
  923. @code{starpu_tag_remove} function is not called. Note that it is still
  924. possible to synchronize with a tag associated to a task which @code{starpu_task}
  925. data structure was freed (e.g. if the @code{destroy} flag of the
  926. @code{starpu_task} was enabled).
  927. @item @emph{Prototype}:
  928. @code{void starpu_tag_wait(starpu_tag_t id);}
  929. @end table
  930. @node starpu_tag_wait_array
  931. @subsection @code{starpu_tag_wait_array} -- Block until a set of Tags is terminated
  932. @table @asis
  933. @item @emph{Description}:
  934. This function is similar to @code{starpu_tag_wait} except that it blocks until
  935. @emph{all} the @code{ntags} tags contained in the @code{id} array are
  936. terminated.
  937. @item @emph{Prototype}:
  938. @code{void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);}
  939. @end table
  940. @node starpu_tag_remove
  941. @subsection @code{starpu_tag_remove} -- Destroy a Tag
  942. @table @asis
  943. @item @emph{Description}:
  944. This function releases the resources associated to tag @code{id}. It can be
  945. called once the corresponding task has been executed and when there is
  946. no other tag that depend on this tag anymore.
  947. @item @emph{Prototype}:
  948. @code{void starpu_tag_remove(starpu_tag_t id);}
  949. @end table
  950. @node starpu_tag_notify_from_apps
  951. @subsection @code{starpu_tag_notify_from_apps} -- Feed a Tag explicitly
  952. @table @asis
  953. @item @emph{Description}:
  954. This function explicitly unlocks tag @code{id}. It may be useful in the
  955. case of applications which execute part of their computation outside StarPU
  956. tasks (e.g. third-party libraries). It is also provided as a
  957. convenient tool for the programmer, for instance to entirely construct the task
  958. DAG before actually giving StarPU the opportunity to execute the tasks.
  959. @item @emph{Prototype}:
  960. @code{void starpu_tag_notify_from_apps(starpu_tag_t id);}
  961. @end table
  962. @node CUDA extensions
  963. @section CUDA extensions
  964. @c void starpu_data_malloc_pinned_if_possible(float **A, size_t dim);
  965. @c starpu_helper_cublas_init TODO
  966. @c starpu_helper_cublas_shutdown TODO
  967. @menu
  968. * starpu_cuda_get_local_stream:: Get current worker's CUDA stream
  969. * starpu_helper_cublas_init:: Initialize CUBLAS on every CUDA device
  970. * starpu_helper_cublas_shutdown:: Deinitialize CUBLAS on every CUDA device
  971. @end menu
  972. @node starpu_cuda_get_local_stream
  973. @subsection @code{starpu_cuda_get_local_stream} -- Get current worker's CUDA stream
  974. @table @asis
  975. @item @emph{Description}:
  976. StarPU provides a stream for every CUDA device controlled by StarPU. This
  977. function is only provided for convenience so that programmers can easily use
  978. asynchronous operations within codelets without having to create a stream by
  979. hand. Note that the application is not forced to use the stream provided by
  980. @code{starpu_cuda_get_local_stream} and may also create its own streams.
  981. @item @emph{Prototype}:
  982. @code{cudaStream_t *starpu_cuda_get_local_stream(void);}
  983. @end table
  984. @node starpu_helper_cublas_init
  985. @subsection @code{starpu_helper_cublas_init} -- Initialize CUBLAS on every CUDA device
  986. @table @asis
  987. @item @emph{Description}:
  988. The CUBLAS library must be initialized prior to any CUBLAS call. Calling
  989. @code{starpu_helper_cublas_init} will initialize CUBLAS on every CUDA device
  990. controlled by StarPU. This call blocks until CUBLAS has been properly
  991. initialized on every device.
  992. @item @emph{Prototype}:
  993. @code{void starpu_helper_cublas_init(void);}
  994. @end table
  995. @node starpu_helper_cublas_shutdown
  996. @subsection @code{starpu_helper_cublas_shutdown} -- Deinitialize CUBLAS on every CUDA device
  997. @table @asis
  998. @item @emph{Description}:
  999. This function synchronously deinitializes the CUBLAS library on every CUDA device.
  1000. @item @emph{Prototype}:
  1001. @code{void starpu_helper_cublas_shutdown(void);}
  1002. @end table
  1003. @node OpenCL extensions
  1004. @section OpenCL extensions
  1005. @menu
  1006. * Enabling OpenCL:: Enabling OpenCL
  1007. * Compiling OpenCL codelets:: Compiling OpenCL codelets
  1008. @end menu
  1009. @node Enabling OpenCL
  1010. @subsection Enabling OpenCL
  1011. On GPU devices which can run both CUDA and OpenCL, CUDA will be
  1012. enabled by default. To enable OpenCL, you need either to disable CUDA
  1013. when configuring StarPU:
  1014. @example
  1015. $ ./configure --disable-cuda
  1016. @end example
  1017. or when running applications:
  1018. @example
  1019. $ STARPU_NCUDA=0 ./application
  1020. @end example
  1021. OpenCL will automatically be started on any device not yet used by
  1022. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  1023. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  1024. so:
  1025. @example
  1026. $ STARPU_NCUDA=2 ./application
  1027. @end example
  1028. @node Compiling OpenCL codelets
  1029. @subsection Compiling OpenCL codelets
  1030. TODO
  1031. @node Cell extensions
  1032. @section Cell extensions
  1033. nothing yet.
  1034. @node Miscellaneous
  1035. @section Miscellaneous helpers
  1036. @menu
  1037. * starpu_execute_on_each_worker:: Execute a function on a subset of workers
  1038. @end menu
  1039. @node starpu_execute_on_each_worker
  1040. @subsection @code{starpu_execute_on_each_worker} -- Execute a function on a subset of workers
  1041. @table @asis
  1042. @item @emph{Description}:
  1043. When calling this method, the offloaded function specified by the first argument is
  1044. executed by every StarPU worker that may execute the function.
  1045. The second argument is passed to the offloaded function.
  1046. The last argument specifies on which types of processing units the function
  1047. should be executed. Similarly to the @code{where} field of the
  1048. @code{starpu_codelet} structure, it is possible to specify that the function
  1049. should be executed on every CUDA device and every CPU by passing
  1050. @code{STARPU_CPU|STARPU_CUDA}.
  1051. This function blocks until the function has been executed on every appropriate
  1052. processing units, so that it may not be called from a callback function for
  1053. instance.
  1054. @item @emph{Prototype}:
  1055. @code{void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);}
  1056. @end table
  1057. @c ---------------------------------------------------------------------
  1058. @c Basic Examples
  1059. @c ---------------------------------------------------------------------
  1060. @node Basic Examples
  1061. @chapter Basic Examples
  1062. @menu
  1063. * Compiling and linking:: Compiling and Linking Options
  1064. * Hello World:: Submitting Tasks
  1065. * Scaling a Vector:: Manipulating Data
  1066. * Scaling a Vector (hybrid):: Handling Heterogeneous Architectures
  1067. @end menu
  1068. @node Compiling and linking
  1069. @section Compiling and linking options
  1070. The Makefile could for instance contain the following lines to define which
  1071. options must be given to the compiler and to the linker:
  1072. @cartouche
  1073. @example
  1074. CFLAGS+=$$(pkg-config --cflags libstarpu)
  1075. LIBS+=$$(pkg-config --libs libstarpu)
  1076. @end example
  1077. @end cartouche
  1078. @node Hello World
  1079. @section Hello World
  1080. In this section, we show how to implement a simple program that submits a task to StarPU.
  1081. @subsection Required Headers
  1082. The @code{starpu.h} header should be included in any code using StarPU.
  1083. @cartouche
  1084. @example
  1085. #include <starpu.h>
  1086. @end example
  1087. @end cartouche
  1088. @subsection Defining a Codelet
  1089. @cartouche
  1090. @example
  1091. void cpu_func(void *buffers[], void *cl_arg)
  1092. @{
  1093. float *array = cl_arg;
  1094. printf("Hello world (array = @{%f, %f@} )\n", array[0], array[1]);
  1095. @}
  1096. starpu_codelet cl =
  1097. @{
  1098. .where = STARPU_CPU,
  1099. .cpu_func = cpu_func,
  1100. .nbuffers = 0
  1101. @};
  1102. @end example
  1103. @end cartouche
  1104. A codelet is a structure that represents a computational kernel. Such a codelet
  1105. may contain an implementation of the same kernel on different architectures
  1106. (e.g. CUDA, Cell's SPU, x86, ...).
  1107. The @code{nbuffers} field specifies the number of data buffers that are
  1108. manipulated by the codelet: here the codelet does not access or modify any data
  1109. that is controlled by our data management library. Note that the argument
  1110. passed to the codelet (the @code{cl_arg} field of the @code{starpu_task}
  1111. structure) does not count as a buffer since it is not managed by our data
  1112. management library.
  1113. @c TODO need a crossref to the proper description of "where" see bla for more ...
  1114. We create a codelet which may only be executed on the CPUs. The @code{where}
  1115. field is a bitmask that defines where the codelet may be executed. Here, the
  1116. @code{STARPU_CPU} value means that only CPUs can execute this codelet
  1117. (@pxref{Codelets and Tasks} for more details on this field).
  1118. When a CPU core executes a codelet, it calls the @code{cpu_func} function,
  1119. which @emph{must} have the following prototype:
  1120. @code{void (*cpu_func)(void *buffers[], void *cl_arg)}
  1121. In this example, we can ignore the first argument of this function which gives a
  1122. description of the input and output buffers (e.g. the size and the location of
  1123. the matrices). The second argument is a pointer to a buffer passed as an
  1124. argument to the codelet by the means of the @code{cl_arg} field of the
  1125. @code{starpu_task} structure.
  1126. @c TODO rewrite so that it is a little clearer ?
  1127. Be aware that this may be a pointer to a
  1128. @emph{copy} of the actual buffer, and not the pointer given by the programmer:
  1129. if the codelet modifies this buffer, there is no guarantee that the initial
  1130. buffer will be modified as well: this for instance implies that the buffer
  1131. cannot be used as a synchronization medium.
  1132. @subsection Submitting a Task
  1133. @cartouche
  1134. @example
  1135. void callback_func(void *callback_arg)
  1136. @{
  1137. printf("Callback function (arg %x)\n", callback_arg);
  1138. @}
  1139. int main(int argc, char **argv)
  1140. @{
  1141. /* initialize StarPU */
  1142. starpu_init(NULL);
  1143. struct starpu_task *task = starpu_task_create();
  1144. task->cl = &cl;
  1145. float *array[2] = @{1.0f, -1.0f@};
  1146. task->cl_arg = &array;
  1147. task->cl_arg_size = 2*sizeof(float);
  1148. task->callback_func = callback_func;
  1149. task->callback_arg = 0x42;
  1150. /* starpu_task_submit will be a blocking call */
  1151. task->synchronous = 1;
  1152. /* submit the task to StarPU */
  1153. starpu_task_submit(task);
  1154. /* terminate StarPU */
  1155. starpu_shutdown();
  1156. return 0;
  1157. @}
  1158. @end example
  1159. @end cartouche
  1160. Before submitting any tasks to StarPU, @code{starpu_init} must be called. The
  1161. @code{NULL} argument specifies that we use default configuration. Tasks cannot
  1162. be submitted after the termination of StarPU by a call to
  1163. @code{starpu_shutdown}.
  1164. In the example above, a task structure is allocated by a call to
  1165. @code{starpu_task_create}. This function only allocates and fills the
  1166. corresponding structure with the default settings (@pxref{starpu_task_create}),
  1167. but it does not submit the task to StarPU.
  1168. @c not really clear ;)
  1169. The @code{cl} field is a pointer to the codelet which the task will
  1170. execute: in other words, the codelet structure describes which computational
  1171. kernel should be offloaded on the different architectures, and the task
  1172. structure is a wrapper containing a codelet and the piece of data on which the
  1173. codelet should operate.
  1174. The optional @code{cl_arg} field is a pointer to a buffer (of size
  1175. @code{cl_arg_size}) with some parameters for the kernel
  1176. described by the codelet. For instance, if a codelet implements a computational
  1177. kernel that multiplies its input vector by a constant, the constant could be
  1178. specified by the means of this buffer.
  1179. Once a task has been executed, an optional callback function can be called.
  1180. While the computational kernel could be offloaded on various architectures, the
  1181. callback function is always executed on a CPU. The @code{callback_arg}
  1182. pointer is passed as an argument of the callback. The prototype of a callback
  1183. function must be:
  1184. @cartouche
  1185. @example
  1186. void (*callback_function)(void *);
  1187. @end example
  1188. @end cartouche
  1189. If the @code{synchronous} field is non-null, task submission will be
  1190. synchronous: the @code{starpu_task_submit} function will not return until the
  1191. task was executed. Note that the @code{starpu_shutdown} method does not
  1192. guarantee that asynchronous tasks have been executed before it returns.
  1193. @node Scaling a Vector
  1194. @section Manipulating Data: Scaling a Vector
  1195. The previous example has shown how to submit tasks. In this section we show how
  1196. StarPU tasks can manipulate data.
  1197. Programmers can describe the data layout of their application so that StarPU is
  1198. responsible for enforcing data coherency and availability across the machine.
  1199. Instead of handling complex (and non-portable) mechanisms to perform data
  1200. movements, programmers only declare which piece of data is accessed and/or
  1201. modified by a task, and StarPU makes sure that when a computational kernel
  1202. starts somewhere (e.g. on a GPU), its data are available locally.
  1203. Before submitting those tasks, the programmer first needs to declare the
  1204. different pieces of data to StarPU using the @code{starpu_*_data_register}
  1205. functions. To ease the development of applications for StarPU, it is possible
  1206. to describe multiple types of data layout. A type of data layout is called an
  1207. @b{interface}. By default, there are different interfaces available in StarPU:
  1208. here we will consider the @b{vector interface}.
  1209. The following lines show how to declare an array of @code{n} elements of type
  1210. @code{float} using the vector interface:
  1211. @cartouche
  1212. @example
  1213. float tab[n];
  1214. starpu_data_handle tab_handle;
  1215. starpu_vector_data_register(&tab_handle, 0, tab, n, sizeof(float));
  1216. @end example
  1217. @end cartouche
  1218. The first argument, called the @b{data handle}, is an opaque pointer which
  1219. designates the array in StarPU. This is also the structure which is used to
  1220. describe which data is used by a task. The second argument is the node number
  1221. where the data currently resides. Here it is 0 since the @code{tab} array is in
  1222. the main memory. Then comes the pointer @code{tab} where the data can be found,
  1223. the number of elements in the vector and the size of each element.
  1224. It is possible to construct a StarPU
  1225. task that multiplies this vector by a constant factor:
  1226. @cartouche
  1227. @example
  1228. float factor = 3.0;
  1229. struct starpu_task *task = starpu_task_create();
  1230. task->cl = &cl;
  1231. task->buffers[0].handle = tab_handle;
  1232. task->buffers[0].mode = STARPU_RW;
  1233. task->cl_arg = &factor;
  1234. task->cl_arg_size = sizeof(float);
  1235. task->synchronous = 1;
  1236. starpu_task_submit(task);
  1237. @end example
  1238. @end cartouche
  1239. Since the factor is constant, it does not need a preliminary declaration, and
  1240. can just be passed through the @code{cl_arg} pointer like in the previous
  1241. example. The vector parameter is described by its handle.
  1242. There are two fields in each element of the @code{buffers} array.
  1243. @code{handle} is the handle of the data, and @code{mode} specifies how the
  1244. kernel will access the data (@code{STARPU_R} for read-only, @code{STARPU_W} for
  1245. write-only and @code{STARPU_RW} for read and write access).
  1246. The definition of the codelet can be written as follows:
  1247. @cartouche
  1248. @example
  1249. void scal_func(void *buffers[], void *cl_arg)
  1250. @{
  1251. unsigned i;
  1252. float *factor = cl_arg;
  1253. struct starpu_vector_interface_s *vector = buffers[0];
  1254. /* length of the vector */
  1255. unsigned n = STARPU_GET_VECTOR_NX(vector);
  1256. /* local copy of the vector pointer */
  1257. float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
  1258. for (i = 0; i < n; i++)
  1259. val[i] *= *factor;
  1260. @}
  1261. starpu_codelet cl = @{
  1262. .where = STARPU_CPU,
  1263. .cpu_func = scal_func,
  1264. .nbuffers = 1
  1265. @};
  1266. @end example
  1267. @end cartouche
  1268. The second argument of the @code{scal_func} function contains a pointer to the
  1269. parameters of the codelet (given in @code{task->cl_arg}), so that we read the
  1270. constant factor from this pointer. The first argument is an array that gives
  1271. a description of every buffers passed in the @code{task->buffers}@ array. The
  1272. size of this array is given by the @code{nbuffers} field of the codelet
  1273. structure. For the sake of generality, this array contains pointers to the
  1274. different interfaces describing each buffer. In the case of the @b{vector
  1275. interface}, the location of the vector (resp. its length) is accessible in the
  1276. @code{ptr} (resp. @code{nx}) of this array. Since the vector is accessed in a
  1277. read-write fashion, any modification will automatically affect future accesses
  1278. to this vector made by other tasks.
  1279. @node Scaling a Vector (hybrid)
  1280. @section Vector Scaling on an Hybrid CPU/GPU Machine
  1281. Contrary to the previous examples, the task submitted in this example may not
  1282. only be executed by the CPUs, but also by a CUDA device.
  1283. @menu
  1284. * Source code:: Source of the StarPU application
  1285. * Compilation and execution:: Executing the StarPU application
  1286. @end menu
  1287. @node Source code
  1288. @subsection Source code
  1289. The CUDA implementation can be written as follows. It needs to be
  1290. compiled with a CUDA compiler such as nvcc, the NVIDIA CUDA compiler
  1291. driver.
  1292. @cartouche
  1293. @example
  1294. #include <starpu.h>
  1295. static __global__ void vector_mult_cuda(float *val, unsigned n,
  1296. float factor)
  1297. @{
  1298. unsigned i;
  1299. for(i = 0 ; i < n ; i++)
  1300. val[i] *= factor;
  1301. @}
  1302. extern "C" void scal_cuda_func(void *buffers[], void *_args)
  1303. @{
  1304. float *factor = (float *)_args;
  1305. struct starpu_vector_interface_s *vector = (struct starpu_vector_interface_s *) buffers[0];
  1306. /* length of the vector */
  1307. unsigned n = STARPU_GET_VECTOR_NX(vector);
  1308. /* local copy of the vector pointer */
  1309. float *val = (float *)STARPU_GET_VECTOR_PTR(vector);
  1310. /* TODO: use more blocks and threads in blocks */
  1311. vector_mult_cuda<<<1,1>>>(val, n, *factor);
  1312. cudaThreadSynchronize();
  1313. @}
  1314. @end example
  1315. @end cartouche
  1316. The CPU implementation is the same as in the previous section.
  1317. Here is the source of the main application. You can notice the value of the
  1318. field @code{where} for the codelet. We specify
  1319. @code{STARPU_CPU|STARPU_CUDA} to indicate to StarPU that the codelet
  1320. can be executed either on a CPU or on a CUDA device.
  1321. @cartouche
  1322. @example
  1323. #include <starpu.h>
  1324. #define NX 5
  1325. extern void scal_cuda_func(void *buffers[], void *_args);
  1326. extern void scal_func(void *buffers[], void *_args);
  1327. /* @b{Definition of the codelet} */
  1328. static starpu_codelet cl = @{
  1329. .where = STARPU_CPU|STARPU_CUDA; /* @b{It can be executed on a CPU} */
  1330. /* @b{or on a CUDA device} */
  1331. .cuda_func = scal_cuda_func;
  1332. .cpu_func = scal_func;
  1333. .nbuffers = 1;
  1334. @}
  1335. int main(int argc, char **argv)
  1336. @{
  1337. float *vector;
  1338. int i, ret;
  1339. float factor=3.0;
  1340. struct starpu_task *task;
  1341. starpu_data_handle tab_handle;
  1342. starpu_init(NULL); /* @b{Initialising StarPU} */
  1343. vector = (float*)malloc(NX*sizeof(float));
  1344. assert(vector);
  1345. for(i=0 ; i<NX ; i++) vector[i] = i;
  1346. @end example
  1347. @end cartouche
  1348. @cartouche
  1349. @example
  1350. /* @b{Registering data within StarPU} */
  1351. starpu_vector_data_register(&tab_handle, 0, (uintptr_t)vector,
  1352. NX, sizeof(float));
  1353. /* @b{Definition of the task} */
  1354. task = starpu_task_create();
  1355. task->cl = &cl;
  1356. task->callback_func = NULL;
  1357. task->buffers[0].handle = tab_handle;
  1358. task->buffers[0].mode = STARPU_RW;
  1359. task->cl_arg = &factor;
  1360. @end example
  1361. @end cartouche
  1362. @cartouche
  1363. @example
  1364. /* @b{Submitting the task} */
  1365. ret = starpu_task_submit(task);
  1366. if (ret == -ENODEV) @{
  1367. fprintf(stderr, "No worker may execute this task\n");
  1368. return 1;
  1369. @}
  1370. /* @b{Waiting for its termination} */
  1371. starpu_task_wait_for_all();
  1372. /* @b{Update the vector in RAM} */
  1373. starpu_data_sync_with_mem(tab_handle, STARPU_R);
  1374. @end example
  1375. @end cartouche
  1376. @cartouche
  1377. @example
  1378. /* @b{Access the data} */
  1379. for(i=0 ; i<NX; i++) @{
  1380. fprintf(stderr, "%f ", vector[i]);
  1381. @}
  1382. fprintf(stderr, "\n");
  1383. /* @b{Release the data and shutdown StarPU} */
  1384. starpu_data_release_from_mem(tab_handle);
  1385. starpu_shutdown();
  1386. return 0;
  1387. @}
  1388. @end example
  1389. @end cartouche
  1390. @node Compilation and execution
  1391. @subsection Compilation and execution
  1392. Let's suppose StarPU has been installed in the directory
  1393. @code{$STARPU_DIR}. As explained in @ref{pkg-config configuration},
  1394. the variable @code{PKG_CONFIG_PATH} needs to be set. It is also
  1395. necessary to set the variable @code{LD_LIBRARY_PATH} to locate dynamic
  1396. libraries at runtime.
  1397. @example
  1398. $ PKG_CONFIG_PATH=$STARPU_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
  1399. $ LD_LIBRARY_PATH=$STARPU_DIR/lib:$LD_LIBRARY_PATH
  1400. @end example
  1401. It is then possible to compile the application using the following
  1402. makefile:
  1403. @cartouche
  1404. @example
  1405. CFLAGS += $(shell pkg-config --cflags libstarpu)
  1406. LDFLAGS += $(shell pkg-config --libs libstarpu)
  1407. CC = gcc
  1408. vector: vector.o vector_cpu.o vector_cuda.o
  1409. %.o: %.cu
  1410. nvcc $(CFLAGS) $< -c $@
  1411. clean:
  1412. rm -f vector *.o
  1413. @end example
  1414. @end cartouche
  1415. @example
  1416. $ make
  1417. @end example
  1418. and to execute it, with the default configuration:
  1419. @example
  1420. $ ./vector
  1421. 0.000000 3.000000 6.000000 9.000000 12.000000
  1422. @end example
  1423. or for example, by disabling CPU devices:
  1424. @example
  1425. $ STARPU_NCPUS=0 ./vector
  1426. 0.000000 3.000000 6.000000 9.000000 12.000000
  1427. @end example
  1428. or by disabling CUDA devices:
  1429. @example
  1430. $ STARPU_NCUDA=0 ./vector
  1431. 0.000000 3.000000 6.000000 9.000000 12.000000
  1432. @end example
  1433. @c TODO: Add performance model example (and update basic_examples)
  1434. @c ---------------------------------------------------------------------
  1435. @c Advanced Topics
  1436. @c ---------------------------------------------------------------------
  1437. @node Advanced Topics
  1438. @chapter Advanced Topics
  1439. @bye