01building.doxy 11 KB

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