workers.doxy 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup API_Workers_Properties Workers’ Properties
  9. \def STARPU_NMAXWORKERS
  10. \ingroup API_Workers_Properties
  11. Define the maximum number of workers managed by StarPU.
  12. \enum starpu_node_kind
  13. \ingroup API_Workers_Properties
  14. TODO
  15. \var starpu_node_kind::STARPU_UNUSED
  16. \ingroup API_Workers_Properties
  17. TODO
  18. \ingroup API_Workers_Properties
  19. \var starpu_node_kind::STARPU_CPU_RAM
  20. \ingroup API_Workers_Properties
  21. TODO
  22. \var starpu_node_kind::STARPU_CUDA_RAM
  23. \ingroup API_Workers_Properties
  24. TODO
  25. \var starpu_node_kind::STARPU_OPENCL_RAM
  26. \ingroup API_Workers_Properties
  27. TODO
  28. \var starpu_node_kind::STARPU_MIC_RAM
  29. \ingroup API_Workers_Properties
  30. TODO
  31. \var starpu_node_kind::STARPU_SCC_RAM
  32. \ingroup API_Workers_Properties
  33. This node kind is not used anymore, but implementations in interfaces
  34. will be useful for MPI.
  35. \var starpu_node_kind::STARPU_SCC_SHM
  36. \ingroup API_Workers_Properties
  37. TODO
  38. \enum starpu_worker_archtype
  39. \ingroup API_Workers_Properties
  40. Worker Architecture Type
  41. \var starpu_worker_archtype::STARPU_ANY_WORKER
  42. \ingroup API_Workers_Properties
  43. any worker, used in the hypervisor
  44. \var starpu_worker_archtype::STARPU_CPU_WORKER
  45. \ingroup API_Workers_Properties
  46. CPU core
  47. \var starpu_worker_archtype::STARPU_CUDA_WORKER
  48. \ingroup API_Workers_Properties
  49. NVIDIA CUDA device
  50. \var starpu_worker_archtype::STARPU_OPENCL_WORKER
  51. \ingroup API_Workers_Properties
  52. OpenCL device
  53. \var starpu_worker_archtype::STARPU_MIC_WORKER
  54. \ingroup API_Workers_Properties
  55. Intel MIC device
  56. \var starpu_worker_archtype::STARPU_SCC_WORKER
  57. \ingroup API_Workers_Properties
  58. Intel SCC device
  59. \struct starpu_worker_collection
  60. \ingroup API_Workers_Properties
  61. A scheduling context manages a collection of workers that can
  62. be memorized using different data structures. Thus, a generic
  63. structure is available in order to simplify the choice of its type.
  64. Only the list data structure is available but further data
  65. structures(like tree) implementations are foreseen.
  66. \var void *starpu_worker_collection::workerids
  67. The workerids managed by the collection
  68. \var unsigned starpu_worker_collection::nworkers
  69. The number of workers in the collection
  70. \var enum starpu_worker_collection_type starpu_worker_collection::type
  71. The type of structure (currently ::STARPU_WORKER_LIST is the only one available)
  72. \var unsigned (*starpu_worker_collection::has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
  73. Checks if there is another element in collection
  74. \var int (*starpu_worker_collection::get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
  75. return the next element in the collection
  76. \var int (*starpu_worker_collection::add)(struct starpu_worker_collection *workers, int worker)
  77. add a new element in the collection
  78. \var int (*starpu_worker_collection::remove)(struct starpu_worker_collection *workers, int worker)
  79. remove an element from the collection
  80. \var void (*starpu_worker_collection::init)(struct starpu_worker_collection *workers)
  81. Initialize the collection
  82. \var void (*starpu_worker_collection::deinit)(struct starpu_worker_collection *workers)
  83. Deinitialize the colection
  84. \var void (*starpu_worker_collection::init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
  85. Initialize the cursor if there is one
  86. \enum starpu_worker_collection_type
  87. \ingroup API_Workers_Properties
  88. Types of structures the worker collection can implement
  89. \var starpu_worker_collection_type::STARPU_WORKER_LIST
  90. \ingroup API_Workers_Properties
  91. The collection is an array
  92. \struct starpu_sched_ctx_iterator
  93. \ingroup API_Workers_Properties
  94. Structure needed to iterate on the collection
  95. \var int starpu_sched_ctx_iterator::cursor
  96. The index of the current worker in the collection, needed when iterating on
  97. the collection.
  98. \fn unsigned starpu_worker_get_count(void)
  99. \ingroup API_Workers_Properties
  100. This function returns the number of workers (i.e. processing
  101. units executing StarPU tasks). The returned value should be at most
  102. \ref STARPU_NMAXWORKERS.
  103. \fn int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
  104. \ingroup API_Workers_Properties
  105. Returns the number of workers of the given type. A positive (or
  106. NULL) value is returned in case of success, -EINVAL indicates that the
  107. type is not valid otherwise.
  108. \fn unsigned starpu_cpu_worker_get_count(void)
  109. \ingroup API_Workers_Properties
  110. This function returns the number of CPUs controlled by StarPU. The
  111. returned value should be at most \ref STARPU_MAXCPUS.
  112. \fn unsigned starpu_cuda_worker_get_count(void)
  113. \ingroup API_Workers_Properties
  114. This function returns the number of CUDA devices controlled by
  115. StarPU. The returned value should be at most \ref STARPU_MAXCUDADEVS.
  116. \fn unsigned starpu_mic_worker_get_count(void)
  117. \ingroup API_Workers_Properties
  118. This function returns the number of MIC workers controlled by StarPU.
  119. \fn unsigned starpu_mic_device_get_count(void)
  120. \ingroup API_Workers_Properties
  121. This function returns the number of MIC devices controlled by StarPU.
  122. The returned value should be at most \ref STARPU_MAXMICDEVS.
  123. \fn unsigned starpu_scc_worker_get_count(void)
  124. \ingroup API_Workers_Properties
  125. This function returns the number of SCC devices controlled by StarPU.
  126. The returned value should be at most \ref STARPU_MAXSCCDEVS.
  127. \fn unsigned starpu_opencl_worker_get_count(void)
  128. \ingroup API_Workers_Properties
  129. This function returns the number of OpenCL devices controlled by
  130. StarPU. The returned value should be at most \ref STARPU_MAXOPENCLDEVS.
  131. \fn int starpu_worker_get_id(void)
  132. \ingroup API_Workers_Properties
  133. This function returns the identifier of the current worker, i.e
  134. the one associated to the calling thread. The returned value is either
  135. -1 if the current context is not a StarPU worker (i.e. when called
  136. from the application outside a task or a callback), or an integer
  137. between 0 and starpu_worker_get_count() - 1.
  138. \fn int starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, int maxsize)
  139. \ingroup API_Workers_Properties
  140. This function gets the list of identifiers of workers with the
  141. given type. It fills the array \p workerids with the identifiers of the
  142. workers that have the type indicated in the first argument. The
  143. argument \p maxsize indicates the size of the array \p workerids. The returned
  144. value gives the number of identifiers that were put in the array.
  145. -ERANGE is returned is \p maxsize is lower than the number of workers
  146. with the appropriate type: in that case, the array is filled with the
  147. \p maxsize first elements. To avoid such overflows, the value of maxsize
  148. can be chosen by the means of the function
  149. starpu_worker_get_count_by_type(), or by passing a value greater or
  150. equal to \ref STARPU_NMAXWORKERS.
  151. \fn int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num)
  152. \ingroup API_Workers_Properties
  153. This returns the identifier of the num-th worker that has the
  154. specified type type. If there are no such worker, -1 is returned.
  155. \fn int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid)
  156. \ingroup API_Workers_Properties
  157. This returns the identifier of the worker that has the specified type
  158. \p type and device id \p devid (which may not be the n-th, if some
  159. devices are skipped for instance). If there are no such worker, -1 is returned.
  160. \fn int starpu_worker_get_devid(int id)
  161. \ingroup API_Workers_Properties
  162. This function returns the device id of the given worker. The
  163. worker should be identified with the value returned by the
  164. starpu_worker_get_id() function. In the case of a CUDA worker, this
  165. device identifier is the logical device identifier exposed by CUDA
  166. (used by the function cudaGetDevice() for instance). The device
  167. identifier of a CPU worker is the logical identifier of the core on
  168. which the worker was bound; this identifier is either provided by the
  169. OS or by the library <c>hwloc</c> in case it is available.
  170. \fn enum starpu_worker_archtype starpu_worker_get_type(int id)
  171. \ingroup API_Workers_Properties
  172. This function returns the type of processing unit associated to
  173. a worker. The worker identifier is a value returned by the function
  174. starpu_worker_get_id()). The returned value indicates the
  175. architecture of the worker: ::STARPU_CPU_WORKER for a CPU core,
  176. ::STARPU_CUDA_WORKER for a CUDA device, and ::STARPU_OPENCL_WORKER for a
  177. OpenCL device. The value returned for an invalid identifier is
  178. unspecified.
  179. \fn void starpu_worker_get_name(int id, char *dst, size_t maxlen)
  180. \ingroup API_Workers_Properties
  181. This function allows to get the name of a given worker. StarPU
  182. associates a unique human readable string to each processing unit.
  183. This function copies at most the maxlen first bytes of the unique
  184. string associated to a worker identified by its identifier id into the
  185. dst buffer. The caller is responsible for ensuring that \p dst is a
  186. valid pointer to a buffer of \p maxlen bytes at least. Calling this
  187. function on an invalid identifier results in an unspecified behaviour.
  188. \fn unsigned starpu_worker_get_memory_node(unsigned workerid)
  189. \ingroup API_Workers_Properties
  190. This function returns the identifier of the memory node
  191. associated to the worker identified by \p workerid.
  192. \fn enum starpu_node_kind starpu_node_get_kind(unsigned node)
  193. \ingroup API_Workers_Properties
  194. Returns the type of the given node as defined by
  195. ::starpu_node_kind. For example, when defining a new data interface,
  196. this function should be used in the allocation function to determine
  197. on which device the memory needs to be allocated.
  198. \fn char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type)
  199. \ingroup API_Workers_Properties
  200. Returns the given worker type as a string.
  201. */