01building.doxy 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014 CNRS
  5. * Copyright (C) 2011, 2012 INRIA
  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 for example:
  17. \verbatim
  18. $ sudo apt-get install libstarpu-1.3 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 <c>hwloc</c> (http://www.open-mpi.org/software/hwloc) topology
  26. discovery library 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 its location.
  35. \subsection GettingSources Getting Sources
  36. StarPU's sources can be obtained from the download page of
  37. the StarPU website (http://runtime.bordeaux.inria.fr/StarPU/files/).
  38. All releases and the development tree of StarPU are freely available
  39. on INRIA's gforge under the LGPL license. Some releases are available
  40. under the BSD license.
  41. The latest release can be downloaded from the INRIA's gforge (http://gforge.inria.fr/frs/?group_id=1570) or
  42. directly from the StarPU download page (http://runtime.bordeaux.inria.fr/StarPU/files/).
  43. The latest nightly snapshot can be downloaded from the StarPU gforge website (http://starpu.gforge.inria.fr/testing/).
  44. \verbatim
  45. $ wget http://starpu.gforge.inria.fr/testing/starpu-nightly-latest.tar.gz
  46. \endverbatim
  47. And finally, current development version is also accessible via svn.
  48. It should be used only if you need the very latest changes (i.e. less
  49. than a day!). Note that the client side of the software Subversion can
  50. be obtained from http://subversion.tigris.org. If you
  51. are running on Windows, you will probably prefer to use TortoiseSVN (http://tortoisesvn.tigris.org/).
  52. \verbatim
  53. $ svn checkout svn://scm.gforge.inria.fr/svn/starpu/trunk StarPU
  54. \endverbatim
  55. \subsection ConfiguringStarPU Configuring StarPU
  56. Running <c>autogen.sh</c> is not necessary when using the tarball
  57. releases of StarPU. If you are using the source code from the svn
  58. repository, you first need to generate the configure scripts and the
  59. Makefiles. This requires the availability of <c>autoconf</c> and
  60. <c>automake</c> >= 2.60.
  61. \verbatim
  62. $ ./autogen.sh
  63. \endverbatim
  64. You then need to configure StarPU. Details about options that are
  65. useful to give to <c>./configure</c> are given in \ref CompilationConfiguration.
  66. \verbatim
  67. $ ./configure
  68. \endverbatim
  69. If <c>configure</c> does not detect some software or produces errors, please
  70. make sure to post the content of <c>config.log</c> when reporting the issue.
  71. By default, the files produced during the compilation are placed in
  72. the source directory. As the compilation generates a lot of files, it
  73. is advised to put them all in a separate directory. It is then
  74. easier to cleanup, and this allows to compile several configurations
  75. out of the same source tree. For that, simply enter the directory
  76. where you want the compilation to produce its files, and invoke the
  77. <c>configure</c> script located in the StarPU source directory.
  78. \verbatim
  79. $ mkdir build
  80. $ cd build
  81. $ ../configure
  82. \endverbatim
  83. By default, StarPU will be installed in <c>/usr/local/bin</c>,
  84. <c>/usr/local/lib</c>, etc. You can specify an installation prefix
  85. other than <c>/usr/local</c> using the option <c>--prefix</c>, for
  86. instance:
  87. \verbatim
  88. $ ../configure --prefix=$HOME/starpu
  89. \endverbatim
  90. \subsection BuildingStarPU Building StarPU
  91. \verbatim
  92. $ make
  93. \endverbatim
  94. Once everything is built, you may want to test the result. An
  95. extensive set of regression tests is provided with StarPU. Running the
  96. tests is done by calling <c>make check</c>. These tests are run every night
  97. and the result from the main profile is publicly available (http://starpu.gforge.inria.fr/testing/).
  98. \verbatim
  99. $ make check
  100. \endverbatim
  101. \subsection InstallingStarPU Installing StarPU
  102. In order to install StarPU at the location that was specified during
  103. configuration:
  104. \verbatim
  105. $ make install
  106. \endverbatim
  107. Libtool interface versioning information are included in
  108. libraries names (<c>libstarpu-1.3.so</c>, <c>libstarpumpi-1.3.so</c> and
  109. <c>libstarpufft-1.3.so</c>).
  110. \section SettingUpYourOwnCode Setting up Your Own Code
  111. \subsection SettingFlagsForCompilingLinkingAndRunningApplications Setting Flags for Compiling, Linking and Running Applications
  112. StarPU provides a <c>pkg-config</c> executable to obtain relevant compiler
  113. and linker flags. As compiling and linking an application against
  114. StarPU may require to use specific flags or libraries (for instance
  115. <c>CUDA</c> or <c>libspe2</c>).
  116. If StarPU was not installed at some standard location, the path of StarPU's
  117. library must be specified in the environment variable <c>PKG_CONFIG_PATH</c> so
  118. that <c>pkg-config</c> can find it. For example if StarPU was installed in
  119. <c>$STARPU_PATH</c>:
  120. \verbatim
  121. $ PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$STARPU_PATH/lib/pkgconfig
  122. \endverbatim
  123. The flags required to compile or link against StarPU are then
  124. accessible with the following commands:
  125. \verbatim
  126. $ pkg-config --cflags starpu-1.3 # options for the compiler
  127. $ pkg-config --libs starpu-1.3 # options for the linker
  128. \endverbatim
  129. Note that it is still possible to use the API provided in the version
  130. 1.0 of StarPU by calling <c>pkg-config</c> with the <c>starpu-1.0</c> package.
  131. Similar packages are provided for <c>starpumpi-1.0</c> and <c>starpufft-1.0</c>.
  132. It is also possible to use the API provided in the version
  133. 0.9 of StarPU by calling <c>pkg-config</c> with the <c>libstarpu</c> package.
  134. Similar packages are provided for <c>libstarpumpi</c> and <c>libstarpufft</c>.
  135. Make sure that <c>pkg-config --libs starpu-1.3</c> actually produces some output
  136. before going further: <c>PKG_CONFIG_PATH</c> has to point to the place where
  137. <c>starpu-1.3.pc</c> was installed during <c>make install</c>.
  138. Also pass the option <c>--static</c> if the application is to be
  139. linked statically.
  140. It is also necessary to set the environment variable <c>LD_LIBRARY_PATH</c> to
  141. locate dynamic libraries at runtime.
  142. \verbatim
  143. $ LD_LIBRARY_PATH=$STARPU_PATH/lib:$LD_LIBRARY_PATH
  144. \endverbatim
  145. When using a Makefile, the following lines can be added to set the
  146. options for the compiler and the linker:
  147. \verbatim
  148. CFLAGS += $$(pkg-config --cflags starpu-1.3)
  149. LDFLAGS += $$(pkg-config --libs starpu-1.3)
  150. \endverbatim
  151. \subsection RunningABasicStarPUApplication Running a Basic StarPU Application
  152. Basic examples using StarPU are built in the directory
  153. <c>examples/basic_examples/</c> (and installed in
  154. <c>$STARPU_PATH/lib/starpu/examples/</c>). You can for example run the example
  155. <c>vector_scal</c>.
  156. \verbatim
  157. $ ./examples/basic_examples/vector_scal
  158. BEFORE: First element was 1.000000
  159. AFTER: First element is 3.140000
  160. \endverbatim
  161. When StarPU is used for the first time, the directory
  162. <c>$STARPU_HOME/.starpu/</c> is created, performance models will be stored in
  163. that directory (\ref STARPU_HOME).
  164. Please note that buses are benchmarked when StarPU is launched for the
  165. first time. This may take a few minutes, or less if <c>hwloc</c> is
  166. installed. This step is done only once per user and per machine.
  167. \subsection RunningABasicStarPUApplicationOnMicrosoft Running a Basic StarPU Application on Microsoft Visual C
  168. Batch files are provided to run StarPU applications under Microsoft
  169. Visual C. They are installed in <c>$STARPU_PATH/bin/msvc</c>.
  170. To execute a StarPU application, you first need to set the environment
  171. variable <c>STARPU_PATH</c>.
  172. \verbatim
  173. c:\....> cd c:\cygwin\home\ci\starpu\
  174. c:\....> set STARPU_PATH=c:\cygwin\home\ci\starpu\
  175. c:\....> cd bin\msvc
  176. c:\....> starpu_open.bat starpu_simple.c
  177. \endverbatim
  178. The batch script will run Microsoft Visual C with a basic project file
  179. to run the given application.
  180. The batch script <c>starpu_clean.bat</c> can be used to delete all
  181. compilation generated files.
  182. The batch script <c>starpu_exec.bat</c> can be used to compile and execute a
  183. StarPU application from the command prompt.
  184. \verbatim
  185. c:\....> cd c:\cygwin\home\ci\starpu\
  186. c:\....> set STARPU_PATH=c:\cygwin\home\ci\starpu\
  187. c:\....> cd bin\msvc
  188. c:\....> starpu_exec.bat ..\..\..\..\examples\basic_examples\hello_world.c
  189. \endverbatim
  190. \verbatim
  191. MSVC StarPU Execution
  192. ...
  193. /out:hello_world.exe
  194. ...
  195. Hello world (params = {1, 2.00000})
  196. Callback function got argument 0000042
  197. c:\....>
  198. \endverbatim
  199. \subsection KernelThreadsStartedByStarPU Kernel Threads Started by StarPU
  200. StarPU automatically binds one thread per CPU core. It does not use
  201. SMT/hyperthreading because kernels are usually already optimized for using a
  202. full core, and using hyperthreading would make kernel calibration rather random.
  203. Since driving GPUs is a CPU-consuming task, StarPU dedicates one core
  204. per GPU.
  205. While StarPU tasks are executing, the application is not supposed to do
  206. computations in the threads it starts itself, tasks should be used instead.
  207. TODO: add a StarPU function to bind an application thread (e.g. the main thread)
  208. to a dedicated core (and thus disable the corresponding StarPU CPU worker).
  209. \subsection EnablingOpenCL Enabling OpenCL
  210. When both CUDA and OpenCL drivers are enabled, StarPU will launch an
  211. OpenCL worker for NVIDIA GPUs only if CUDA is not already running on them.
  212. This design choice was necessary as OpenCL and CUDA can not run at the
  213. same time on the same NVIDIA GPU, as there is currently no interoperability
  214. between them.
  215. To enable OpenCL, you need either to disable CUDA when configuring StarPU:
  216. \verbatim
  217. $ ./configure --disable-cuda
  218. \endverbatim
  219. or when running applications:
  220. \verbatim
  221. $ STARPU_NCUDA=0 ./application
  222. \endverbatim
  223. OpenCL will automatically be started on any device not yet used by
  224. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  225. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  226. so:
  227. \verbatim
  228. $ STARPU_NCUDA=2 ./application
  229. \endverbatim
  230. \section BenchmarkingStarPU Benchmarking StarPU
  231. Some interesting benchmarks are installed among examples in
  232. <c>$STARPU_PATH/lib/starpu/examples/</c>. Make sure to try various
  233. schedulers, for instance <c>STARPU_SCHED=dmda</c>.
  234. \subsection TaskSizeOverhead Task Size Overhead
  235. This benchmark gives a glimpse into how long a task should be (in µs) for StarPU overhead
  236. to be low enough to keep efficiency. Running
  237. <c>tasks_size_overhead.sh</c> generates a plot
  238. of the speedup of tasks of various sizes, depending on the number of CPUs being
  239. used.
  240. \image html tasks_size_overhead.png
  241. \image latex tasks_size_overhead.eps "" width=\textwidth
  242. \subsection DataTransferLatency Data Transfer Latency
  243. <c>local_pingpong</c> performs a ping-pong between the first two CUDA nodes, and
  244. prints the measured latency.
  245. \subsection MatrixMatrixMultiplication Matrix-Matrix Multiplication
  246. <c>sgemm</c> and <c>dgemm</c> perform a blocked matrix-matrix
  247. multiplication using BLAS and cuBLAS. They output the obtained GFlops.
  248. \subsection CholeskyFactorization Cholesky Factorization
  249. <c>cholesky_*</c> perform a Cholesky factorization (single precision). They use different dependency primitives.
  250. \subsection LUFactorization LU Factorization
  251. <c>lu_*</c> perform an LU factorization. They use different dependency primitives.
  252. \subsection SimulatedBenchmarks Simulated benchmarks
  253. It can also be convenient to try simulated benchmarks, if you want to give a try
  254. at CPU-GPU scheduling without actually having a GPU at hand. This can be done by
  255. using the simgrid version of StarPU: first install the simgrid simulator from
  256. http://simgrid.gforge.inria.fr/ , then configure StarPU with \ref enable-simgrid "--enable-simgrid"
  257. and rebuild and install it, and then you can simulate the performance for a
  258. few virtualized systems shipped along StarPU: attila, mirage, idgraf, and sirocco.
  259. For instance:
  260. \verbatim
  261. $ export STARPU_PERF_MODEL_DIR=$STARPU_PATH/share/starpu/perfmodels/sampling
  262. $ export STARPU_HOSTNAME=attila
  263. $ $STARPU_PATH/lib/starpu/examples/cholesky_implicit -size $((960*20)) -nblocks 20
  264. \endverbatim
  265. Will show the performance of the cholesky factorization with the attila
  266. system. It will be interesting to try with different matrix sizes and
  267. schedulers.
  268. Performance models are available for cholesky_*, lu_*, *gemm, with block sizes
  269. 320, 640, or 960 (plus 1440 for sirocco), and for stencil with block size 128x128x128, 192x192x192, and
  270. 256x256x256.
  271. */