introduction.texi 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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, 2012 Institut National de Recherche en Informatique et Automatique
  6. @c See the file starpu.texi for copying conditions.
  7. @menu
  8. * Motivation:: Why StarPU ?
  9. * StarPU in a Nutshell:: The Fundamentals of StarPU
  10. * Application taskification:: How to taskify an application
  11. * Glossary::
  12. * Research Papers::
  13. @end menu
  14. @node Motivation
  15. @section Motivation
  16. @c complex machines with heterogeneous cores/devices
  17. The use of specialized hardware such as accelerators or coprocessors offers an
  18. interesting approach to overcome the physical limits encountered by processor
  19. architects. As a result, many machines are now equipped with one or several
  20. accelerators (e.g. a GPU), in addition to the usual processor(s). While a lot of
  21. efforts have been devoted to offload computation onto such accelerators, very
  22. little attention as been paid to portability concerns on the one hand, and to the
  23. possibility of having heterogeneous accelerators and processors to interact on the other hand.
  24. StarPU is a runtime system that offers support for heterogeneous multicore
  25. architectures, it not only offers a unified view of the computational resources
  26. (i.e. CPUs and accelerators at the same time), but it also takes care of
  27. efficiently mapping and executing tasks onto an heterogeneous machine while
  28. transparently handling low-level issues such as data transfers in a portable
  29. fashion.
  30. @c this leads to a complicated distributed memory design
  31. @c which is not (easily) manageable by hand
  32. @c added value/benefits of StarPU
  33. @c - portability
  34. @c - scheduling, perf. portability
  35. @node StarPU in a Nutshell
  36. @section StarPU in a Nutshell
  37. StarPU is a software tool aiming to allow programmers to exploit the
  38. computing power of the available CPUs and GPUs, while relieving them
  39. from the need to specially adapt their programs to the target machine
  40. and processing units.
  41. At the core of StarPU is its run-time support library, which is
  42. responsible for scheduling application-provided tasks on heterogeneous
  43. CPU/GPU machines. In addition, StarPU comes with programming language
  44. support, in the form of extensions to languages of the C family
  45. (@pxref{C Extensions}), as well as an OpenCL front-end (@pxref{SOCL
  46. OpenCL Extensions}).
  47. @cindex task-based programming model
  48. StarPU's run-time and programming language extensions support a
  49. @dfn{task-based programming model}. Applications submit computational
  50. tasks, with CPU and/or GPU implementations, and StarPU schedules these
  51. tasks and associated data transfers on available CPUs and GPUs. The
  52. data that a task manipulates are automatically transferred among
  53. accelerators and the main memory, so that programmers are freed from the
  54. scheduling issues and technical details associated with these transfers.
  55. StarPU takes particular care of scheduling tasks efficiently, using
  56. well-known algorithms from the literature (@pxref{Task scheduling
  57. policy}). In addition, it allows scheduling experts, such as compiler
  58. or computational library developers, to implement custom scheduling
  59. policies in a portable fashion (@pxref{Defining a New Scheduling Policy}).
  60. The remainder of this section describes the main concepts used in StarPU.
  61. @menu
  62. * Codelet and Tasks::
  63. * StarPU Data Management Library::
  64. @end menu
  65. @c explain the notion of codelet and task (i.e. g(A, B)
  66. @node Codelet and Tasks
  67. @subsection Codelet and Tasks
  68. @cindex codelet
  69. One of the StarPU primary data structures is the @b{codelet}. A codelet describes a
  70. computational kernel that can possibly be implemented on multiple architectures
  71. such as a CPU, a CUDA device or an OpenCL device.
  72. @c TODO insert illustration f: f_spu, f_cpu, ...
  73. @cindex task
  74. Another important data structure is the @b{task}. Executing a StarPU task
  75. consists in applying a codelet on a data set, on one of the architectures on
  76. which the codelet is implemented. A task thus describes the codelet that it
  77. uses, but also which data are accessed, and how they are
  78. accessed during the computation (read and/or write).
  79. StarPU tasks are asynchronous: submitting a task to StarPU is a non-blocking
  80. operation. The task structure can also specify a @b{callback} function that is
  81. called once StarPU has properly executed the task. It also contains optional
  82. fields that the application may use to give hints to the scheduler (such as
  83. priority levels).
  84. @cindex tag
  85. By default, task dependencies are inferred from data dependency (sequential
  86. coherence) by StarPU. The application can however disable sequential coherency
  87. for some data, and dependencies be expressed by hand.
  88. A task may be identified by a unique 64-bit number chosen by the application
  89. which we refer as a @b{tag}.
  90. Task dependencies can be enforced by hand either by the means of callback functions, by
  91. submitting other tasks, or by expressing dependencies
  92. between tags (which can thus correspond to tasks that have not been submitted
  93. yet).
  94. @c TODO insert illustration f(Ar, Brw, Cr) + ..
  95. @c DSM
  96. @node StarPU Data Management Library
  97. @subsection StarPU Data Management Library
  98. Because StarPU schedules tasks at runtime, data transfers have to be
  99. done automatically and ``just-in-time'' between processing units,
  100. relieving the application programmer from explicit data transfers.
  101. Moreover, to avoid unnecessary transfers, StarPU keeps data
  102. where it was last needed, even if was modified there, and it
  103. allows multiple copies of the same data to reside at the same time on
  104. several processing units as long as it is not modified.
  105. @node Application taskification
  106. @section Application taskification
  107. TODO
  108. @c TODO: section describing what taskifying an application means: before
  109. @c porting to StarPU, turn the program into:
  110. @c "pure" functions, which only access data from their passed parameters
  111. @c a main function which just calls these pure functions
  112. @c
  113. @c and then it's trivial to use StarPU or any other kind of task-based library:
  114. @c simply replace calling the function with submitting a task.
  115. @node Glossary
  116. @section Glossary
  117. A @b{codelet} records pointers to various implementations of the same
  118. theoretical function.
  119. A @b{memory node} can be either the main RAM or GPU-embedded memory.
  120. A @b{bus} is a link between memory nodes.
  121. A @b{data handle} keeps track of replicates of the same data (@b{registered} by the
  122. application) over various memory nodes. The data management library manages
  123. keeping them coherent.
  124. The @b{home} memory node of a data handle is the memory node from which the data
  125. was registered (usually the main memory node).
  126. A @b{task} represents a scheduled execution of a codelet on some data handles.
  127. A @b{tag} is a rendez-vous point. Tasks typically have their own tag, and can
  128. depend on other tags. The value is chosen by the application.
  129. A @b{worker} execute tasks. There is typically one per CPU computation core and
  130. one per accelerator (for which a whole CPU core is dedicated).
  131. A @b{driver} drives a given kind of workers. There are currently CPU, CUDA,
  132. and OpenCL drivers. They usually start several workers to actually drive
  133. them.
  134. A @b{performance model} is a (dynamic or static) model of the performance of a
  135. given codelet. Codelets can have execution time performance model as well as
  136. power consumption performance models.
  137. A data @b{interface} describes the layout of the data: for a vector, a pointer
  138. for the start, the number of elements and the size of elements ; for a matrix, a
  139. pointer for the start, the number of elements per row, the offset between rows,
  140. and the size of each element ; etc. To access their data, codelet functions are
  141. given interfaces for the local memory node replicates of the data handles of the
  142. scheduled task.
  143. @b{Partitioning} data means dividing the data of a given data handle (called
  144. @b{father}) into a series of @b{children} data handles which designate various
  145. portions of the former.
  146. A @b{filter} is the function which computes children data handles from a father
  147. data handle, and thus describes how the partitioning should be done (horizontal,
  148. vertical, etc.)
  149. @b{Acquiring} a data handle can be done from the main application, to safely
  150. access the data of a data handle from its home node, without having to
  151. unregister it.
  152. @node Research Papers
  153. @section Research Papers
  154. Research papers about StarPU can be found at
  155. @url{http://runtime.bordeaux.inria.fr/Publis/Keyword/STARPU.html}.
  156. A good overview is available in the research report at
  157. @url{http://hal.archives-ouvertes.fr/inria-00467677}.