starpu.texi 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  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 (eg. 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. (ie. CPUs and accelerators at the same time), but it also takes care to
  56. efficiently map and execute 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 manipulate 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 (ie. 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 architecture 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. StarPU can be built and installed by the standard means of the GNU
  107. autotools. The following chapter is intended to briefly remind how these tools
  108. can be used to install StarPU.
  109. @section Configuring StarPU
  110. @subsection Generating Makefiles and configuration scripts
  111. This step is not necessary when using the tarball releases of StarPU. If you
  112. are using the source code from the svn repository, you first need to generate
  113. the configure scripts and the Makefiles.
  114. @example
  115. $ autoreconf -vfi
  116. @end example
  117. @subsection Configuring StarPU
  118. @example
  119. $ ./configure
  120. @end example
  121. @c TODO enumerate the list of interesting options: refer to a specific section
  122. @section Building and Installing StarPU
  123. @subsection Building
  124. @example
  125. $ make
  126. @end example
  127. @subsection Sanity Checks
  128. In order to make sure that StarPU is working properly on the system, it is also
  129. possible to run a test suite.
  130. @example
  131. $ make check
  132. @end example
  133. @subsection Installing
  134. In order to install StarPU at the location that was specified during
  135. configuration:
  136. @example
  137. $ make install
  138. @end example
  139. @subsection pkg-config configuration
  140. It is possible that compiling and linking an application against StarPU
  141. requires to use specific flags or libraries (for instance @code{CUDA} or
  142. @code{libspe2}). Therefore, it is possible to use the @code{pkg-config} tool.
  143. If StarPU was not installed at some standard location, the path of StarPU's
  144. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  145. that @code{pkg-config} can find it. So if StarPU was installed in
  146. @code{$(prefix_dir)}:
  147. @example
  148. @c TODO: heu, c'est vraiment du shell ça ? :)
  149. $ PKG_CONFIG_PATH = @{PKG_CONFIG_PATH@}:$(prefix_dir)/lib/
  150. @end example
  151. The flags required to compiled or linked against StarPU are then
  152. accessible with the following commands:
  153. @example
  154. $ pkg-config --cflags libstarpu # options for the compiler
  155. $ pkg-config --libs libstarpu # options for the linker
  156. @end example
  157. @c ---------------------------------------------------------------------
  158. @c Configuration options
  159. @c ---------------------------------------------------------------------
  160. @node Configuration options
  161. @chapter Configuration options
  162. TODO
  163. @c ---------------------------------------------------------------------
  164. @c Environment variables
  165. @c ---------------------------------------------------------------------
  166. @node Environment variables
  167. @chapter Environment variables
  168. @menu
  169. * Workers:: Configuring workers
  170. * Scheduling:: Configuring the Scheduling engine
  171. * Misc:: Miscellaneous and debug
  172. @end menu
  173. TODO, explicit configuration (passed to starpu_init) overrides env variables.
  174. @node Workers
  175. @section Configuring workers
  176. @menu
  177. * STARPU_NCPUS :: Number of CPU workers
  178. * STARPU_NCUDA :: Number of CUDA workers
  179. * STARPU_NOPENCL :: Number of OpenCL workers
  180. * STARPU_NGORDON :: Number of SPU workers (Cell)
  181. * STARPU_WORKERS_CPUID :: Bind workers to specific CPUs
  182. * STARPU_WORKERS_CUDAID :: Select specific CUDA devices
  183. * STARPU_WORKERS_OPENCLID :: Select specific OpenCL devices
  184. @end menu
  185. @node STARPU_NCPUS
  186. @subsection @code{STARPU_NCPUS} -- Number of CPU workers
  187. @table @asis
  188. @item @emph{Description}:
  189. Specify the maximum number of CPU workers. Note that StarPU will not allocate
  190. more CPUs than there are physical CPUs, and that some CPUs are used to control
  191. the accelerators.
  192. @end table
  193. @node STARPU_NCUDA
  194. @subsection @code{STARPU_NCUDA} -- Number of CUDA workers
  195. @table @asis
  196. @item @emph{Description}:
  197. Specify the maximum number of CUDA devices that StarPU can use. In case there
  198. @code{STARPU_NCUDA} is lower than the number of physical devices, it is
  199. possible to select which CUDA devices should be used by the means of the
  200. @code{STARPU_WORKERS_CUDAID} environment variable.
  201. @end table
  202. @node STARPU_NOPENCL
  203. @subsection @code{STARPU_NOPENCL} -- Number of OpenCL workers
  204. @table @asis
  205. @item @emph{Description}:
  206. OpenCL equivalent of the @code{STARPU_NCUDA} environment variable.
  207. @end table
  208. @node STARPU_NGORDON
  209. @subsection @code{STARPU_NGORDON} -- Number of SPU workers (Cell)
  210. @table @asis
  211. @item @emph{Description}:
  212. Specify the maximum number of SPUs that StarPU can use.
  213. @end table
  214. @node STARPU_WORKERS_CPUID
  215. @subsection @code{STARPU_WORKERS_CPUID} -- Bind workers to specific CPUs
  216. @table @asis
  217. @item @emph{Description}:
  218. Passing an array of integers (starting from 0) in @code{STARPU_WORKERS_CPUID}
  219. specifies on which logical CPU the different workers should be
  220. bound. For instance, if @code{STARPU_WORKERS_CPUID = "1 3 0 2"}, the first
  221. worker will be bound to logical CPU #1, the second CPU worker will be bound to
  222. logical CPU #3 and so on. Note that the logical ordering of the CPUs is either
  223. determined by the OS, or provided by the @code{hwloc}  library in case it is
  224. available.
  225. Note that the first workers correspond to the CUDA workers, then come the
  226. OpenCL and the SPU, and finally the CPU workers. For example if
  227. we have @code{STARPU_NCUDA=1}, @code{STARPU_NOPENCL=1}, @code{STARPU_NCPUS=2}
  228. and @code{STARPU_WORKERS_CPUID = "0 2 1 3"}, the CUDA device will be controlled
  229. by logical CPU #0, the OpenCL device will be controlled by logical CPU #2, and
  230. the logical CPUs #1 and #3 will be used by the CPU workers.
  231. If the number of workers is larger than the array given in
  232. @code{STARPU_WORKERS_CPUID}, the workers are bound to the logical CPUs in a
  233. round-robin fashion: if @code{STARPU_WORKERS_CPUID = "0 1"}, the first and the
  234. third (resp. second and fourth) workers will be put on CPU #0 (resp. CPU #1).
  235. @end table
  236. @node STARPU_WORKERS_CUDAID
  237. @subsection @code{STARPU_WORKERS_CUDAID} -- Select specific CUDA devices
  238. @table @asis
  239. @item @emph{Description}:
  240. Similarly to the @code{STARPU_WORKERS_CPUID} environment variable, it is
  241. possible to select which CUDA devices should be used by StarPU. On a machine
  242. equipped with 4 GPUs, setting @code{STARPU_WORKERS_CUDAID = "1 3"} and
  243. @code{STARPU_NCUDA=2} specifies that 2 CUDA workers should be created, and that
  244. they should use CUDA devices #1 and #3 (the logical ordering of the devices is
  245. the one reported by CUDA).
  246. @end table
  247. @node STARPU_WORKERS_OPENCLID
  248. @subsection @code{STARPU_WORKERS_OPENCLID} -- Select specific OpenCL devices
  249. @table @asis
  250. @item @emph{Description}:
  251. OpenCL equivalent of the @code{STARPU_WORKERS_CUDAID} environment variable.
  252. @end table
  253. @node Scheduling
  254. @section Configuring the Scheduling engine
  255. @menu
  256. * STARPU_SCHED :: Scheduling policy
  257. * STARPU_CALIBRATE :: Calibrate performance models
  258. * STARPU_PREFETCH :: Use data prefetch
  259. * STARPU_SCHED_ALPHA :: Computation factor
  260. * STARPU_SCHED_BETA :: Communication factor
  261. @end menu
  262. @node STARPU_SCHED
  263. @subsection @code{STARPU_SCHED} -- Scheduling policy
  264. @table @asis
  265. @item @emph{Description}:
  266. TODO
  267. Use @code{STARPU_SCHED=help} to get the list of available schedulers
  268. @end table
  269. @node STARPU_CALIBRATE
  270. @subsection @code{STARPU_CALIBRATE} -- Calibrate performance models
  271. @table @asis
  272. @item @emph{Description}:
  273. If this variable is set, the performance models are calibrated during the execution.
  274. TODO
  275. Note: this currently only applies to dm and dmda scheduling policies.
  276. @end table
  277. @node STARPU_PREFETCH
  278. @subsection @code{STARPU_PREFETCH} -- Use data prefetch
  279. @table @asis
  280. @item @emph{Description}:
  281. TODO
  282. @end table
  283. @node STARPU_SCHED_ALPHA
  284. @subsection @code{STARPU_SCHED_ALPHA} -- Computation factor
  285. @table @asis
  286. @item @emph{Description}:
  287. TODO
  288. @end table
  289. @node STARPU_SCHED_BETA
  290. @subsection @code{STARPU_SCHED_BETA} -- Communication factor
  291. @table @asis
  292. @item @emph{Description}:
  293. TODO
  294. @end table
  295. @node Misc
  296. @section Miscellaneous and debug
  297. @menu
  298. * STARPU_LOGFILENAME :: Select debug file name
  299. @end menu
  300. @node STARPU_LOGFILENAME
  301. @subsection @code{STARPU_LOGFILENAME} -- Select debug file name
  302. @table @asis
  303. @item @emph{Description}:
  304. TODO
  305. @end table
  306. @c ---------------------------------------------------------------------
  307. @c StarPU API
  308. @c ---------------------------------------------------------------------
  309. @node StarPU API
  310. @chapter StarPU API
  311. @menu
  312. * Initialization and Termination:: Initialization and Termination methods
  313. * Workers' Properties:: Methods to enumerate workers' properties
  314. * Data Library:: Methods to manipulate data
  315. * Codelets and Tasks:: Methods to construct tasks
  316. * Tags:: Task dependencies
  317. @end menu
  318. @node Initialization and Termination
  319. @section Initialization and Termination
  320. @menu
  321. * starpu_init:: Initialize StarPU
  322. * struct starpu_conf:: StarPU runtime configuration
  323. * starpu_shutdown:: Terminate StarPU
  324. @end menu
  325. @node starpu_init
  326. @subsection @code{starpu_init} -- Initialize StarPU
  327. @table @asis
  328. @item @emph{Description}:
  329. This is StarPU initialization method, which must be called prior to any other
  330. StarPU call. It is possible to specify StarPU's configuration (eg. scheduling
  331. policy, number of cores, ...) by passing a non-null argument. Default
  332. configuration is used if the passed argument is @code{NULL}.
  333. @item @emph{Return value}:
  334. Upon successful completion, this function returns 0. Otherwise, @code{-ENODEV}
  335. indicates that no worker was available (so that StarPU was not be initialized).
  336. @item @emph{Prototype}:
  337. @code{int starpu_init(struct starpu_conf *conf);}
  338. @end table
  339. @node struct starpu_conf
  340. @subsection @code{struct starpu_conf} -- StarPU runtime configuration
  341. @table @asis
  342. @item @emph{Description}:
  343. This structure is passed to the @code{starpu_init} function in order configure
  344. StarPU. When the default value is used, StarPU automatically select the number
  345. of processing units and takes the default scheduling policy. This parameters
  346. overwrite the equivalent environnement variables.
  347. @item @emph{Fields}:
  348. @table @asis
  349. @item @code{sched_policy} (default = NULL):
  350. This is the name of the scheduling policy. This can also be specified with the
  351. @code{STARPU_SCHED} environment variable.
  352. @item @code{ncpus} (default = -1):
  353. This is the maximum number of CPU cores that StarPU can use. This can also be
  354. specified with the @code{STARPU_NCPUS} environment variable.
  355. @item @code{ncuda} (default = -1):
  356. This is the maximum number of CUDA devices that StarPU can use. This can also be
  357. specified with the @code{STARPU_NCUDA} environment variable.
  358. @item @code{nspus} (default = -1):
  359. This is the maximum number of Cell SPUs that StarPU can use. This can also be
  360. specified with the @code{STARPU_NGORDON} environment variable.
  361. @item @code{calibrate} (default = 0):
  362. If this flag is set, StarPU will calibrate the performance models when
  363. executing tasks. This can also be specified with the @code{STARPU_CALIBRATE}
  364. environment variable.
  365. @end table
  366. @end table
  367. @node starpu_shutdown
  368. @subsection @code{starpu_shutdown} -- Terminate StarPU
  369. @table @asis
  370. @item @emph{Description}:
  371. This is StarPU termination method. It must be called at the end of the
  372. application: statistics and other post-mortem debugging information are not
  373. garanteed to be available until this method has been called.
  374. @item @emph{Prototype}:
  375. @code{void starpu_shutdown(void);}
  376. @end table
  377. @node Workers' Properties
  378. @section Workers' Properties
  379. @menu
  380. * starpu_get_worker_count:: Get the number of processing units
  381. * starpu_get_worker_id:: Get the identifier of the current worker
  382. * starpu_get_worker_type:: Get the type of processing unit associated to a worker
  383. * starpu_get_worker_name:: Get the name of a worker
  384. @end menu
  385. @node starpu_get_worker_count
  386. @subsection @code{starpu_get_worker_count} -- Get the number of processing units
  387. @table @asis
  388. @item @emph{Description}:
  389. This function returns the number of workers (ie. processing units executing
  390. StarPU tasks). The returned value should be at most @code{STARPU_NMAXWORKERS}.
  391. @item @emph{Prototype}:
  392. @code{unsigned starpu_get_worker_count(void);}
  393. @end table
  394. @node starpu_get_worker_id
  395. @subsection @code{starpu_get_worker_id} -- Get the identifier of the current worker
  396. @table @asis
  397. @item @emph{Description}:
  398. This function returns the identifier of the worker associated to the calling
  399. thread. The returned value is either -1 if the current context is not a StarPU
  400. worker (ie. when called from the application outside a task or a callback), or
  401. an integer between 0 and @code{starpu_get_worker_count() - 1}.
  402. @item @emph{Prototype}:
  403. @code{int starpu_get_worker_count(void);}
  404. @end table
  405. @node starpu_get_worker_type
  406. @subsection @code{starpu_get_worker_type} -- Get the type of processing unit associated to a worker
  407. @table @asis
  408. @item @emph{Description}:
  409. This function returns the type of worker associated to an identifier (as
  410. returned by the @code{starpu_get_worker_id} function). The returned value
  411. indicates the architecture of the worker: @code{STARPU_CPU_WORKER} for a CPU
  412. core, @code{STARPU_CUDA_WORKER} for a CUDA device, and
  413. @code{STARPU_GORDON_WORKER} for a Cell SPU. The value returned for an invalid
  414. identifier is unspecified.
  415. @item @emph{Prototype}:
  416. @code{enum starpu_archtype starpu_get_worker_type(int id);}
  417. @end table
  418. @node starpu_get_worker_name
  419. @subsection @code{starpu_get_worker_name} -- Get the name of a worker
  420. @table @asis
  421. @item @emph{Description}:
  422. StarPU associates a unique human readable string to each processing unit. This
  423. function copies at most the @code{maxlen} first bytes of the unique string
  424. associated to a worker identified by its identifier @code{id} into the
  425. @code{dst} buffer. The caller is responsible for ensuring that the @code{dst}
  426. is a valid pointer to a buffer of @code{maxlen} bytes at least. Calling this
  427. function on an invalid identifier results in an unspecified behaviour.
  428. @item @emph{Prototype}:
  429. @code{void starpu_get_worker_name(int id, char *dst, size_t maxlen);}
  430. @end table
  431. @node Data Library
  432. @section Data Library
  433. @c data_handle_t
  434. @c void starpu_delete_data(struct starpu_data_state_t *state);
  435. @c user interaction with the DSM
  436. @c void starpu_sync_data_with_mem(struct starpu_data_state_t *state);
  437. @c void starpu_notify_data_modification(struct starpu_data_state_t *state, uint32_t modifying_node);
  438. @node Codelets and Tasks
  439. @section Codelets and Tasks
  440. @menu
  441. * struct starpu_codelet:: StarPU codelet structure
  442. * struct starpu_task:: StarPU task structure
  443. * starpu_task_init:: Initialize a Task
  444. * starpu_task_create:: Allocate and Initialize a Task
  445. * starpu_task_destroy:: Destroy a dynamically allocated Task
  446. * starpu_submit_task:: Submit a Task
  447. * starpu_wait_task:: Wait for the termination of a Task
  448. * starpu_wait_all_tasks:: Wait for the termination of all Tasks
  449. @end menu
  450. @node struct starpu_codelet
  451. @subsection @code{struct starpu_codelet} -- StarPU codelet structure
  452. @table @asis
  453. @item @emph{Description}:
  454. The codelet structure describes a kernel that is possibly implemented on
  455. various targets.
  456. @item @emph{Fields}:
  457. @table @asis
  458. @item @code{where}:
  459. Indicates which types of processing units are able to execute that codelet.
  460. @code{STARPU_CPU|STARPU_CUDA} for instance indicates that the codelet is
  461. implemented for both CPU cores and CUDA devices while @code{STARPU_GORDON}
  462. indicates that it is only available on Cell SPUs.
  463. @item @code{cpu_func} (optionnal):
  464. Is a function pointer to the CPU implementation of the codelet. Its prototype
  465. must be: @code{void cpu_func(void *buffers[], void *cl_arg)}. The
  466. first argument being the array of data managed by the data management library,
  467. and the second argument is a pointer to the argument (possibly a copy of it)
  468. passed from the @code{.cl_arg} field of the @code{starpu_task} structure. This
  469. pointer is ignored if @code{STARPU_CPU} does not appear in the @code{.where} field,
  470. it must be non-null otherwise.
  471. @item @code{cuda_func} (optionnal):
  472. Is a function pointer to the CUDA implementation of the codelet. @emph{This
  473. must be a host-function written in the CUDA runtime API}. Its prototype must
  474. be: @code{void cuda_func(void *buffers[], void *cl_arg);}. This
  475. pointer is ignored if @code{CUDA} does not appear in the @code{.where} field,
  476. it must be non-null otherwise.
  477. @item @code{gordon_func} (optionnal):
  478. This is the index of the Cell SPU implementation within the Gordon library.
  479. TODO
  480. @item @code{nbuffers}:
  481. Specifies the number of arguments taken by the codelet. These arguments are
  482. managed by the DSM and are accessed from the @code{void *buffers[]}
  483. array. The constant argument passed with the @code{.cl_arg} field of the
  484. @code{starpu_task} structure is not counted in this number. This value should
  485. not be above @code{STARPU_NMAXBUFS}.
  486. @item @code{model} (optionnal):
  487. This is a pointer to the performance model associated to this codelet. This
  488. optionnal field is ignored when null. TODO
  489. @end table
  490. @end table
  491. @node struct starpu_task
  492. @subsection @code{struct starpu_task} -- StarPU task structure
  493. @table @asis
  494. @item @emph{Description}:
  495. The starpu_task structure describes a task that can be offloaded on the various
  496. processing units managed by StarPU. It instanciates a codelet. It can either be
  497. allocated dynamically with the @code{starpu_task_create} method, or declared
  498. statically. In the latter case, the programmer has to zero the
  499. @code{starpu_task} structure and to fill the different fields properly. The
  500. indicated default values correspond to the configuration of a task allocated
  501. with @code{starpu_task_create}.
  502. @item @emph{Fields}:
  503. @table @asis
  504. @item @code{cl}:
  505. Is a pointer to the corresponding @code{starpu_codelet} data structure. This
  506. describes where the kernel should be executed, and supplies the appropriate
  507. implementations. When set to @code{NULL}, no code is executed during the tasks,
  508. such empty tasks can be useful for synchronization purposes.
  509. @item @code{buffers}:
  510. TODO
  511. @item @code{cl_arg} (optional) (default = NULL):
  512. TODO
  513. @item @code{cl_arg_size} (optional):
  514. TODO
  515. @c ignored if only executable on CPUs or CUDA ...
  516. @item @code{callback_func} (optional) (default = @code{NULL}):
  517. This is a function pointer of prototype @code{void (*f)(void *)} which
  518. specifies a possible callback. If that pointer is non-null, the callback
  519. function is executed @emph{on the host} after the execution of the task. The
  520. callback is passed the value contained in the @code{callback_arg} field. No
  521. callback is executed if that field is null.
  522. @item @code{callback_arg} (optional) (default = @code{NULL}):
  523. This is the pointer passed to the callback function. This field is ignored if
  524. the @code{callback_func} is null.
  525. @item @code{use_tag} (optional) (default = 0):
  526. If set, this flag indicates that the task should be associated with the tag
  527. conained in the @code{tag_id} field. Tag allow the application to synchronize
  528. with the task and to express task dependencies easily.
  529. @item @code{tag_id}:
  530. This fields contains the tag associated to the tag if the @code{use_tag} field
  531. was set, it is ignored otherwise.
  532. @item @code{synchronous}:
  533. If this flag is set, the @code{starpu_submit_task} function is blocking and
  534. returns only when the task has been executed (or if no worker is able to
  535. process the task). Otherwise, @code{starpu_submit_task} returns immediately.
  536. @item @code{priority} (optionnal) (default = @code{DEFAULT_PRIO}):
  537. This field indicates a level of priority for the task. This is an integer value
  538. that must be selected between @code{MIN_PRIO} (for the least important tasks)
  539. and @code{MAX_PRIO} (for the most important tasks) included. Default priority
  540. is @code{DEFAULT_PRIO}. Scheduling strategies that take priorities into
  541. account can use this parameter to take better scheduling decisions, but the
  542. scheduling policy may also ignore it.
  543. @item @code{execute_on_a_specific_worker} (default = 0):
  544. If this flag is set, StarPU will bypass the scheduler and directly affect this
  545. task to the worker specified by the @code{workerid} field.
  546. @item @code{workerid} (optional):
  547. If the @code{execute_on_a_specific_worker} field is set, this field indicates
  548. which is the identifier of the worker that should process this task (as
  549. returned by @code{starpu_get_worker_id}). This field is ignored if
  550. @code{execute_on_a_specific_worker} field is set to 0.
  551. @item @code{detach} (optional) (default = 1):
  552. If this flag is set, it is not possible to synchronize with the task
  553. by the means of @code{starpu_wait_task} later on. Internal data structures
  554. are only garanteed to be liberated once @code{starpu_wait_task} is called
  555. if that flag is not set.
  556. @item @code{destroy} (optional) (default = 1):
  557. If that flag is set, the task structure will automatically be liberated, either
  558. after the execution of the callback if the task is detached, or during
  559. @code{starpu_task_wait} otherwise. If this flag is not set, dynamically allocated data
  560. structures will not be liberated until @code{starpu_task_destroy} is called
  561. explicitely. Setting this flag for a statically allocated task structure will
  562. result in undefined behaviour.
  563. @end table
  564. @end table
  565. @node starpu_task_init
  566. @subsection @code{starpu_task_init} -- Initialize a Task
  567. @table @asis
  568. @item @emph{Description}:
  569. TODO
  570. @item @emph{Prototype}:
  571. @code{void starpu_task_init(struct starpu_task *task);}
  572. @end table
  573. @node starpu_task_create
  574. @subsection @code{starpu_task_create} -- Allocate and Initialize a Task
  575. @table @asis
  576. @item @emph{Description}:
  577. TODO
  578. (Describe the different default fields ...)
  579. @item @emph{Prototype}:
  580. @code{struct starpu_task *starpu_task_create(void);}
  581. @end table
  582. @node starpu_task_destroy
  583. @subsection @code{starpu_task_destroy} -- Destroy a dynamically allocated Task
  584. @table @asis
  585. @item @emph{Description}:
  586. Liberate the ressource allocated during starpu_task_create. This function can
  587. be called automatically after the execution of a task by setting the
  588. @code{.destroy} flag of the @code{starpu_task} structure (default behaviour).
  589. Calling this function on a statically allocated task results in an undefined
  590. behaviour.
  591. @item @emph{Prototype}:
  592. @code{void starpu_task_destroy(struct starpu_task *task);}
  593. @end table
  594. @node starpu_wait_task
  595. @subsection @code{starpu_wait_task} -- Wait for the termination of a Task
  596. @table @asis
  597. @item @emph{Description}:
  598. This function blocks until the task was executed. It is not possible to
  599. synchronize with a task more than once. It is not possible to wait
  600. synchronous or detached tasks.
  601. @item @emph{Return value}:
  602. Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
  603. indicates that the waited task was either synchronous or detached.
  604. @item @emph{Prototype}:
  605. @code{int starpu_wait_task(struct starpu_task *task);}
  606. @end table
  607. @node starpu_submit_task
  608. @subsection @code{starpu_submit_task} -- Submit a Task
  609. @table @asis
  610. @item @emph{Description}:
  611. This function submits task @code{task} to StarPU. Calling this function does
  612. not mean that the task will be executed immediatly as there can be data or task
  613. (tag) dependencies that are not fulfilled yet: StarPU will take care to
  614. schedule this task with respect to such dependencies.
  615. This function returns immediately if the @code{synchronous} field of the
  616. @code{starpu_task} structure was set to 0, and block until the termination of
  617. the task otherwise. It is also possible to synchronize the application with
  618. asynchronous tasks by the means of tags, using the @code{starpu_tag_wait}
  619. function for instance.
  620. In case of success, this function returns 0, a return value of @code{-ENODEV}
  621. means that there is no worker able to process that task (eg. there is no GPU
  622. available and this task is only implemented on top of CUDA).
  623. @item @emph{Prototype}:
  624. @code{int starpu_submit_task(struct starpu_task *task);}
  625. @end table
  626. @node starpu_wait_all_tasks
  627. @subsection @code{starpu_wait_all_tasks} -- Wait for the termination of all Tasks
  628. @table @asis
  629. @item @emph{Description}:
  630. This function blocks until all the tasks that were submitted are terminated.
  631. @item @emph{Prototype}:
  632. @code{void starpu_wait_all_tasks(void);}
  633. @end table
  634. @c Callbacks : what can we put in callbacks ?
  635. @node Tags
  636. @section Tags
  637. @menu
  638. * starpu_tag_t:: Task identifier
  639. * starpu_tag_declare_deps:: Declare the Dependencies of a Tag
  640. * starpu_tag_declare_deps_array:: Declare the Dependencies of a Tag
  641. * starpu_tag_wait:: Block until a Tag is terminated
  642. * starpu_tag_wait_array:: Block until a set of Tags is terminated
  643. * starpu_tag_remove:: Destroy a Tag
  644. * starpu_tag_notify_from_apps:: Feed a tag explicitely
  645. @end menu
  646. @node starpu_tag_t
  647. @subsection @code{starpu_tag_t} -- Task identifier
  648. @table @asis
  649. @item @emph{Description}:
  650. It is possible to associate a task with a unique "tag" and to express
  651. dependencies between tasks by the means of those tags. To do so, fill the
  652. @code{tag_id} field of the @code{starpu_task} structure with a tag number (can
  653. be arbitrary) and set the @code{use_tag} field to 1.
  654. If @code{starpu_tag_declare_deps} is called with that tag number, the task will
  655. not be started until the task which wears the declared dependency tags are
  656. complete.
  657. @end table
  658. @node starpu_tag_declare_deps
  659. @subsection @code{starpu_tag_declare_deps} -- Declare the Dependencies of a Tag
  660. @table @asis
  661. @item @emph{Description}:
  662. Specify the dependencies of the task identified by tag @code{id}. The first
  663. argument specifies the tag which is configured, the second argument gives the
  664. number of tag(s) on which @code{id} depends. The following arguments are the
  665. tags which have to terminated to unlock the task.
  666. This function must be called before the associated task is submitted to StarPU
  667. with @code{starpu_submit_task}.
  668. @item @emph{Remark}
  669. Because of the variable arity of @code{starpu_tag_declare_deps}, note that the
  670. last arguments @emph{must} be of type @code{starpu_tag_t}: constant values
  671. typically need to be explicitely casted. Using the
  672. @code{starpu_tag_declare_deps_array} function avoids this hazard.
  673. @item @emph{Prototype}:
  674. @code{void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);}
  675. @item @emph{Example}:
  676. @example
  677. @c @cartouche
  678. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  679. starpu_tag_declare_deps((starpu_tag_t)0x1,
  680. 2, (starpu_tag_t)0x32, (starpu_tag_t)0x52);
  681. @c @end cartouche
  682. @end example
  683. @end table
  684. @node starpu_tag_declare_deps_array
  685. @subsection @code{starpu_tag_declare_deps_array} -- Declare the Dependencies of a Tag
  686. @table @asis
  687. @item @emph{Description}:
  688. This function is similar to @code{starpu_tag_declare_deps}, except that its
  689. does not take a variable number of arguments but an array of tags of size
  690. @code{ndeps}.
  691. @item @emph{Prototype}:
  692. @code{void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);}
  693. @item @emph{Example}:
  694. @example
  695. @c @cartouche
  696. /* Tag 0x1 depends on tags 0x32 and 0x52 */
  697. starpu_tag_t tag_array[2] = @{0x32, 0x52@};
  698. starpu_tag_declare_deps((starpu_tag_t)0x1, 2, tag_array);
  699. @c @end cartouche
  700. @end example
  701. @end table
  702. @node starpu_tag_wait
  703. @subsection @code{starpu_tag_wait} -- Block until a Tag is terminated
  704. @table @asis
  705. @item @emph{Description}:
  706. This function blocks until the task associated to tag @code{id} has been
  707. executed. This is a blocking call which must therefore not be called within
  708. tasks or callbacks, but only from the application directly. It is possible to
  709. synchronize with the same tag multiple times, as long as the
  710. @code{starpu_tag_remove} function is not called. Note that it is still
  711. possible to synchronize wih a tag associated to a task which @code{starpu_task}
  712. data structure was liberated (eg. if the @code{destroy} flag of the
  713. @code{starpu_task} was enabled).
  714. @item @emph{Prototype}:
  715. @code{void starpu_tag_wait(starpu_tag_t id);}
  716. @end table
  717. @node starpu_tag_wait_array
  718. @subsection @code{starpu_tag_wait_array} -- Block until a set of Tags is terminated
  719. @table @asis
  720. @item @emph{Description}:
  721. This function is similar to @code{starpu_tag_wait} except that it blocks until
  722. @emph{all} the @code{ntags} tags contained in the @code{id} array are
  723. terminated.
  724. @item @emph{Prototype}:
  725. @code{void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);}
  726. @end table
  727. @node starpu_tag_remove
  728. @subsection @code{starpu_tag_remove} -- Destroy a Tag
  729. @table @asis
  730. @item @emph{Description}:
  731. This function release the resources associated to tag @code{id}. It can be
  732. called once the corresponding task has been executed and when there is no tag
  733. that depend on that one anymore.
  734. @item @emph{Prototype}:
  735. @code{void starpu_tag_remove(starpu_tag_t id);}
  736. @end table
  737. @node starpu_tag_notify_from_apps
  738. @subsection @code{starpu_tag_notify_from_apps} -- Feed a Tag explicitely
  739. @table @asis
  740. @item @emph{Description}:
  741. This function explicitely unlocks tag @code{id}. It may be useful in the
  742. case of applications which execute part of their computation outside StarPU
  743. tasks (eg. third-party libraries). It is also provided as a
  744. convenient tool for the programmer, for instance to entirely construct the task
  745. DAG before actually giving StarPU the opportunity to execute the tasks.
  746. @item @emph{Prototype}:
  747. @code{void starpu_tag_notify_from_apps(starpu_tag_t id);}
  748. @end table
  749. @section Extensions
  750. @subsection CUDA extensions
  751. @c void starpu_malloc_pinned_if_possible(float **A, size_t dim);
  752. @subsection Cell extensions
  753. @c ---------------------------------------------------------------------
  754. @c Basic Examples
  755. @c ---------------------------------------------------------------------
  756. @node Basic Examples
  757. @chapter Basic Examples
  758. @menu
  759. * Compiling and linking:: Compiling and Linking Options
  760. * Hello World:: Submitting Tasks
  761. * Scaling a Vector:: Manipulating Data
  762. * Scaling a Vector (hybrid):: Handling Heterogeneous Architectures
  763. @end menu
  764. @node Compiling and linking
  765. @section Compiling and linking options
  766. The Makefile could for instance contain the following lines to define which
  767. options must be given to the compiler and to the linker:
  768. @example
  769. @c @cartouche
  770. CFLAGS+=$$(pkg-config --cflags libstarpu)
  771. LIBS+=$$(pkg-config --libs libstarpu)
  772. @c @end cartouche
  773. @end example
  774. @node Hello World
  775. @section Hello World
  776. In this section, we show how to implement a simple program that submits a task to StarPU.
  777. @subsection Required Headers
  778. The @code{starpu.h} header should be included in any code using StarPU.
  779. @example
  780. @c @cartouche
  781. #include <starpu.h>
  782. @c @end cartouche
  783. @end example
  784. @subsection Defining a Codelet
  785. @example
  786. @c @cartouche
  787. void cpu_func(void *buffers[], void *cl_arg)
  788. @{
  789. float *array = cl_arg;
  790. printf("Hello world (array = @{%f, %f@} )\n", array[0], array[1]);
  791. @}
  792. starpu_codelet cl =
  793. @{
  794. .where = STARPU_CPU,
  795. .cpu_func = cpu_func,
  796. .nbuffers = 0
  797. @};
  798. @c @end cartouche
  799. @end example
  800. A codelet is a structure that represents a computational kernel. Such a codelet
  801. may contain an implementation of the same kernel on different architectures
  802. (eg. CUDA, Cell's SPU, x86, ...).
  803. The ''@code{.nbuffers}'' field specifies the number of data buffers that are
  804. manipulated by the codelet: here the codelet does not access or modify any data
  805. that is controlled by our data management library. Note that the argument
  806. passed to the codelet (the ''@code{.cl_arg}'' field of the @code{starpu_task}
  807. structure) does not count as a buffer since it is not managed by our data
  808. management library.
  809. @c TODO need a crossref to the proper description of "where" see bla for more ...
  810. We create a codelet which may only be executed on the CPUs. The ''@code{.where}''
  811. field is a bitmask that defines where the codelet may be executed. Here, the
  812. @code{STARPU_CPU} value means that only CPUs can execute this codelet
  813. (@pxref{Codelets and Tasks} for more details on that field).
  814. When a CPU core executes a codelet, it calls the @code{.cpu_func} function,
  815. which @emph{must} have the following prototype:
  816. @code{void (*cpu_func)(void *buffers[], void *cl_arg)}
  817. In this example, we can ignore the first argument of this function which gives a
  818. description of the input and output buffers (eg. the size and the location of
  819. the matrices). The second argument is a pointer to a buffer passed as an
  820. argument to the codelet by the means of the ''@code{.cl_arg}'' field of the
  821. @code{starpu_task} structure.
  822. @c TODO rewrite so that it is a little clearer ?
  823. Be aware that this may be a pointer to a
  824. @emph{copy} of the actual buffer, and not the pointer given by the programmer:
  825. if the codelet modifies this buffer, there is no garantee that the initial
  826. buffer will be modified as well: this for instance implies that the buffer
  827. cannot be used as a synchronization medium.
  828. @subsection Submitting a Task
  829. @example
  830. @c @cartouche
  831. void callback_func(void *callback_arg)
  832. @{
  833. printf("Callback function (arg %x)\n", callback_arg);
  834. @}
  835. int main(int argc, char **argv)
  836. @{
  837. /* initialize StarPU */
  838. starpu_init(NULL);
  839. struct starpu_task *task = starpu_task_create();
  840. task->cl = &cl;
  841. float *array[2] = @{1.0f, -1.0f@};
  842. task->cl_arg = &array;
  843. task->cl_arg_size = 2*sizeof(float);
  844. task->callback_func = callback_func;
  845. task->callback_arg = 0x42;
  846. /* starpu_submit_task will be a blocking call */
  847. task->synchronous = 1;
  848. /* submit the task to StarPU */
  849. starpu_submit_task(task);
  850. /* terminate StarPU */
  851. starpu_shutdown();
  852. return 0;
  853. @}
  854. @c @end cartouche
  855. @end example
  856. Before submitting any tasks to StarPU, @code{starpu_init} must be called. The
  857. @code{NULL} argument specifies that we use default configuration. Tasks cannot
  858. be submitted after the termination of StarPU by a call to
  859. @code{starpu_shutdown}.
  860. In the example above, a task structure is allocated by a call to
  861. @code{starpu_task_create}. This function only allocates and fills the
  862. corresponding structure with the default settings (@pxref{starpu_task_create}),
  863. but it does not submit the task to StarPU.
  864. @c not really clear ;)
  865. The ''@code{.cl}'' field is a pointer to the codelet which the task will
  866. execute: in other words, the codelet structure describes which computational
  867. kernel should be offloaded on the different architectures, and the task
  868. structure is a wrapper containing a codelet and the piece of data on which the
  869. codelet should operate.
  870. The optional ''@code{.cl_arg}'' field is a pointer to a buffer (of size
  871. @code{.cl_arg_size}) with some parameters for the kernel
  872. described by the codelet. For instance, if a codelet implements a computational
  873. kernel that multiplies its input vector by a constant, the constant could be
  874. specified by the means of this buffer.
  875. Once a task has been executed, an optional callback function can be called.
  876. While the computational kernel could be offloaded on various architectures, the
  877. callback function is always executed on a CPU. The ''@code{.callback_arg}''
  878. pointer is passed as an argument of the callback. The prototype of a callback
  879. function must be:
  880. @example
  881. void (*callback_function)(void *);
  882. @end example
  883. If the @code{.synchronous} field is non-null, task submission will be
  884. synchronous: the @code{starpu_submit_task} function will not return until the
  885. task was executed. Note that the @code{starpu_shutdown} method does not
  886. guarantee that asynchronous tasks have been executed before it returns.
  887. @node Scaling a Vector
  888. @section Manipulating Data: Scaling a Vector
  889. The previous example has shown how to submit tasks. In this section we show how
  890. StarPU tasks can manipulate data.
  891. Programmers can describe the data layout of their application so that StarPU is
  892. responsible for enforcing data coherency and availability accross the machine.
  893. Instead of handling complex (and non-portable) mechanisms to perform data
  894. movements, programmers only declare which piece of data is accessed and/or
  895. modified by a task, and StarPU makes sure that when a computational kernel
  896. starts somewhere (eg. on a GPU), its data are available locally.
  897. Before submitting those tasks, the programmer first needs to declare the
  898. different pieces of data to StarPU using the @code{starpu_register_*_data}
  899. functions. To ease the development of applications for StarPU, it is possible
  900. to describe multiple types of data layout. A type of data layout is called an
  901. @b{interface}. By default, there are different interfaces available in StarPU:
  902. here we will consider the @b{vector interface}.
  903. The following lines show how to declare an array of @code{n} elements of type
  904. @code{float} using the vector interface:
  905. @example
  906. float tab[n];
  907. starpu_data_handle tab_handle;
  908. starpu_register_vector_data(&tab_handle, 0, tab, n, sizeof(float));
  909. @end example
  910. The first argument, called the @b{data handle}, is an opaque pointer which
  911. designates the array in StarPU. This is also the structure which is used to
  912. describe which data is used by a task.
  913. @c TODO: what is 0 ?
  914. It is possible to construct a StarPU
  915. task that multiplies this vector by a constant factor:
  916. @example
  917. float factor;
  918. struct starpu_task *task = starpu_task_create();
  919. task->cl = &cl;
  920. task->buffers[0].handle = tab_handle;
  921. task->buffers[0].mode = STARPU_RW;
  922. task->cl_arg = &factor;
  923. task->cl_arg_size = sizeof(float);
  924. @end example
  925. Since the factor is constant, it does not need a preliminary declaration, and
  926. can just be passed through the @code{cl_arg} pointer like in the previous
  927. example. The vector parameter is described by its handle.
  928. There are two fields in each element of the @code{buffers} array.
  929. @code{.handle} is the handle of the data, and @code{.mode} specifies how the
  930. kernel will access the data (@code{STARPU_R} for read-only, @code{STARPU_W} for
  931. write-only and @code{STARPU_RW} for read and write access).
  932. The definition of the codelet can be written as follows:
  933. @example
  934. void scal_func(void *buffers[], void *cl_arg)
  935. @{
  936. unsigned i;
  937. float *factor = cl_arg;
  938. struct starpu_vector_interface_s *vector = buffers[0];
  939. /* length of the vector */
  940. unsigned n = vector->nx;
  941. /* local copy of the vector pointer */
  942. float *val = (float *)vector->ptr;
  943. for (i = 0; i < n; i++)
  944. val[i] *= *factor;
  945. @}
  946. starpu_codelet cl = @{
  947. .where = STARPU_CPU,
  948. .cpu_func = scal_func,
  949. .nbuffers = 1
  950. @};
  951. @end example
  952. The second argument of the @code{scal_func} function contains a pointer to the
  953. parameters of the codelet (given in @code{task->cl_arg}), so that we read the
  954. constant factor from this pointer. The first argument is an array that gives
  955. a description of every buffers passed in the @code{task->buffers}@ array. The
  956. size of this array is given by the @code{.nbuffers} field of the codelet
  957. structure. For the sake of generality, this array contains pointers to the
  958. different interfaces describing each buffer. In the case of the @b{vector
  959. interface}, the location of the vector (resp. its length) is accessible in the
  960. @code{ptr} (resp. @code{nx}) of this array. Since the vector is accessed in a
  961. read-write fashion, any modification will automatically affect future accesses
  962. to that vector made by other tasks.
  963. @node Scaling a Vector (hybrid)
  964. @section Vector Scaling on an Hybrid CPU/GPU Machine
  965. Contrary to the previous examples, the task submitted in the example may not
  966. only be executed by the CPUs, but also by a CUDA device.
  967. TODO
  968. @c ---------------------------------------------------------------------
  969. @c Advanced Topics
  970. @c ---------------------------------------------------------------------
  971. @node Advanced Topics
  972. @chapter Advanced Topics
  973. @bye