installing.texi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. @c -*-texinfo-*-
  2. @c This file is part of the StarPU Handbook.
  3. @c Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. @c Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. @c Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  6. @c See the file starpu.texi for copying conditions.
  7. @menu
  8. * Installing a Binary Package::
  9. * Installing from Source::
  10. * Setting up Your Own Code::
  11. * Benchmarking StarPU::
  12. @end menu
  13. @node Installing a Binary Package
  14. @section Installing a Binary Package
  15. One of the StarPU developers being a Debian Developer, the packages
  16. are well integrated and very uptodate. To see which packages are
  17. available, simply type:
  18. @example
  19. $ apt-cache search starpu
  20. @end example
  21. To install what you need, type:
  22. @example
  23. $ sudo apt-get install libstarpu-1.0 libstarpu-dev
  24. @end example
  25. @node Installing from Source
  26. @section Installing from Source
  27. StarPU can be built and installed by the standard means of the GNU
  28. autotools. The following chapter is intended to briefly remind how these tools
  29. can be used to install StarPU.
  30. @menu
  31. * Optional Dependencies::
  32. * Getting Sources::
  33. * Configuring StarPU::
  34. * Building StarPU::
  35. * Installing StarPU::
  36. @end menu
  37. @node Optional Dependencies
  38. @subsection Optional Dependencies
  39. The @url{http://www.open-mpi.org/software/hwloc, @code{hwloc} topology
  40. discovery library} is not mandatory to use StarPU but strongly
  41. recommended. It allows for topology aware scheduling, which improves
  42. performance. @code{hwloc} is available in major free operating system
  43. distributions, and for most operating systems.
  44. If @code{hwloc} is not available on your system, the option
  45. @code{--without-hwloc} should be explicitely given when calling the
  46. @code{configure} script. If @code{hwloc} is installed with a @code{pkg-config} file,
  47. no option is required, it will be detected automatically, otherwise
  48. @code{with-hwloc=prefix} should be used to specify the location
  49. of @code{hwloc}.
  50. @node Getting Sources
  51. @subsection Getting Sources
  52. StarPU's sources can be obtained from the
  53. @url{http://runtime.bordeaux.inria.fr/StarPU/files/,download page} of
  54. the StarPU website.
  55. All releases and the development tree of StarPU are freely available
  56. on INRIA's gforge under the LGPL license. Some releases are available
  57. under the BSD license.
  58. The latest release can be downloaded from the
  59. @url{http://gforge.inria.fr/frs/?group_id=1570,INRIA's gforge} or
  60. directly from the @url{http://runtime.bordeaux.inria.fr/StarPU/files/,StarPU download page}.
  61. The latest nightly snapshot can be downloaded from the @url{http://starpu.gforge.inria.fr/testing/,StarPU gforge website}.
  62. @example
  63. $ wget http://starpu.gforge.inria.fr/testing/starpu-nightly-latest.tar.gz
  64. @end example
  65. And finally, current development version is also accessible via svn.
  66. It should be used only if you need the very latest changes (i.e. less
  67. than a day!)@footnote{The client side of the software Subversion can
  68. be obtained from @url{http://subversion.tigris.org}. If you
  69. are running on Windows, you will probably prefer to use
  70. @url{http://tortoisesvn.tigris.org/, TortoiseSVN}.}.
  71. @example
  72. svn checkout svn://scm.gforge.inria.fr/svn/starpu/trunk StarPU
  73. @end example
  74. @node Configuring StarPU
  75. @subsection Configuring StarPU
  76. Running @code{autogen.sh} is not necessary when using the tarball
  77. releases of StarPU. If you are using the source code from the svn
  78. repository, you first need to generate the configure scripts and the
  79. Makefiles. This requires the availability of @code{autoconf},
  80. @code{automake} >= 2.60, and @code{makeinfo}.
  81. @example
  82. $ ./autogen.sh
  83. @end example
  84. You then need to configure StarPU. Details about options that are
  85. useful to give to @code{./configure} are given in @ref{Compilation
  86. configuration}.
  87. @example
  88. $ ./configure
  89. @end example
  90. If @code{configure} does not detect some software or produces errors, please
  91. make sure to post the content of @code{config.log} when reporting the issue.
  92. By default, the files produced during the compilation are placed in
  93. the source directory. As the compilation generates a lot of files, it
  94. is advised to to put them all in a separate directory. It is then
  95. easier to cleanup, and this allows to compile several configurations
  96. out of the same source tree. For that, simply enter the directory
  97. where you want the compilation to produce its files, and invoke the
  98. @code{configure} script located in the StarPU source directory.
  99. @example
  100. $ mkdir build
  101. $ cd build
  102. $ ../configure
  103. @end example
  104. @node Building StarPU
  105. @subsection Building StarPU
  106. @example
  107. $ make
  108. @end example
  109. Once everything is built, you may want to test the result. An
  110. extensive set of regression tests is provided with StarPU. Running the
  111. tests is done by calling @code{make check}. These tests are run every night
  112. and the result from the main profile is publicly
  113. @url{http://starpu.gforge.inria.fr/testing/,available}.
  114. @example
  115. $ make check
  116. @end example
  117. @node Installing StarPU
  118. @subsection Installing StarPU
  119. In order to install StarPU at the location that was specified during
  120. configuration:
  121. @example
  122. $ make install
  123. @end example
  124. Libtool interface versioning information are included in
  125. libraries names (libstarpu-1.0.so, libstarpumpi-1.0.so and
  126. libstarpufft-1.0.so).
  127. @node Setting up Your Own Code
  128. @section Setting up Your Own Code
  129. @menu
  130. * Setting Flags for Compiling::
  131. * Running a Basic StarPU Application::
  132. * Kernel Threads Started by StarPU::
  133. * Enabling OpenCL::
  134. @end menu
  135. @node Setting Flags for Compiling
  136. @subsection Setting Flags for Compiling, Linking and Running Applications
  137. StarPU provides a pkg-config executable to obtain relevant compiler
  138. and linker flags.
  139. Compiling and linking an application against StarPU may require to use
  140. specific flags or libraries (for instance @code{CUDA} or @code{libspe2}).
  141. To this end, it is possible to use the @code{pkg-config} tool.
  142. If StarPU was not installed at some standard location, the path of StarPU's
  143. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  144. that @code{pkg-config} can find it. For example if StarPU was installed in
  145. @code{$prefix_dir}:
  146. @example
  147. $ PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$prefix_dir/lib/pkgconfig
  148. @end example
  149. The flags required to compile or link against StarPU are then
  150. accessible with the following commands@footnote{It is still possible to use the API
  151. provided in the version 0.9 of StarPU by calling @code{pkg-config}
  152. with the @code{libstarpu} package. Similar packages are provided for
  153. @code{libstarpumpi} and @code{libstarpufft}.}:
  154. @example
  155. $ pkg-config --cflags starpu-1.1 # options for the compiler
  156. $ pkg-config --libs starpu-1.1 # options for the linker
  157. @end example
  158. Make sure that @code{pkg-config --libs starpu-1.1} actually produces some output
  159. before going further: @code{PKG_CONFIG_PATH} has to point to the place where
  160. @code{starpu-1.1.pc} was installed during @code{make install}.
  161. Also pass the @code{--static} option if the application is to be
  162. linked statically.
  163. It is also necessary to set the variable @code{LD_LIBRARY_PATH} to
  164. locate dynamic libraries at runtime.
  165. @example
  166. $ LD_LIBRARY_PATH=$prefix_dir/lib:$LD_LIBRARY_PATH
  167. @end example
  168. When using a Makefile, the following lines can be added to set the
  169. options for the compiler and the linker:
  170. @cartouche
  171. @example
  172. CFLAGS += $$(pkg-config --cflags starpu-1.1)
  173. LDFLAGS += $$(pkg-config --libs starpu-1.1)
  174. @end example
  175. @end cartouche
  176. @node Running a Basic StarPU Application
  177. @subsection Running a Basic StarPU Application
  178. Basic examples using StarPU are built in the directory
  179. @code{examples/basic_examples/} (and installed in
  180. @code{$prefix_dir/lib/starpu/examples/}). You can for example run the example
  181. @code{vector_scal}.
  182. @example
  183. $ ./examples/basic_examples/vector_scal
  184. BEFORE: First element was 1.000000
  185. AFTER: First element is 3.140000
  186. @end example
  187. When StarPU is used for the first time, the directory
  188. @code{$STARPU_HOME/.starpu/} is created, performance models will be stored in
  189. that directory (@pxref{STARPU_HOME}).
  190. Please note that buses are benchmarked when StarPU is launched for the
  191. first time. This may take a few minutes, or less if @code{hwloc} is
  192. installed. This step is done only once per user and per machine.
  193. @node Kernel Threads Started by StarPU
  194. @subsection Kernel Threads Started by StarPU
  195. StarPU automatically binds one thread per CPU core. It does not use
  196. SMT/hyperthreading because kernels are usually already optimized for using a
  197. full core, and using hyperthreading would make kernel calibration rather random.
  198. Since driving GPUs is a CPU-consuming task, StarPU dedicates one core per GPU
  199. While StarPU tasks are executing, the application is not supposed to do
  200. computations in the threads it starts itself, tasks should be used instead.
  201. TODO: add a StarPU function to bind an application thread (e.g. the main thread)
  202. to a dedicated core (and thus disable the corresponding StarPU CPU worker).
  203. @node Enabling OpenCL
  204. @subsection Enabling OpenCL
  205. When both CUDA and OpenCL drivers are enabled, StarPU will launch an
  206. OpenCL worker for NVIDIA GPUs only if CUDA is not already running on them.
  207. This design choice was necessary as OpenCL and CUDA can not run at the
  208. same time on the same NVIDIA GPU, as there is currently no interoperability
  209. between them.
  210. To enable OpenCL, you need either to disable CUDA when configuring StarPU:
  211. @example
  212. $ ./configure --disable-cuda
  213. @end example
  214. or when running applications:
  215. @example
  216. $ STARPU_NCUDA=0 ./application
  217. @end example
  218. OpenCL will automatically be started on any device not yet used by
  219. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  220. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  221. so:
  222. @example
  223. $ STARPU_NCUDA=2 ./application
  224. @end example
  225. @node Benchmarking StarPU
  226. @section Benchmarking StarPU
  227. Some interesting benchmarks are installed among examples in
  228. @code{$prefix_dir/lib/starpu/examples/}. Make sure to try various
  229. schedulers, for instance STARPU_SCHED=dmda
  230. @menu
  231. * Task size overhead::
  232. * Data transfer latency::
  233. * Gemm::
  234. * Cholesky::
  235. * LU::
  236. @end menu
  237. @node Task size overhead
  238. @subsection Task size overhead
  239. This benchmark gives a glimpse into how big a size should be for StarPU overhead
  240. to be low enough. Run @code{tasks_size_overhead.sh}, it will generate a plot
  241. of the speedup of tasks of various sizes, depending on the number of CPUs being
  242. used.
  243. @node Data transfer latency
  244. @subsection Data transfer latency
  245. @code{local_pingpong} performs a ping-pong between the first two CUDA nodes, and
  246. prints the measured latency.
  247. @node Gemm
  248. @subsection Matrix-matrix multiplication
  249. @code{sgemm} and @code{dgemm} perform a blocked matrix-matrix
  250. multiplication using BLAS and cuBLAS. They output the obtained GFlops.
  251. @node Cholesky
  252. @subsection Cholesky factorization
  253. @code{cholesky*} perform a Cholesky factorization (single precision). They use different dependency primitives.
  254. @node LU
  255. @subsection LU factorization
  256. @code{lu*} perform an LU factorization. They use different dependency primitives.