using.texi 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 Institut National de Recherche en Informatique et Automatique
  6. @c See the file starpu.texi for copying conditions.
  7. @menu
  8. * Setting flags for compiling::
  9. * Running a basic StarPU application::
  10. * Kernel threads started by StarPU::
  11. * Enabling OpenCL::
  12. @end menu
  13. @node Setting flags for compiling
  14. @section Setting flags for compiling, linking and running applications
  15. StarPU provides a pkg-config executable to obtain relevant compiler
  16. and linker flags.
  17. Compiling and linking an application against StarPU may require to use
  18. specific flags or libraries (for instance @code{CUDA} or @code{libspe2}).
  19. To this end, it is possible to use the @code{pkg-config} tool.
  20. If StarPU was not installed at some standard location, the path of StarPU's
  21. library must be specified in the @code{PKG_CONFIG_PATH} environment variable so
  22. that @code{pkg-config} can find it. For example if StarPU was installed in
  23. @code{$prefix_dir}:
  24. @example
  25. $ PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$prefix_dir/lib/pkgconfig
  26. @end example
  27. The flags required to compile or link against StarPU are then
  28. accessible with the following commands@footnote{It is still possible to use the API
  29. provided in the version 0.9 of StarPU by calling @code{pkg-config}
  30. with the @code{libstarpu} package. Similar packages are provided for
  31. @code{libstarpumpi} and @code{libstarpufft}.}:
  32. @example
  33. $ pkg-config --cflags starpu-1.0 # options for the compiler
  34. $ pkg-config --libs starpu-1.0 # options for the linker
  35. @end example
  36. Make sure that @code{pkg-config --libs starpu-1.0} actually produces some output
  37. before going further: @code{PKG_CONFIG_PATH} has to point to the place where
  38. @code{starpu-1.0.pc} was installed during @code{make install}.
  39. Also pass the @code{--static} option if the application is to be
  40. linked statically.
  41. It is also necessary to set the variable @code{LD_LIBRARY_PATH} to
  42. locate dynamic libraries at runtime.
  43. @example
  44. $ LD_LIBRARY_PATH=$prefix_dir/lib:$LD_LIBRARY_PATH
  45. @end example
  46. When using a Makefile, the following lines can be added to set the
  47. options for the compiler and the linker:
  48. @cartouche
  49. @example
  50. CFLAGS += $$(pkg-config --cflags starpu-1.0)
  51. LDFLAGS += $$(pkg-config --libs starpu-1.0)
  52. @end example
  53. @end cartouche
  54. @node Running a basic StarPU application
  55. @section Running a basic StarPU application
  56. Basic examples using StarPU are built in the directory
  57. @code{examples/basic_examples/} (and installed in
  58. @code{$prefix_dir/lib/starpu/examples/}). You can for example run the example
  59. @code{vector_scal}.
  60. @example
  61. $ ./examples/basic_examples/vector_scal
  62. BEFORE: First element was 1.000000
  63. AFTER: First element is 3.140000
  64. @end example
  65. When StarPU is used for the first time, the directory
  66. @code{$STARPU_HOME/.starpu/} is created, performance models will be stored in
  67. that directory (@code{STARPU_HOME} defaults to @code{$HOME}, or @code{$USERPROFILE
  68. } in windows environments).
  69. Please note that buses are benchmarked when StarPU is launched for the
  70. first time. This may take a few minutes, or less if @code{hwloc} is
  71. installed. This step is done only once per user and per machine.
  72. @node Kernel threads started by StarPU
  73. @section Kernel threads started by StarPU
  74. StarPU automatically binds one thread per CPU core. It does not use
  75. SMT/hyperthreading because kernels are usually already optimized for using a
  76. full core, and using hyperthreading would make kernel calibration rather random.
  77. Since driving GPUs is a CPU-consuming task, StarPU dedicates one core per GPU
  78. While StarPU tasks are executing, the application is not supposed to do
  79. computations in the threads it starts itself, tasks should be used instead.
  80. TODO: add a StarPU function to bind an application thread (e.g. the main thread)
  81. to a dedicated core (and thus disable the corresponding StarPU CPU worker).
  82. @node Enabling OpenCL
  83. @section Enabling OpenCL
  84. When both CUDA and OpenCL drivers are enabled, StarPU will launch an
  85. OpenCL worker for NVIDIA GPUs only if CUDA is not already running on them.
  86. This design choice was necessary as OpenCL and CUDA can not run at the
  87. same time on the same NVIDIA GPU, as there is currently no interoperability
  88. between them.
  89. To enable OpenCL, you need either to disable CUDA when configuring StarPU:
  90. @example
  91. $ ./configure --disable-cuda
  92. @end example
  93. or when running applications:
  94. @example
  95. $ STARPU_NCUDA=0 ./application
  96. @end example
  97. OpenCL will automatically be started on any device not yet used by
  98. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  99. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  100. so:
  101. @example
  102. $ STARPU_NCUDA=2 ./application
  103. @end example