starpu.texi 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. * StarPU API:: The API to use StarPU
  29. * Basic Examples:: Basic examples of the use of StarPU
  30. @end menu
  31. @c ---------------------------------------------------------------------
  32. @c Introduction to StarPU
  33. @c ---------------------------------------------------------------------
  34. @node Introduction
  35. @chapter Introduction to StarPU
  36. @c ---------------------------------------------------------------------
  37. @c Installing StarPU
  38. @c ---------------------------------------------------------------------
  39. @node Installing StarPU
  40. @chapter Installing StarPU
  41. StarPU can be built and install by the standard means of the GNU autotools. The
  42. following chapter is intended to briefly remind how these tools can be used to
  43. install StarPU.
  44. @section Configuring StarPU
  45. @subsection Generating Makefiles and configuration scripts
  46. This step is not necessary when using the tarball releases of StarPU. If you
  47. are using the source code from the svn repository, you first need to generate
  48. the configure scripts and the Makefiles.
  49. @example
  50. $ autoreconf -i
  51. @end example
  52. @subsection Configuring StarPU
  53. @example
  54. $ configure
  55. @end example
  56. @c TODO enumerate the list of interesting options
  57. @section Building and Installing StarPU
  58. @subsection Building
  59. @example
  60. $ make
  61. @end example
  62. @subsection Sanity Checks
  63. In order to make sure that StarPU is working properly on the system, it is also
  64. possible to run a test suite.
  65. @example
  66. $ make check
  67. @end example
  68. @subsection Installing
  69. In order to install StarPU at the location that was specified during
  70. configuration:
  71. @example
  72. $ make install
  73. @end example
  74. @subsection pkg-config configuration
  75. It is possible that compiling and linking an application against StarPU
  76. requires to use specific flags or libraries (for instance @code{CUDA} or
  77. @code{libspe2}). Therefore, it is possible to use the @code{pkg-config} tool.
  78. If StarPU was not installed at some standard location, the path of StarPU's
  79. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  80. that @code{pkg-config} can find it. So if StarPU was installed in
  81. @code{$(prefix_dir)}:
  82. @example
  83. $ PKG_CONFIG_PATH = @{PKG_CONFIG_PATH@}:$(prefix_dir)/lib/
  84. @end example
  85. The flags required to compiled or linked against StarPU are then
  86. accessible with the following commands:
  87. @example
  88. $ pkg-config --cflags libstarpu # options for the compiler
  89. $ pkg-config --libs libstarpu # options for the linker
  90. @end example
  91. @c ---------------------------------------------------------------------
  92. @c StarPU API
  93. @c ---------------------------------------------------------------------
  94. @node StarPU API
  95. @chapter StarPU API
  96. @menu
  97. * Initialization and Termination:: Initialization and Termination methods
  98. * Data Library:: Methods to manipulate data
  99. * Codelets and Tasks:: Methods to construct tasks
  100. @end menu
  101. @node Initialization and Termination
  102. @section Initialization and Termination
  103. @menu
  104. * starpu_init:: Initialize StarPU
  105. * starpu_shutdown:: Terminate StarPU
  106. @end menu
  107. @node starpu_init
  108. @subsection @code{starpu_init} -- Initialize StarPU
  109. @table @asis
  110. @item @emph{Description}:
  111. This is StarPU initialization method, which must be called prior to any other
  112. StarPU call. It is possible to specify StarPU's configuration (eg. scheduling
  113. policy, number of cores, ...) by passing a non-null argument. Default
  114. configuration is used if the passed argument is @code{NULL}.
  115. @item @emph{Prototype}:
  116. @code{void starpu_init(struct starpu_conf *conf);}
  117. @end table
  118. @node starpu_shutdown
  119. @subsection @code{starpu_shutdown} -- Terminate StarPU
  120. @table @asis
  121. @item @emph{Description}:
  122. This is StarPU termination method. It must be called at the end of the
  123. application: statistics and other post-mortem debugging information are not
  124. garanteed to be available until this method has been called.
  125. @item @emph{Prototype}:
  126. @code{void starpu_shutdown(void);}
  127. @end table
  128. @node Data Library
  129. @section Data Library
  130. @node Codelets and Tasks
  131. @section Codelets and Tasks
  132. @section Extensions
  133. @subsection CUDA extensions
  134. @subsection Cell extensions
  135. @c ---------------------------------------------------------------------
  136. @c Basic Examples
  137. @c ---------------------------------------------------------------------
  138. @node Basic Examples
  139. @chapter Basic Examples
  140. @section Compiling and linking options
  141. The Makefile could for instance contain the following lines to define which
  142. options must be given to the compiler and to the linker:
  143. @example
  144. @cartouche
  145. CFLAGS+=$$(pkg-config --cflags libstarpu)
  146. LIBS+=$$(pkg-config --libs libstarpu)
  147. @end cartouche
  148. @end example
  149. @section Hello World
  150. In this section, we show a simple
  151. @subsection Required Headers
  152. The @code{starpu.h} header should be included in any code using StarPU.
  153. @example
  154. @cartouche
  155. #include <starpu.h>
  156. @end cartouche
  157. @end example
  158. @subsection Defining a Codelet
  159. @example
  160. @cartouche
  161. void cpu_func(starpu_data_interface_t *buffers, void *func_arg)
  162. @{
  163. float *array = func_arg;
  164. printf("Hello world (array = @{%f, %f@} )\n", array[0], array[1]);
  165. @}
  166. starpu_codelet cl =
  167. @{
  168. .where = CORE,
  169. .core_func = cpu_func,
  170. .nbuffers = 0
  171. @};
  172. @end cartouche
  173. @end example
  174. The ''@code{.nbuffers}'' field specifies the number of data buffers that are
  175. manipulated by the codelet: here the codelet does not access or modify any data
  176. that is controlled by our data management library. Note that the argument
  177. passed to the codelet (the ''@code{.cl_arg}'' field of the @code{starpu_task}
  178. structure) does not count as a buffer since it is not managed by our data
  179. management library.
  180. @c TODO need a crossref to the proper description of "where" see bla for more ...
  181. We create a codelet which may only execute on the CPUs. The ''@code{.where}''
  182. field is a bitmask that defines where the codelet may be executed. Here, the
  183. @code{CORE} value means that only CPUs can execute this codelet.
  184. When a CPU core executes a codelet, it calls the @code{.core_func} function,
  185. which @emph{must} have the following prototype:
  186. @code{void (*core_func)(starpu_data_interface_t *, void *)}
  187. In this example, we can ignore the first argument of this function gives a
  188. description of the input and output buffers (eg. the size and the location of
  189. the matrices). The second argument is a pointer to a buffer passed as an
  190. argument to the codelet by the means of the ''@code{.cl_arg}'' field of the
  191. @code{starpu_task} structure. Be aware that this may be a pointer to a
  192. @emph{copy} of the actual buffer, and not the pointer given by the programmer:
  193. if the codelet modifies this buffer, there is no garantee that the initial
  194. buffer will be modified as well: this for instance implies that the buffer
  195. cannot be used as a synchronization medium.
  196. @subsection Submitting a Task
  197. @example
  198. @cartouche
  199. void callback_func(void *callback_arg)
  200. @{
  201. printf("Callback function (arg %x)\n", callback_arg);
  202. @}
  203. int main(int argc, char **argv)
  204. @{
  205. /* initialize StarPU */
  206. starpu_init(NULL);
  207. struct starpu_task *task = starpu_task_create();
  208. task->cl = &cl;
  209. float array[2] = {1.0f, -1.0f};
  210. task->cl_arg = &array;
  211. task->cl_arg_size = 2*sizeof(float);
  212. task->callback_func = callback_func;
  213. task->callback_arg = 0x42;
  214. /* starpu_submit_task will be a blocking call */
  215. task->synchronous = 1;
  216. /* submit the task to StarPU */
  217. starpu_submit_task(task);
  218. /* terminate StarPU */
  219. starpu_shutdown();
  220. return 0;
  221. @}
  222. @end cartouche
  223. @end example
  224. @bye