data_interfaces.doxy 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 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_Data_Interfaces Data Interfaces
  9. \struct starpu_data_interface_ops
  10. Per-interface data transfer methods.
  11. \ingroup API_Data_Interfaces
  12. \var starpu_data_interface_ops::register_data_handle
  13. Register an existing interface into a data handle.
  14. \var starpu_data_interface_ops::allocate_data_on_node
  15. Allocate data for the interface on a given node.
  16. \var starpu_data_interface_ops::free_data_on_node
  17. Free data of the interface on a given node.
  18. \var starpu_data_interface_ops::copy_methods
  19. ram/cuda/opencl synchronous and asynchronous transfer methods.
  20. \var starpu_data_interface_ops::handle_to_pointer
  21. Return the current pointer (if any) for the handle on the given node.
  22. \var starpu_data_interface_ops::get_size
  23. Return an estimation of the size of data, for performance models.
  24. \var starpu_data_interface_ops::footprint
  25. Return a 32bit footprint which characterizes the data size.
  26. \var starpu_data_interface_ops::compare
  27. Compare the data size of two interfaces.
  28. \var starpu_data_interface_ops::display
  29. Dump the sizes of a handle to a file.
  30. \var starpu_data_interface_ops::interfaceid
  31. An identifier that is unique to each interface.
  32. \var starpu_data_interface_ops::interface_size
  33. The size of the interface data descriptor.
  34. \var starpu_data_interface_ops::is_multiformat
  35. todo
  36. \var starpu_data_interface_ops::get_mf_ops
  37. todo
  38. \var starpu_data_interface_ops::pack_data
  39. Pack the data handle into a contiguous buffer at the address ptr and
  40. set the size of the newly created buffer in count. If ptr is NULL, the
  41. function should not copy the data in the buffer but just set count to
  42. the size of the buffer which would have been allocated. The special
  43. value -1 indicates the size is yet unknown.
  44. \var starpu_data_interface_ops::unpack_data
  45. Unpack the data handle from the contiguous buffer at the address ptr
  46. of size count
  47. \struct starpu_data_copy_methods
  48. Defines the per-interface methods. If the any_to_any method is
  49. provided, it will be used by default if no more specific method is
  50. provided. It can still be useful to provide more specific method in
  51. case of e.g. available particular CUDA or OpenCL support.
  52. \ingroup API_Data_Interfaces
  53. \var starpu_data_copy_methods::ram_to_ram
  54. Define how to copy data from the \p src_interface interface on the \p
  55. src_node CPU node to the \p dst_interface interface on the \p dst_node
  56. CPU node. Return 0 on success.
  57. \var starpu_data_copy_methods::ram_to_cuda
  58. Define how to copy data from the \p src_interface interface on the
  59. \p src_node CPU node to the \p dst_interface interface on the \p dst_node CUDA
  60. node. Return 0 on success.
  61. \var starpu_data_copy_methods::ram_to_opencl
  62. Define how to copy data from the \p src_interface interface on the
  63. \p src_node CPU node to the \p dst_interface interface on the \p dst_node
  64. OpenCL node. Return 0 on success.
  65. \var starpu_data_copy_methods::ram_to_mic
  66. Define how to copy data from the \p src_interface interface on the
  67. \p src_node CPU node to the \p dst_interface interface on the \p dst_node MIC
  68. node. Return 0 on success.
  69. \var starpu_data_copy_methods::cuda_to_ram
  70. Define how to copy data from the \p src_interface interface on the
  71. \p src_node CUDA node to the \p dst_interface interface on the \p dst_node
  72. CPU node. Return 0 on success.
  73. \var starpu_data_copy_methods::cuda_to_cuda
  74. Define how to copy data from the \p src_interface interface on the
  75. \p src_node CUDA node to the \p dst_interface interface on the \p dst_node CUDA
  76. node. Return 0 on success.
  77. \var starpu_data_copy_methods::cuda_to_opencl
  78. Define how to copy data from the \p src_interface interface on the
  79. \p src_node CUDA node to the \p dst_interface interface on the \p dst_node
  80. OpenCL node. Return 0 on success.
  81. \var starpu_data_copy_methods::opencl_to_ram
  82. Define how to copy data from the \p src_interface interface on the
  83. \p src_node OpenCL node to the \p dst_interface interface on the \p dst_node
  84. CPU node. Return 0 on success.
  85. \var starpu_data_copy_methods::opencl_to_cuda
  86. Define how to copy data from the \p src_interface interface on the
  87. \p src_node OpenCL node to the \p dst_interface interface on the \p dst_node
  88. CUDA node. Return 0 on success.
  89. \var starpu_data_copy_methods::opencl_to_opencl
  90. Define how to copy data from the \p src_interface interface on the
  91. \p src_node OpenCL node to the \p dst_interface interface on the \p dst_node
  92. OpenCL node. Return 0 on success.
  93. \var starpu_data_copy_methods::mic_to_ram
  94. Define how to copy data from the \p src_interface interface on the
  95. \p src_node MIC node to the \p dst_interface interface on the \p dst_node CPU
  96. node. Return 0 on success.
  97. \var starpu_data_copy_methods::scc_src_to_sink
  98. Define how to copy data from the \p src_interface interface on the
  99. \p src_node node to the \p dst_interface interface on the \p dst_node node.
  100. Must return 0 if the transfer was actually completed completely
  101. synchronously, or -EAGAIN if at least some transfers are still ongoing
  102. and should be awaited for by the core.
  103. \var starpu_data_copy_methods::scc_sink_to_src
  104. Define how to copy data from the \p src_interface interface on the
  105. \p src_node node to the \p dst_interface interface on the \p dst_node node.
  106. Must return 0 if the transfer was actually completed completely
  107. synchronously, or -EAGAIN if at least some transfers are still ongoing
  108. and should be awaited for by the core.
  109. \var starpu_data_copy_methods::scc_sink_to_sink
  110. Define how to copy data from the \p src_interface interface on the
  111. \p src_node node to the \p dst_interface interface on the \p dst_node node.
  112. Must return 0 if the transfer was actually completed completely
  113. synchronously, or -EAGAIN if at least some transfers are still ongoing
  114. and should be awaited for by the core.
  115. \var starpu_data_copy_methods::ram_to_cuda_async
  116. Define how to copy data from the \p src_interface interface on the
  117. \p src_node CPU node to the \p dst_interface interface on the \p dst_node CUDA
  118. node, using the given stream. Must return 0 if the transfer was
  119. actually completed completely synchronously, or -EAGAIN if at least
  120. some transfers are still ongoing and should be awaited for by the core.
  121. \var starpu_data_copy_methods::cuda_to_ram_async
  122. Define how to copy data from the \p src_interface interface on the
  123. \p src_node CUDA node to the \p dst_interface interface on the \p dst_node CPU
  124. node, using the given stream. Must return 0 if the transfer was
  125. actually completed completely synchronously, or -EAGAIN if at least
  126. some transfers are still ongoing and should be awaited for by the core.
  127. \var starpu_data_copy_methods::cuda_to_cuda_async
  128. Define how to copy data from the \p src_interface interface on the
  129. \p src_node CUDA node to the \p dst_interface interface on the \p dst_node CUDA
  130. node, using the given stream. Must return 0 if the transfer was
  131. actually completed completely synchronously, or -EAGAIN if at least
  132. some transfers are still ongoing and should be awaited for by the core.
  133. \var starpu_data_copy_methods::ram_to_opencl_async
  134. Define how to copy data from the \p src_interface interface on the
  135. \p src_node CPU node to the \p dst_interface interface on the \p dst_node
  136. OpenCL node, by recording in event, a pointer to a cl_event, the event
  137. of the last submitted transfer. Must return 0 if the transfer was
  138. actually completed completely synchronously, or -EAGAIN if at least
  139. some transfers are still ongoing and should be awaited for by the
  140. core.
  141. \var starpu_data_copy_methods::opencl_to_ram_async
  142. Define how to copy data from the \p src_interface interface on the
  143. \p src_node OpenCL node to the \p dst_interface interface on the \p dst_node
  144. CPU node, by recording in event, a pointer to a cl_event, the event of
  145. the last submitted transfer. Must return 0 if the transfer was
  146. actually completed completely synchronously, or -EAGAIN if at least
  147. some transfers are still ongoing and should be awaited for by the
  148. core.
  149. \var starpu_data_copy_methods::opencl_to_opencl_async
  150. Define how to copy data from the \p src_interface interface on the
  151. \p src_node OpenCL node to the \p dst_interface interface on the \p dst_node
  152. OpenCL node, by recording in event, a pointer to a cl_event, the event
  153. of the last submitted transfer. Must return 0 if the transfer was
  154. actually completed completely synchronously, or -EAGAIN if at least
  155. some transfers are still ongoing and should be awaited for by the
  156. core.
  157. \var starpu_data_copy_methods::ram_to_mic_async
  158. Define how to copy data from the \p src_interface interface on the
  159. \p src_node CPU node to the \p dst_interface interface on the \p dst_node
  160. MIC node. Must return 0 if the transfer was actually completed
  161. completely synchronously, or -EAGAIN if at least some transfers are
  162. still ongoing and should be awaited for by the core.
  163. \var starpu_data_copy_methods::mic_to_ram_async
  164. Define how to copy data from the \p src_interface interface on the
  165. \p src_node MIC node to the \p dst_interface interface on the \p dst_node
  166. CPU node. Must return 0 if the transfer was actually completed
  167. completely synchronously, or -EAGAIN if at least some transfers are
  168. still ongoing and should be awaited for by the core.
  169. \var starpu_data_copy_methods::any_to_any
  170. Define how to copy data from the \p src_interface interface on the
  171. \p src_node node to the \p dst_interface interface on the \p dst_node node.
  172. This is meant to be implemented through the starpu_interface_copy()
  173. helper, to which async_data should be passed as such, and will be used
  174. to manage asynchronicity. This must return -EAGAIN if any of the
  175. starpu_interface_copy() calls has returned -EAGAIN (i.e. at least some
  176. transfer is still ongoing), and return 0 otherwise.
  177. @name Registering Data
  178. \ingroup API_Data_Interfaces
  179. There are several ways to register a memory region so that it can be
  180. managed by StarPU. The functions below allow the registration of
  181. vectors, 2D matrices, 3D matrices as well as BCSR and CSR sparse
  182. matrices.
  183. \fn void starpu_void_data_register(starpu_data_handle_t *handle)
  184. \ingroup API_Data_Interfaces
  185. Register a void interface. There is no data really associated
  186. to that interface, but it may be used as a synchronization mechanism.
  187. It also permits to express an abstract piece of data that is managed
  188. by the application internally: this makes it possible to forbid the
  189. concurrent execution of different tasks accessing the same <c>void</c> data
  190. in read-write concurrently.
  191. \fn void starpu_variable_data_register(starpu_data_handle_t *handle, unsigned home_node, uintptr_t ptr, size_t size)
  192. \ingroup API_Data_Interfaces
  193. Register the \p size byte element pointed to by \p ptr, which is
  194. typically a scalar, and initialize \p handle to represent this data item.
  195. Here an example of how to use the function.
  196. \code{.c}
  197. float var;
  198. starpu_data_handle_t var_handle;
  199. starpu_variable_data_register(&var_handle, 0, (uintptr_t)&var, sizeof(var));
  200. \endcode
  201. \fn void starpu_vector_data_register(starpu_data_handle_t *handle, unsigned home_node, uintptr_t ptr, uint32_t nx, size_t elemsize)
  202. \ingroup API_Data_Interfaces
  203. Register the \p nx elemsize-byte elements pointed to by \p ptr and initialize \p handle to represent it.
  204. Here an example of how to use the function.
  205. \code{.c}
  206. float vector[NX];
  207. starpu_data_handle_t vector_handle;
  208. starpu_vector_data_register(&vector_handle, 0, (uintptr_t)vector, NX, sizeof(vector[0]));
  209. \endcode
  210. \fn void starpu_matrix_data_register(starpu_data_handle_t *handle, unsigned home_node, uintptr_t ptr, uint32_t ld, uint32_t nx, uint32_t ny, size_t elemsize)
  211. \ingroup API_Data_Interfaces
  212. Register the \p nx x \p ny 2D matrix of \p elemsize-byte elements pointed
  213. by \p ptr and initialize \p handle to represent it. \p ld specifies the number
  214. of elements between rows. a value greater than \p nx adds padding, which
  215. can be useful for alignment purposes.
  216. Here an example of how to use the function.
  217. \code{.c}
  218. float *matrix;
  219. starpu_data_handle_t matrix_handle;
  220. matrix = (float*)malloc(width * height * sizeof(float));
  221. starpu_matrix_data_register(&matrix_handle, 0, (uintptr_t)matrix, width, width, height, sizeof(float));
  222. \endcode
  223. \fn void starpu_block_data_register(starpu_data_handle_t *handle, unsigned home_node, uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx, uint32_t ny, uint32_t nz, size_t elemsize)
  224. \ingroup API_Data_Interfaces
  225. Register the \p nx x \p ny x \p nz 3D matrix of \p elemsize byte elements
  226. pointed by \p ptr and initialize \p handle to represent it. Again, \p ldy and
  227. \p ldz specify the number of elements between rows and between z planes.
  228. Here an example of how to use the function.
  229. \code{.c}
  230. float *block;
  231. starpu_data_handle_t block_handle;
  232. block = (float*)malloc(nx*ny*nz*sizeof(float));
  233. starpu_block_data_register(&block_handle, 0, (uintptr_t)block, nx, nx*ny, nx, ny, nz, sizeof(float));
  234. \endcode
  235. \fn void starpu_bcsr_data_register(starpu_data_handle_t *handle, unsigned home_node, uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, uint32_t r, uint32_t c, size_t elemsize)
  236. \ingroup API_Data_Interfaces
  237. This variant of starpu_data_register() uses the BCSR (Blocked
  238. Compressed Sparse Row Representation) sparse matrix interface.
  239. Register the sparse matrix made of \p nnz non-zero blocks of elements of
  240. size \p elemsize stored in \p nzval and initializes \p handle to represent it.
  241. Blocks have size \p r * \p c. \p nrow is the number of rows (in terms of
  242. blocks), \p colind[i] is the block-column index for block i in \p nzval,
  243. \p rowptr[i] is the block-index (in \p nzval) of the first block of row i.
  244. \p firstentry is the index of the first entry of the given arrays
  245. (usually 0 or 1).
  246. \fn void starpu_csr_data_register(starpu_data_handle_t *handle, unsigned home_node, uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize)
  247. \ingroup API_Data_Interfaces
  248. This variant of starpu_data_register() uses the CSR (Compressed
  249. Sparse Row Representation) sparse matrix interface. TODO
  250. \fn void starpu_coo_data_register(starpu_data_handle_t *handleptr, unsigned home_node, uint32_t nx, uint32_t ny, uint32_t n_values, uint32_t *columns, uint32_t *rows, uintptr_t values, size_t elemsize);
  251. \ingroup API_Data_Interfaces
  252. Register the \p nx x \p ny 2D matrix given in the COO format, using the
  253. \p columns, \p rows, \p values arrays, which must have \p n_values elements of
  254. size \p elemsize. Initialize \p handleptr.
  255. \fn void *starpu_data_get_interface_on_node(starpu_data_handle_t handle, unsigned memory_node)
  256. \ingroup API_Data_Interfaces
  257. Return the interface associated with \p handle on \p memory_node.
  258. @name Accessing Data Interfaces
  259. \ingroup API_Data_Interfaces
  260. Each data interface is provided with a set of field access functions.
  261. The ones using a void * parameter aimed to be used in codelet
  262. implementations (see for example the code in \ref
  263. VectorScalingUsingStarPUAPI).
  264. \fn void *starpu_data_handle_to_pointer(starpu_data_handle_t handle, unsigned node)
  265. \ingroup API_Data_Interfaces
  266. Return the pointer associated with \p handle on node \p node or <c>NULL</c>
  267. if handle’s interface does not support this operation or data for this
  268. \p handle is not allocated on that \p node.
  269. \fn void *starpu_data_get_local_ptr(starpu_data_handle_t handle)
  270. \ingroup API_Data_Interfaces
  271. Return the local pointer associated with \p handle or <c>NULL</c> if
  272. \p handle’s interface does not have data allocated locally
  273. \fn enum starpu_data_interface_id starpu_data_get_interface_id(starpu_data_handle_t handle)
  274. \ingroup API_Data_Interfaces
  275. Return the unique identifier of the interface associated with
  276. the given \p handle.
  277. \fn size_t starpu_data_get_size(starpu_data_handle_t handle)
  278. \ingroup API_Data_Interfaces
  279. Return the size of the data associated with \p handle.
  280. \fn int starpu_data_pack(starpu_data_handle_t handle, void **ptr, starpu_ssize_t *count)
  281. \ingroup API_Data_Interfaces
  282. Execute the packing operation of the interface of the data
  283. registered at \p handle (see starpu_data_interface_ops). This
  284. packing operation must allocate a buffer large enough at \p ptr and copy
  285. into the newly allocated buffer the data associated to \p handle. \p count
  286. will be set to the size of the allocated buffer. If \p ptr is NULL, the
  287. function should not copy the data in the buffer but just set \p count to
  288. the size of the buffer which would have been allocated. The special
  289. value -1 indicates the size is yet unknown.
  290. \fn int starpu_data_unpack(starpu_data_handle_t handle, void *ptr, size_t count)
  291. \ingroup API_Data_Interfaces
  292. Unpack in handle the data located at \p ptr of size \p count as
  293. described by the interface of the data. The interface registered at
  294. \p handle must define a unpacking operation (see
  295. starpu_data_interface_ops). The memory at the address \p ptr is freed
  296. after calling the data unpacking operation.
  297. @name Accessing Variable Data Interfaces
  298. \ingroup API_Data_Interfaces
  299. \struct starpu_variable_interface
  300. Variable interface for a single data (not a vector, a matrix, a list, ...)
  301. \ingroup API_Data_Interfaces
  302. \var starpu_variable_interface::id
  303. Identifier of the interface
  304. \var starpu_variable_interface::ptr
  305. local pointer of the variable
  306. \var starpu_variable_interface::dev_handle
  307. device handle of the variable.
  308. \var starpu_variable_interface::offset
  309. offset in the variable
  310. \var starpu_variable_interface::elemsize
  311. size of the variable
  312. \fn size_t starpu_variable_get_elemsize(starpu_data_handle_t handle)
  313. \ingroup API_Data_Interfaces
  314. Return the size of the variable designated by \p handle.
  315. \fn uintptr_t starpu_variable_get_local_ptr(starpu_data_handle_t handle)
  316. \ingroup API_Data_Interfaces
  317. Return a pointer to the variable designated by \p handle.
  318. \def STARPU_VARIABLE_GET_PTR(interface)
  319. \ingroup API_Data_Interfaces
  320. Return a pointer to the variable designated by \p interface.
  321. \def STARPU_VARIABLE_GET_ELEMSIZE(interface)
  322. \ingroup API_Data_Interfaces
  323. Return the size of the variable designated by \p interface.
  324. \def STARPU_VARIABLE_GET_DEV_HANDLE(interface)
  325. \ingroup API_Data_Interfaces
  326. Return a device handle for the variable designated by
  327. \p interface, to be used on OpenCL. The offset documented below has to be
  328. used in addition to this.
  329. \def STARPU_VARIABLE_GET_OFFSET()
  330. \ingroup API_Data_Interfaces
  331. Return the offset in the variable designated by \p interface, to
  332. be used with the device handle.
  333. @name Accessing Vector Data Interfaces
  334. \ingroup API_Data_Interfaces
  335. \struct starpu_vector_interface
  336. Vector interface
  337. \ingroup API_Data_Interfaces
  338. \var starpu_vector_interface::id
  339. Identifier of the interface
  340. \var starpu_vector_interface::ptr
  341. local pointer of the vector
  342. \var starpu_vector_interface::dev_handle
  343. device handle of the vector.
  344. \var starpu_vector_interface::offset
  345. offset in the vector
  346. \var starpu_vector_interface::nx
  347. number of elements on the x-axis of the vector
  348. \var starpu_vector_interface::elemsize
  349. size of the elements of the vector
  350. \fn uint32_t starpu_vector_get_nx(starpu_data_handle_t handle)
  351. \ingroup API_Data_Interfaces
  352. Return the number of elements registered into the array designated by \p handle.
  353. \fn size_t starpu_vector_get_elemsize(starpu_data_handle_t handle)
  354. \ingroup API_Data_Interfaces
  355. Return the size of each element of the array designated by \p handle.
  356. \fn uintptr_t starpu_vector_get_local_ptr(starpu_data_handle_t handle)
  357. \ingroup API_Data_Interfaces
  358. Return the local pointer associated with \p handle.
  359. \def STARPU_VECTOR_GET_PTR(void *interface)
  360. \ingroup API_Data_Interfaces
  361. Return a pointer to the array designated by \p interface, valid on
  362. CPUs and CUDA only. For OpenCL, the device handle and offset need to
  363. be used instead.
  364. \def STARPU_VECTOR_GET_DEV_HANDLE(void *interface)
  365. \ingroup API_Data_Interfaces
  366. Return a device handle for the array designated by \p interface,
  367. to be used on OpenCL. the offset documented below has to be used in
  368. addition to this.
  369. \def STARPU_VECTOR_GET_OFFSET(void *interface)
  370. \ingroup API_Data_Interfaces
  371. Return the offset in the array designated by \p interface, to be
  372. used with the device handle.
  373. \def STARPU_VECTOR_GET_NX(void *interface)
  374. \ingroup API_Data_Interfaces
  375. Return the number of elements registered into the array
  376. designated by \p interface.
  377. \def STARPU_VECTOR_GET_ELEMSIZE(void *interface)
  378. \ingroup API_Data_Interfaces
  379. Return the size of each element of the array designated by
  380. \p interface.
  381. @name Accessing Matrix Data Interfaces
  382. \ingroup API_Data_Interfaces
  383. \struct starpu_matrix_interface
  384. Matrix interface for dense matrices
  385. \ingroup API_Data_Interfaces
  386. \var starpu_matrix_interface::id
  387. Identifier of the interface
  388. \var starpu_matrix_interface::ptr
  389. local pointer of the matrix
  390. \var starpu_matrix_interface::dev_handle
  391. device handle of the matrix.
  392. \var starpu_matrix_interface::offset
  393. offset in the matrix
  394. \var starpu_matrix_interface::nx
  395. number of elements on the x-axis of the matrix
  396. \var starpu_matrix_interface::ny
  397. number of elements on the y-axis of the matrix
  398. \var starpu_matrix_interface::ld
  399. number of elements between each row of the matrix. Maybe be equal to
  400. starpu_matrix_interface::nx when there is no padding.
  401. \var starpu_matrix_interface::elemsize
  402. size of the elements of the matrix
  403. \fn uint32_t starpu_matrix_get_nx(starpu_data_handle_t handle)
  404. \ingroup API_Data_Interfaces
  405. Return the number of elements on the x-axis of the matrix
  406. designated by \p handle.
  407. \fn uint32_t starpu_matrix_get_ny(starpu_data_handle_t handle)
  408. \ingroup API_Data_Interfaces
  409. Return the number of elements on the y-axis of the matrix
  410. designated by \p handle.
  411. \fn uint32_t starpu_matrix_get_local_ld(starpu_data_handle_t handle)
  412. \ingroup API_Data_Interfaces
  413. Return the number of elements between each row of the matrix
  414. designated by \p handle. Maybe be equal to nx when there is no padding.
  415. \fn uintptr_t starpu_matrix_get_local_ptr(starpu_data_handle_t handle)
  416. \ingroup API_Data_Interfaces
  417. Return the local pointer associated with \p handle.
  418. \fn size_t starpu_matrix_get_elemsize(starpu_data_handle_t handle)
  419. \ingroup API_Data_Interfaces
  420. Return the size of the elements registered into the matrix
  421. designated by \p handle.
  422. \def STARPU_MATRIX_GET_PTR(void *interface)
  423. \ingroup API_Data_Interfaces
  424. Return a pointer to the matrix designated by \p interface, valid
  425. on CPUs and CUDA devices only. For OpenCL devices, the device handle
  426. and offset need to be used instead.
  427. \def STARPU_MATRIX_GET_DEV_HANDLE(void *interface)
  428. \ingroup API_Data_Interfaces
  429. Return a device handle for the matrix designated by \p interface,
  430. to be used on OpenCL. The offset documented below has to be used in
  431. addition to this.
  432. \def STARPU_MATRIX_GET_OFFSET(void *interface)
  433. \ingroup API_Data_Interfaces
  434. Return the offset in the matrix designated by \p interface, to be
  435. used with the device handle.
  436. \def STARPU_MATRIX_GET_NX(void *interface)
  437. \ingroup API_Data_Interfaces
  438. Return the number of elements on the x-axis of the matrix
  439. designated by \p interface.
  440. \def STARPU_MATRIX_GET_NY(void *interface)
  441. \ingroup API_Data_Interfaces
  442. Return the number of elements on the y-axis of the matrix
  443. designated by \p interface.
  444. \def STARPU_MATRIX_GET_LD(void *interface)
  445. \ingroup API_Data_Interfaces
  446. Return the number of elements between each row of the matrix
  447. designated by \p interface. May be equal to nx when there is no padding.
  448. \def STARPU_MATRIX_GET_ELEMSIZE(void *interface)
  449. \ingroup API_Data_Interfaces
  450. Return the size of the elements registered into the matrix
  451. designated by \p interface.
  452. @name Accessing Block Data Interfaces
  453. \ingroup API_Data_Interfaces
  454. \struct starpu_block_interface
  455. Block interface for 3D dense blocks
  456. \ingroup API_Data_Interfaces
  457. \struct starpu_block_interface::id
  458. identifier of the interface
  459. \var starpu_block_interface::ptr
  460. local pointer of the block
  461. \var starpu_block_interface::dev_handle
  462. device handle of the block.
  463. \var starpu_block_interface::offset
  464. offset in the block.
  465. \var starpu_block_interface::nx
  466. number of elements on the x-axis of the block.
  467. \var starpu_block_interface::ny
  468. number of elements on the y-axis of the block.
  469. \var starpu_block_interface::nz
  470. number of elements on the z-axis of the block.
  471. \var starpu_block_interface::ldy
  472. number of elements between two lines
  473. \var starpu_block_interface::ldz
  474. number of elements between two planes
  475. \var starpu_block_interface::elemsize
  476. size of the elements of the block.
  477. \fn uint32_t starpu_block_get_nx(starpu_data_handle_t handle)
  478. \ingroup API_Data_Interfaces
  479. Return the number of elements on the x-axis of the block
  480. designated by \p handle.
  481. \fn uint32_t starpu_block_get_ny(starpu_data_handle_t handle)
  482. \ingroup API_Data_Interfaces
  483. Return the number of elements on the y-axis of the block
  484. designated by \p handle.
  485. \fn uint32_t starpu_block_get_nz(starpu_data_handle_t handle)
  486. \ingroup API_Data_Interfaces
  487. Return the number of elements on the z-axis of the block
  488. designated by \p handle.
  489. \fn uint32_t starpu_block_get_local_ldy(starpu_data_handle_t handle)
  490. \ingroup API_Data_Interfaces
  491. Return the number of elements between each row of the block
  492. designated by \p handle, in the format of the current memory node.
  493. \fn uint32_t starpu_block_get_local_ldz(starpu_data_handle_t handle)
  494. \ingroup API_Data_Interfaces
  495. Return the number of elements between each z plane of the block
  496. designated by \p handle, in the format of the current memory node.
  497. \fn uintptr_t starpu_block_get_local_ptr(starpu_data_handle_t handle)
  498. \ingroup API_Data_Interfaces
  499. Return the local pointer associated with \p handle.
  500. \fn size_t starpu_block_get_elemsize(starpu_data_handle_t handle)
  501. \ingroup API_Data_Interfaces
  502. Return the size of the elements of the block designated by
  503. \p handle.
  504. \def STARPU_BLOCK_GET_PTR(void *interface)
  505. \ingroup API_Data_Interfaces
  506. Return a pointer to the block designated by \p interface.
  507. \def STARPU_BLOCK_GET_DEV_HANDLE(void *interface)
  508. \ingroup API_Data_Interfaces
  509. Return a device handle for the block designated by \p interface,
  510. to be used on OpenCL. The offset document below has to be used in
  511. addition to this.
  512. \def STARPU_BLOCK_GET_OFFSET(void *interface)
  513. \ingroup API_Data_Interfaces
  514. Return the offset in the block designated by \p interface, to be
  515. used with the device handle.
  516. \def STARPU_BLOCK_GET_NX(void *interface)
  517. \ingroup API_Data_Interfaces
  518. Return the number of elements on the x-axis of the block
  519. designated by \p interface.
  520. \def STARPU_BLOCK_GET_NY(void *interface)
  521. \ingroup API_Data_Interfaces
  522. Return the number of elements on the y-axis of the block
  523. designated by \p interface.
  524. \def STARPU_BLOCK_GET_NZ(void *interface)
  525. \ingroup API_Data_Interfaces
  526. Return the number of elements on the z-axis of the block
  527. designated by \p interface.
  528. \def STARPU_BLOCK_GET_LDY(void *interface)
  529. \ingroup API_Data_Interfaces
  530. Return the number of elements between each row of the block
  531. designated by \p interface. May be equal to nx when there is no padding.
  532. \def STARPU_BLOCK_GET_LDZ(void *interface)
  533. \ingroup API_Data_Interfaces
  534. Return the number of elements between each z plane of the block
  535. designated by \p interface. May be equal to nx*ny when there is no
  536. padding.
  537. \def STARPU_BLOCK_GET_ELEMSIZE(void *interface)
  538. \ingroup API_Data_Interfaces
  539. Return the size of the elements of the block designated by
  540. \p interface.
  541. @name Accessing BCSR Data Interfaces
  542. \ingroup API_Data_Interfaces
  543. \struct starpu_bcsr_interface
  544. BCSR interface for sparse matrices (blocked compressed sparse
  545. row representation)
  546. \ingroup API_Data_Interfaces
  547. \var starpu_bcsr_interface::id
  548. Identifier of the interface
  549. \var starpu_bcsr_interface::nnz
  550. number of non-zero BLOCKS
  551. \var starpu_bcsr_interface::nrow
  552. number of rows (in terms of BLOCKS)
  553. \var starpu_bcsr_interface::nzval
  554. non-zero values
  555. \var starpu_bcsr_interface::colind
  556. position of non-zero entried on the row
  557. \var starpu_bcsr_interface::rowptr
  558. index (in nzval) of the first entry of the row
  559. \var starpu_bcsr_interface::firstentry
  560. k for k-based indexing (0 or 1 usually). Also useful when partitionning the matrix.
  561. \var starpu_bcsr_interface::r
  562. size of the blocks
  563. \var starpu_bcsr_interface::c
  564. size of the blocks
  565. \var starpu_bcsr_interface::elemsize;
  566. size of the elements of the matrix
  567. \fn uint32_t starpu_bcsr_get_nnz(starpu_data_handle_t handle)
  568. \ingroup API_Data_Interfaces
  569. Return the number of non-zero elements in the matrix designated
  570. by \p handle.
  571. \fn uint32_t starpu_bcsr_get_nrow(starpu_data_handle_t handle)
  572. \ingroup API_Data_Interfaces
  573. Return the number of rows (in terms of blocks of size r*c) in
  574. the matrix designated by \p handle.
  575. \fn uint32_t starpu_bcsr_get_firstentry(starpu_data_handle_t handle)
  576. \ingroup API_Data_Interfaces
  577. Return the index at which all arrays (the column indexes, the
  578. row pointers...) of the matrix desginated by \p handle.
  579. \fn uintptr_t starpu_bcsr_get_local_nzval(starpu_data_handle_t handle)
  580. \ingroup API_Data_Interfaces
  581. Return a pointer to the non-zero values of the matrix
  582. designated by \p handle.
  583. \fn uint32_t * starpu_bcsr_get_local_colind(starpu_data_handle_t handle)
  584. \ingroup API_Data_Interfaces
  585. Return a pointer to the column index, which holds the positions
  586. of the non-zero entries in the matrix designated by \p handle.
  587. \fn uint32_t * starpu_bcsr_get_local_rowptr(starpu_data_handle_t handle)
  588. \ingroup API_Data_Interfaces
  589. Return the row pointer array of the matrix designated by
  590. \p handle.
  591. \fn uint32_t starpu_bcsr_get_r(starpu_data_handle_t handle)
  592. \ingroup API_Data_Interfaces
  593. Return the number of rows in a block.
  594. \fn uint32_t starpu_bcsr_get_c(starpu_data_handle_t handle)
  595. \ingroup API_Data_Interfaces
  596. Return the numberof columns in a block.
  597. \fn size_t starpu_bcsr_get_elemsize(starpu_data_handle_t handle)
  598. \ingroup API_Data_Interfaces
  599. Return the size of the elements in the matrix designated by
  600. \p handle.
  601. \def STARPU_BCSR_GET_NNZ(void *interface)
  602. \ingroup API_Data_Interfaces
  603. Return the number of non-zero values in the matrix designated
  604. by \p interface.
  605. \def STARPU_BCSR_GET_NZVAL(void *interface)
  606. \ingroup API_Data_Interfaces
  607. Return a pointer to the non-zero values of the matrix
  608. designated by \p interface.
  609. \def STARPU_BCSR_GET_NZVAL_DEV_HANDLE(void *interface)
  610. \ingroup API_Data_Interfaces
  611. Return a device handle for the array of non-zero values in the
  612. matrix designated by \p interface. The offset documented below has to be
  613. used in addition to this.
  614. \def STARPU_BCSR_GET_COLIND(void *interface)
  615. \ingroup API_Data_Interfaces
  616. Return a pointer to the column index of the matrix designated
  617. by \p interface.
  618. \def STARPU_BCSR_GET_COLIND_DEV_HANDLE(void *interface)
  619. \ingroup API_Data_Interfaces
  620. Return a device handle for the column index of the matrix
  621. designated by \p interface. The offset documented below has to be used in
  622. addition to this.
  623. \def STARPU_BCSR_GET_ROWPTR(void *interface)
  624. \ingroup API_Data_Interfaces
  625. Return a pointer to the row pointer array of the matrix
  626. designated by \p interface.
  627. \def STARPU_CSR_GET_ROWPTR_DEV_HANDLE(void *interface)
  628. \ingroup API_Data_Interfaces
  629. Return a device handle for the row pointer array of the matrix
  630. designated by \p interface. The offset documented below has to be used in
  631. addition to this.
  632. \def STARPU_BCSR_GET_OFFSET(void *interface)
  633. \ingroup API_Data_Interfaces
  634. Return the offset in the arrays (coling, rowptr, nzval) of the
  635. matrix designated by \p interface, to be used with the device handles.
  636. @name Accessing CSR Data Interfaces
  637. \ingroup API_Data_Interfaces
  638. \struct starpu_csr_interface
  639. CSR interface for sparse matrices (compressed sparse row representation)
  640. \ingroup API_Data_Interfaces
  641. \var starpu_csr_interface::id
  642. Identifier of the interface
  643. \var starpu_csr_interface::nnz
  644. number of non-zero entries
  645. \var starpu_csr_interface::nrow
  646. number of rows
  647. \var starpu_csr_interface::nzval
  648. non-zero values
  649. \var starpu_csr_interface::colind
  650. position of non-zero entries on the row
  651. \var starpu_csr_interface::rowptr
  652. index (in nzval) of the first entry of the row
  653. \var starpu_csr_interface::firstentry
  654. k for k-based indexing (0 or 1 usually). also useful when partitionning the matrix.
  655. \var starpu_csr_interface::elemsize
  656. size of the elements of the matrix
  657. \fn uint32_t starpu_csr_get_nnz(starpu_data_handle_t handle)
  658. \ingroup API_Data_Interfaces
  659. Return the number of non-zero values in the matrix designated
  660. by \p handle.
  661. \fn uint32_t starpu_csr_get_nrow(starpu_data_handle_t handle)
  662. \ingroup API_Data_Interfaces
  663. Return the size of the row pointer array of the matrix
  664. designated by \p handle.
  665. \fn uint32_t starpu_csr_get_firstentry(starpu_data_handle_t handle)
  666. \ingroup API_Data_Interfaces
  667. Return the index at which all arrays (the column indexes, the
  668. row pointers...) of the matrix designated by \p handle.
  669. \fn uintptr_t starpu_csr_get_local_nzval(starpu_data_handle_t handle)
  670. \ingroup API_Data_Interfaces
  671. Return a local pointer to the non-zero values of the matrix
  672. designated by \p handle.
  673. \fn uint32_t * starpu_csr_get_local_colind(starpu_data_handle_t handle)
  674. \ingroup API_Data_Interfaces
  675. Return a local pointer to the column index of the matrix
  676. designated by \p handle.
  677. \fn uint32_t * starpu_csr_get_local_rowptr(starpu_data_handle_t handle)
  678. \ingroup API_Data_Interfaces
  679. Return a local pointer to the row pointer array of the matrix
  680. designated by \p handle.
  681. \fn size_t starpu_csr_get_elemsize(starpu_data_handle_t handle)
  682. \ingroup API_Data_Interfaces
  683. Return the size of the elements registered into the matrix
  684. designated by \p handle.
  685. \def STARPU_CSR_GET_NNZ(void *interface)
  686. \ingroup API_Data_Interfaces
  687. Return the number of non-zero values in the matrix designated
  688. by \p interface.
  689. \def STARPU_CSR_GET_NROW(void *interface)
  690. \ingroup API_Data_Interfaces
  691. Return the size of the row pointer array of the matrix
  692. designated by \p interface.
  693. \def STARPU_CSR_GET_NZVAL(void *interface)
  694. \ingroup API_Data_Interfaces
  695. Return a pointer to the non-zero values of the matrix
  696. designated by \p interface.
  697. \def STARPU_CSR_GET_NZVAL_DEV_HANDLE(void *interface)
  698. \ingroup API_Data_Interfaces
  699. Return a device handle for the array of non-zero values in the
  700. matrix designated by \p interface. The offset documented below has to be
  701. used in addition to this.
  702. \def STARPU_CSR_GET_COLIND(void *interface)
  703. \ingroup API_Data_Interfaces
  704. Return a pointer to the column index of the matrix designated
  705. by \p interface.
  706. \def STARPU_CSR_GET_COLIND_DEV_HANDLE(void *interface)
  707. \ingroup API_Data_Interfaces
  708. Return a device handle for the column index of the matrix
  709. designated by \p interface. The offset documented below has to be used in
  710. addition to this.
  711. \def STARPU_CSR_GET_ROWPTR(void *interface)
  712. \ingroup API_Data_Interfaces
  713. Return a pointer to the row pointer array of the matrix
  714. designated by \p interface.
  715. \def STARPU_CSR_GET_ROWPTR_DEV_HANDLE(void *interface)
  716. \ingroup API_Data_Interfaces
  717. Return a device handle for the row pointer array of the matrix
  718. designated by \p interface. The offset documented below has to be used in
  719. addition to this.
  720. \def STARPU_CSR_GET_OFFSET(void *interface)
  721. \ingroup API_Data_Interfaces
  722. Return the offset in the arrays (colind, rowptr, nzval) of the
  723. matrix designated by \p interface, to be used with the device handles.
  724. \def STARPU_CSR_GET_FIRSTENTRY(void *interface)
  725. \ingroup API_Data_Interfaces
  726. Return the index at which all arrays (the column indexes, the
  727. row pointers...) of the \p interface start.
  728. \def STARPU_CSR_GET_ELEMSIZE(void *interface)
  729. \ingroup API_Data_Interfaces
  730. Return the size of the elements registered into the matrix
  731. designated by \p interface.
  732. @name Accessing COO Data Interfaces
  733. \ingroup API_Data_Interfaces
  734. \struct starpu_coo_interface
  735. COO Matrices
  736. \ingroup API_Data_Interfaces
  737. \var starpu_coo_interface::id
  738. identifier of the interface
  739. \var starpu_coo_interface::columns
  740. column array of the matrix
  741. \var starpu_coo_interface::rows
  742. row array of the matrix
  743. \var starpu_coo_interface::values
  744. values of the matrix
  745. \var starpu_coo_interface::nx
  746. number of elements on the x-axis of the matrix
  747. \var starpu_coo_interface::ny
  748. number of elements on the y-axis of the matrix
  749. \var starpu_coo_interface::n_values
  750. number of values registered in the matrix
  751. \var starpu_coo_interface::elemsize
  752. size of the elements of the matrix
  753. \def STARPU_COO_GET_COLUMNS(void *interface)
  754. \ingroup API_Data_Interfaces
  755. Return a pointer to the column array of the matrix designated
  756. by \p interface.
  757. \def STARPU_COO_GET_COLUMNS_DEV_HANDLE(void *interface)
  758. \ingroup API_Data_Interfaces
  759. Return a device handle for the column array of the matrix
  760. designated by \p interface, to be used on OpenCL. The offset documented
  761. below has to be used in addition to this.
  762. \def STARPU_COO_GET_ROWS(interface)
  763. \ingroup API_Data_Interfaces
  764. Return a pointer to the rows array of the matrix designated by
  765. \p interface.
  766. \def STARPU_COO_GET_ROWS_DEV_HANDLE(void *interface)
  767. \ingroup API_Data_Interfaces
  768. Return a device handle for the row array of the matrix
  769. designated by \p interface, to be used on OpenCL. The offset documented
  770. below has to be used in addition to this.
  771. \def STARPU_COO_GET_VALUES(interface)
  772. \ingroup API_Data_Interfaces
  773. Return a pointer to the values array of the matrix designated
  774. by \p interface.
  775. \def STARPU_COO_GET_VALUES_DEV_HANDLE(void *interface)
  776. \ingroup API_Data_Interfaces
  777. Return a device handle for the value array of the matrix
  778. designated by \p interface, to be used on OpenCL. The offset documented
  779. below has to be used in addition to this.
  780. \def STARPU_COO_GET_OFFSET(void *interface)
  781. \ingroup API_Data_Interfaces
  782. Return the offset in the arrays of the COO matrix designated by
  783. \p interface.
  784. \def STARPU_COO_GET_NX(interface)
  785. \ingroup API_Data_Interfaces
  786. Return the number of elements on the x-axis of the matrix
  787. designated by \p interface.
  788. \def STARPU_COO_GET_NY(interface)
  789. \ingroup API_Data_Interfaces
  790. Return the number of elements on the y-axis of the matrix
  791. designated by \p interface.
  792. \def STARPU_COO_GET_NVALUES(interface)
  793. \ingroup API_Data_Interfaces
  794. Return the number of values registered in the matrix designated
  795. by \p interface.
  796. \def STARPU_COO_GET_ELEMSIZE(interface)
  797. \ingroup API_Data_Interfaces
  798. Return the size of the elements registered into the matrix
  799. designated by \p interface.
  800. @name Defining Interface
  801. \ingroup API_Data_Interfaces
  802. Applications can provide their own interface as shown in \ref
  803. DefiningANewDataInterface.
  804. \fn uintptr_t starpu_malloc_on_node(unsigned dst_node, size_t size)
  805. \ingroup API_Data_Interfaces
  806. Allocate \p size bytes on node \p dst_node. This returns 0 if
  807. allocation failed, the allocation method should then return <c>-ENOMEM</c> as
  808. allocated size.
  809. \fn void starpu_free_on_node(unsigned dst_node, uintptr_t addr, size_t size)
  810. \ingroup API_Data_Interfaces
  811. Free \p addr of \p size bytes on node \p dst_node.
  812. \fn int starpu_interface_copy(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, void *async_data)
  813. \ingroup API_Data_Interfaces
  814. Copy \p size bytes from byte offset \p src_offset of \p src on \p src_node
  815. to byte offset \p dst_offset of \p dst on \p dst_node. This is to be used in
  816. the any_to_any() copy method, which is provided with the async_data to
  817. be passed to starpu_interface_copy(). this returns <c>-EAGAIN</c> if the
  818. transfer is still ongoing, or 0 if the transfer is already completed.
  819. \fn uint32_t starpu_hash_crc32c_be_n(const void *input, size_t n, uint32_t inputcrc)
  820. \ingroup API_Data_Interfaces
  821. Compute the CRC of a byte buffer seeded by the \p inputcrc
  822. <em>current state</em>. The return value should be considered as the new
  823. <em>current state</em> for future CRC computation. This is used for computing
  824. data size footprint.
  825. \fn uint32_t starpu_hash_crc32c_be(uint32_t input, uint32_t inputcrc)
  826. \ingroup API_Data_Interfaces
  827. Compute the CRC of a 32bit number seeded by the \p inputcrc
  828. <em>current state</em>. The return value should be considered as the new
  829. <em>current state</em> for future CRC computation. This is used for computing
  830. data size footprint.
  831. \fn uint32_t starpu_hash_crc32c_string(const char *str, uint32_t inputcrc)
  832. \ingroup API_Data_Interfaces
  833. Compute the CRC of a string seeded by the \p inputcrc <em>current
  834. state</em>. The return value should be considered as the new <em>current
  835. state</em> for future CRC computation. This is used for computing data
  836. size footprint.
  837. \fn int starpu_data_interface_get_next_id(void)
  838. \ingroup API_Data_Interfaces
  839. Return the next available id for a newly created data interface
  840. (\ref DefiningANewDataInterface).
  841. */