101_building.doxy 13 KB

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