using.texi 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 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. @node Using StarPU
  8. @chapter Using StarPU
  9. @menu
  10. * Setting flags for compiling and linking applications::
  11. * Running a basic StarPU application::
  12. * Kernel threads started by StarPU::
  13. * Enabling OpenCL::
  14. @end menu
  15. @node Setting flags for compiling and linking applications
  16. @section Setting flags for compiling and linking applications
  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:
  29. @example
  30. % pkg-config --cflags libstarpu # options for the compiler
  31. % pkg-config --libs libstarpu # options for the linker
  32. @end example
  33. @node Running a basic StarPU application
  34. @section Running a basic StarPU application
  35. Basic examples using StarPU are built in the directory
  36. @code{examples/basic_examples/} (and installed in
  37. @code{$prefix_dir/lib/starpu/examples/}). You can for example run the example
  38. @code{vector_scal}.
  39. @example
  40. % ./examples/basic_examples/vector_scal
  41. BEFORE : First element was 1.000000
  42. AFTER First element is 3.140000
  43. %
  44. @end example
  45. When StarPU is used for the first time, the directory
  46. @code{$HOME/.starpu/} is created, performance models will be stored in
  47. that directory.
  48. Please note that buses are benchmarked when StarPU is launched for the
  49. first time. This may take a few minutes, or less if @code{hwloc} is
  50. installed. This step is done only once per user and per machine.
  51. @node Kernel threads started by StarPU
  52. @section Kernel threads started by StarPU
  53. StarPU automatically binds one thread per CPU core. It does not use
  54. SMT/hyperthreading because kernels are usually already optimized for using a
  55. full core, and using hyperthreading would make kernel calibration rather random.
  56. Since driving GPUs is a CPU-consuming task, StarPU dedicates one core per GPU
  57. While StarPU tasks are executing, the application is not supposed to do
  58. computations in the threads it starts itself, tasks should be used instead.
  59. TODO: add a StarPU function to bind an application thread (e.g. the main thread)
  60. to a dedicated core (and thus disable the corresponding StarPU CPU worker).
  61. @node Enabling OpenCL
  62. @section Enabling OpenCL
  63. When both CUDA and OpenCL drivers are enabled, StarPU will launch an
  64. OpenCL worker for NVIDIA GPUs only if CUDA is not already running on them.
  65. This design choice was necessary as OpenCL and CUDA can not run at the
  66. same time on the same NVIDIA GPU, as there is currently no interoperability
  67. between them.
  68. To enable OpenCL, you need either to disable CUDA when configuring StarPU:
  69. @example
  70. % ./configure --disable-cuda
  71. @end example
  72. or when running applications:
  73. @example
  74. % STARPU_NCUDA=0 ./application
  75. @end example
  76. OpenCL will automatically be started on any device not yet used by
  77. CUDA. So on a machine running 4 GPUS, it is therefore possible to
  78. enable CUDA on 2 devices, and OpenCL on the 2 other devices by doing
  79. so:
  80. @example
  81. % STARPU_NCUDA=2 ./application
  82. @end example