installing.texi 9.4 KB

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