workers.doxy 10 KB

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