starpu_data_interfaces.h 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2019 Université de Bordeaux
  4. * Copyright (C) 2011-2014,2016,2017 Inria
  5. * Copyright (C) 2010-2015,2017,2019 CNRS
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __STARPU_DATA_INTERFACES_H__
  19. #define __STARPU_DATA_INTERFACES_H__
  20. #include <starpu.h>
  21. #ifdef STARPU_USE_CUDA
  22. /* to use CUDA streams */
  23. # ifdef STARPU_DONT_INCLUDE_CUDA_HEADERS
  24. typedef void *starpu_cudaStream_t;
  25. # else
  26. # include <cuda_runtime.h>
  27. typedef cudaStream_t starpu_cudaStream_t;
  28. # endif
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. /**
  35. @defgroup API_Data_Interfaces Data Interfaces
  36. @brief Data management is done at a high-level in StarPU: rather than
  37. accessing a mere list of contiguous buffers, the tasks may manipulate
  38. data that are described by a high-level construct which we call data
  39. interface.
  40. An example of data interface is the "vector" interface which describes
  41. a contiguous data array on a spefic memory node. This interface is a
  42. simple structure containing the number of elements in the array, the
  43. size of the elements, and the address of the array in the appropriate
  44. address space (this address may be invalid if there is no valid copy
  45. of the array in the memory node). More informations on the data
  46. interfaces provided by StarPU are given in \ref API_Data_Interfaces.
  47. When a piece of data managed by StarPU is used by a task, the task
  48. implementation is given a pointer to an interface describing a valid
  49. copy of the data that is accessible from the current processing unit.
  50. Every worker is associated to a memory node which is a logical
  51. abstraction of the address space from which the processing unit gets
  52. its data. For instance, the memory node associated to the different
  53. CPU workers represents main memory (RAM), the memory node associated
  54. to a GPU is DRAM embedded on the device. Every memory node is
  55. identified by a logical index which is accessible from the
  56. function starpu_worker_get_memory_node(). When registering a piece of
  57. data to StarPU, the specified memory node indicates where the piece of
  58. data initially resides (we also call this memory node the home node of
  59. a piece of data).
  60. In the case of NUMA systems, functions starpu_memory_nodes_numa_devid_to_id()
  61. and starpu_memory_nodes_numa_id_to_devid() can be used to convert from NUMA node
  62. numbers as seen by the Operating System and NUMA node numbers as seen by StarPU.
  63. There are several ways to register a memory region so that it can be
  64. managed by StarPU. StarPU provides data interfaces for vectors, 2D
  65. matrices, 3D matrices as well as BCSR and CSR sparse matrices.
  66. Each data interface is provided with a set of field access functions.
  67. The ones using a <c>void *</c> parameter aimed to be used in codelet
  68. implementations (see for example the code in
  69. \ref VectorScalingUsingStarPUAPI).
  70. Applications can provide their own interface as shown in \ref DefiningANewDataInterface.
  71. @{
  72. */
  73. /**
  74. Define the per-interface methods. If the
  75. starpu_data_copy_methods::any_to_any method is provided, it will be
  76. used by default if no specific method is provided. It can still be
  77. useful to provide more specific method in case of e.g. available
  78. particular CUDA or OpenCL support.
  79. */
  80. struct starpu_data_copy_methods
  81. {
  82. /**
  83. If defined, allow the interface to declare whether it supports
  84. transferring from \p src_interface on node \p src_node to \p
  85. dst_interface on node \p dst_node, run from node \p handling_node.
  86. If not defined, it is assumed that the interface supports all
  87. transfers.
  88. */
  89. int (*can_copy)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, unsigned handling_node);
  90. /**
  91. Define how to copy data from the \p src_interface interface on the
  92. \p src_node CPU node to the \p dst_interface interface on the \p
  93. dst_node CPU node. Return 0 on success.
  94. */
  95. int (*ram_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  96. /**
  97. Define how to copy data from the \p src_interface interface on the
  98. \p src_node CPU node to the \p dst_interface interface on the \p
  99. dst_node CUDA node. Return 0 on success.
  100. */
  101. int (*ram_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  102. /**
  103. Define how to copy data from the \p src_interface interface on the
  104. \p src_node CPU node to the \p dst_interface interface on the \p
  105. dst_node OpenCL node. Return 0 on success.
  106. */
  107. int (*ram_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  108. /**
  109. Define how to copy data from the \p src_interface interface on the
  110. \p src_node CPU node to the \p dst_interface interface on the \p
  111. dst_node MIC node. Return 0 on success.
  112. */
  113. int (*ram_to_mic)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  114. /**
  115. Define how to copy data from the \p src_interface interface on the
  116. \p src_node CUDA node to the \p dst_interface interface on the \p
  117. dst_node CPU node. Return 0 on success.
  118. */
  119. int (*cuda_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  120. /**
  121. Define how to copy data from the \p src_interface interface on the
  122. \p src_node CUDA node to the \p dst_interface interface on the \p
  123. dst_node CUDA node. Return 0 on success.
  124. */
  125. int (*cuda_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  126. /**
  127. Define how to copy data from the \p src_interface interface on the
  128. \p src_node CUDA node to the \p dst_interface interface on the \p
  129. dst_node OpenCL node. Return 0 on success.
  130. */
  131. int (*cuda_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  132. /**
  133. Define how to copy data from the \p src_interface interface on the
  134. \p src_node OpenCL node to the \p dst_interface interface on the
  135. \p dst_node CPU node. Return 0 on success.
  136. */
  137. int (*opencl_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  138. /**
  139. Define how to copy data from the \p src_interface interface on the
  140. \p src_node OpenCL node to the \p dst_interface interface on the
  141. \p dst_node CUDA node. Return 0 on success.
  142. */
  143. int (*opencl_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  144. /**
  145. Define how to copy data from the \p src_interface interface on the
  146. \p src_node OpenCL node to the \p dst_interface interface on the
  147. \p dst_node OpenCL node. Return 0 on success.
  148. */
  149. int (*opencl_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  150. /**
  151. Define how to copy data from the \p src_interface interface on the
  152. \p src_node MIC node to the \p dst_interface interface on the \p
  153. dst_node CPU node. Return 0 on success.
  154. */
  155. int (*mic_to_ram)(void *src_interface, unsigned srd_node, void *dst_interface, unsigned dst_node);
  156. /**
  157. Define how to copy data from the \p src_interface interface on the
  158. \p src_node CPU node to the \p dst_interface interface on the \p
  159. dst_node MPI Slave node. Return 0 on success.
  160. */
  161. int (*ram_to_mpi_ms)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  162. /**
  163. Define how to copy data from the \p src_interface interface on the
  164. \p src_node MPI Slave node to the \p dst_interface interface on
  165. the \p dst_node CPU node. Return 0 on success.
  166. */
  167. int (*mpi_ms_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  168. /**
  169. Define how to copy data from the \p src_interface interface on the
  170. \p src_node MPI Slave node to the \p dst_interface interface on
  171. the \p dst_node MPI Slave node. Return 0 on success.
  172. */
  173. int (*mpi_ms_to_mpi_ms)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  174. #ifdef STARPU_USE_CUDA
  175. /**
  176. Define how to copy data from the \p src_interface interface on the
  177. \p src_node CPU node to the \p dst_interface interface on the \p
  178. dst_node CUDA node, using the given stream. Must return 0 if the
  179. transfer was actually completed completely synchronously, or
  180. <c>-EAGAIN</c> if at least some transfers are still ongoing and
  181. should be awaited for by the core.
  182. */
  183. int (*ram_to_cuda_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, starpu_cudaStream_t stream);
  184. /**
  185. Define how to copy data from the \p src_interface interface on the
  186. \p src_node CUDA node to the \p dst_interface interface on the \p
  187. dst_node CPU node, using the given stream. Must return 0 if the
  188. transfer was actually completed completely synchronously, or
  189. <c>-EAGAIN</c> if at least some transfers are still ongoing and
  190. should be awaited for by the core.
  191. */
  192. int (*cuda_to_ram_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, starpu_cudaStream_t stream);
  193. /**
  194. Define how to copy data from the \p src_interface interface on the
  195. \p src_node CUDA node to the \p dst_interface interface on the \p
  196. dst_node CUDA node, using the given stream. Must return 0 if the
  197. transfer was actually completed completely synchronously, or
  198. <c>-EAGAIN</c> if at least some transfers are still ongoing and
  199. should be awaited for by the core.
  200. */
  201. int (*cuda_to_cuda_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, starpu_cudaStream_t stream);
  202. #else
  203. int (*ram_to_cuda_async)();
  204. int (*cuda_to_ram_async)();
  205. int (*cuda_to_cuda_async)();
  206. #endif
  207. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  208. /**
  209. Define how to copy data from the \p src_interface interface on the
  210. \p src_node CPU node to the \p dst_interface interface on the \p
  211. dst_node OpenCL node, by recording in \p event, a pointer to a
  212. <c>cl_event</c>, the event of the last submitted transfer. Must
  213. return 0 if the transfer was actually completed completely
  214. synchronously, or <c>-EAGAIN</c> if at least some transfers are
  215. still ongoing and should be awaited for by the core.
  216. */
  217. int (*ram_to_opencl_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  218. /**
  219. Define how to copy data from the \p src_interface interface on the
  220. \p src_node OpenCL node to the \p dst_interface interface on the
  221. \p dst_node CPU node, by recording in \p event, a pointer to a
  222. <c>cl_event</c>, the event of the last submitted transfer. Must
  223. return 0 if the transfer was actually completed completely
  224. synchronously, or <c>-EAGAIN</c> if at least some transfers are
  225. still ongoing and should be awaited for by the core.
  226. */
  227. int (*opencl_to_ram_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  228. /**
  229. Define how to copy data from the \p src_interface interface on the
  230. \p src_node OpenCL node to the \p dst_interface interface on the
  231. \p dst_node OpenCL node, by recording in \p event, a pointer to a
  232. <c>cl_event</c>, the event of the last submitted transfer. Must
  233. return 0 if the transfer was actually completed completely
  234. synchronously, or <c>-EAGAIN</c> if at least some transfers are
  235. still ongoing and should be awaited for by the core.
  236. */
  237. int (*opencl_to_opencl_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  238. #else
  239. int (*ram_to_opencl_async)();
  240. int (*opencl_to_ram_async)();
  241. int (*opencl_to_opencl_async)();
  242. #endif
  243. /**
  244. Define how to copy data from the \p src_interface interface on the
  245. \p src_node CPU node to the \p dst_interface interface on the \p
  246. dst_node MPI Slave node, with the given even. Must return 0 if the
  247. transfer was actually completed completely synchronously, or
  248. <c>-EAGAIN</c> if at least some transfers are still ongoing and
  249. should be awaited for by the core.
  250. */
  251. int (*ram_to_mpi_ms_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void * event);
  252. /**
  253. Define how to copy data from the \p src_interface interface on the
  254. \p src_node MPI Slave node to the \p dst_interface interface on
  255. the \p dst_node CPU node, with the given event. Must return 0 if
  256. the transfer was actually completed completely synchronously, or
  257. <c>-EAGAIN</c> if at least some transfers are still ongoing and
  258. should be awaited for by the core.
  259. */
  260. int (*mpi_ms_to_ram_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void * event);
  261. /**
  262. Define how to copy data from the \p src_interface interface on the
  263. \p src_node MPI Slave node to the \p dst_interface interface on
  264. the \p dst_node MPI Slave node, using the given stream. Must
  265. return 0 if the transfer was actually completed completely
  266. synchronously, or <c>-EAGAIN</c> if at least some transfers are
  267. still ongoing and should be awaited for by the core.
  268. */
  269. int (*mpi_ms_to_mpi_ms_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void * event);
  270. /**
  271. Define how to copy data from the \p src_interface interface on the
  272. \p src_node CPU node to the \p dst_interface interface on the \p
  273. dst_node MIC node. Must return 0 if the transfer was actually
  274. completed completely synchronously, or <c>-EAGAIN</c> if at least
  275. some transfers are still ongoing and should be awaited for by the
  276. core.
  277. */
  278. int (*ram_to_mic_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  279. /**
  280. Define how to copy data from the \p src_interface interface on the
  281. \p src_node MIC node to the \p dst_interface interface on the \p
  282. dst_node CPU node. Must return 0 if the transfer was actually
  283. completed completely synchronously, or <c>-EAGAIN</c> if at least
  284. some transfers are still ongoing and should be awaited for by the
  285. core.
  286. */
  287. int (*mic_to_ram_async)(void *src_interface, unsigned srd_node, void *dst_interface, unsigned dst_node);
  288. /**
  289. Define how to copy data from the \p src_interface interface on the
  290. \p src_node node to the \p dst_interface interface on the \p
  291. dst_node node. This is meant to be implemented through the
  292. starpu_interface_copy() helper, to which async_data should be
  293. passed as such, and will be used to manage asynchronicity. This
  294. must return <c>-EAGAIN</c> if any of the starpu_interface_copy()
  295. calls has returned <c>-EAGAIN</c> (i.e. at least some transfer is
  296. still ongoing), and return 0 otherwise.
  297. This can only be implemented if the interface has ready-to-send
  298. data blocks. If the interface is more involved than
  299. this, i.e. it needs to collect pieces of data before
  300. transferring, starpu_data_interface_ops::pack_data and
  301. starpu_data_interface_ops::unpack_data should be implemented instead,
  302. and the core will just transfer the resulting data buffer.
  303. */
  304. int (*any_to_any)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
  305. };
  306. /**
  307. Identifier for all predefined StarPU data interfaces
  308. */
  309. enum starpu_data_interface_id
  310. {
  311. STARPU_UNKNOWN_INTERFACE_ID = -1, /**< Unknown interface */
  312. STARPU_MATRIX_INTERFACE_ID=0, /**< Identifier for the matrix data interface */
  313. STARPU_BLOCK_INTERFACE_ID=1, /**< Identifier for the block data interface*/
  314. STARPU_VECTOR_INTERFACE_ID=2, /**< Identifier for the vector data interface*/
  315. STARPU_CSR_INTERFACE_ID=3, /**< Identifier for the CSR data interface*/
  316. STARPU_BCSR_INTERFACE_ID=4, /**< Identifier for the BCSR data interface*/
  317. STARPU_VARIABLE_INTERFACE_ID=5, /**< Identifier for the variable data interface*/
  318. STARPU_VOID_INTERFACE_ID=6, /**< Identifier for the void data interface*/
  319. STARPU_MULTIFORMAT_INTERFACE_ID=7, /**< Identifier for the multiformat data interface*/
  320. STARPU_COO_INTERFACE_ID=8, /**< Identifier for the COO data interface*/
  321. STARPU_TENSOR_INTERFACE_ID=9, /**< Identifier for the block data interface*/
  322. STARPU_MAX_INTERFACE_ID=10 /**< Maximum number of data interfaces */
  323. };
  324. /**
  325. Per-interface data management methods.
  326. */
  327. struct starpu_data_interface_ops
  328. {
  329. /**
  330. Register an existing interface into a data handle.
  331. This iterates over all memory nodes to initialize all fields of the data
  332. interface on each of them. Since data is not allocated yet except on the
  333. home node, pointers should be left as NULL except on the \p home_node, for
  334. which the pointers should be copied from the given \p data_interface, which
  335. was filled with the application's pointers.
  336. This method is mandatory.
  337. */
  338. void (*register_data_handle) (starpu_data_handle_t handle, unsigned home_node, void *data_interface);
  339. /**
  340. Allocate data for the interface on a given node. This should use
  341. starpu_malloc_on_node() to perform the allocation(s), and fill the pointers
  342. in the data interface. It should return the size of the allocated memory, or
  343. -ENOMEM if memory could not be allocated.
  344. Note that the memory node can be CPU memory, GPU memory, or even disk
  345. area. The result returned by starpu_malloc_on_node() should be just
  346. stored as uintptr_t without trying to interpret it since it may be a
  347. GPU pointer, a disk descriptor, etc.
  348. This method is mandatory to be able to support memory nodes.
  349. */
  350. starpu_ssize_t (*allocate_data_on_node) (void *data_interface, unsigned node);
  351. /**
  352. Free data of the interface on a given node.
  353. This method is mandatory to be able to support memory nodes.
  354. */
  355. void (*free_data_on_node) (void *data_interface, unsigned node);
  356. /**
  357. Initialize the interface.
  358. This method is optional. It is called when initializing the
  359. handler on all the memory nodes.
  360. */
  361. void (*init) (void *data_interface);
  362. /**
  363. Struct with pointer to functions for performing ram/cuda/opencl synchronous and asynchronous transfers.
  364. This field is mandatory to be able to support memory
  365. nodes, except disk nodes which can be supported by just
  366. implementing starpu_data_interface_ops::pack_data and
  367. starpu_data_interface_ops::unpack_data.
  368. */
  369. const struct starpu_data_copy_methods *copy_methods;
  370. /**
  371. @deprecated
  372. Use starpu_data_interface_ops::to_pointer instead.
  373. Return the current pointer (if any) for the handle on the given node.
  374. This method is only required if starpu_data_interface_ops::to_pointer
  375. is not implemented.
  376. */
  377. void * (*handle_to_pointer) (starpu_data_handle_t handle, unsigned node);
  378. /**
  379. Return the current pointer (if any) for the given interface on the given node.
  380. This method is only required for starpu_data_handle_to_pointer()
  381. and starpu_data_get_local_ptr(), and for disk support.
  382. */
  383. void * (*to_pointer) (void *data_interface, unsigned node);
  384. /**
  385. Return whether the given \p ptr is within the data for the given interface on the given node.
  386. This method is optional, as it is only used for coherency checks.
  387. */
  388. int (*pointer_is_inside) (void *data_interface, unsigned node, void *ptr);
  389. /**
  390. Return an estimation of the size of data, for performance models and tracing feedback.
  391. */
  392. size_t (*get_size) (starpu_data_handle_t handle);
  393. /**
  394. Return an estimation of the size of allocated data, for allocation
  395. management.
  396. If not specified, the starpu_data_interface_ops::get_size method is
  397. used instead.
  398. */
  399. size_t (*get_alloc_size) (starpu_data_handle_t handle);
  400. /**
  401. Return the maximum size that the data may need to increase to. For
  402. instance, in the case of compressed matrix tiles this is the size
  403. when the block is fully dense.
  404. This is currently only used for feedback tools.
  405. */
  406. size_t (*get_max_size) (starpu_data_handle_t handle);
  407. /**
  408. Return a 32bit footprint which characterizes the data size and layout (nx, ny, ld, elemsize, etc.), required for indexing performance models.
  409. starpu_hash_crc32c_be() and alike can be used to produce this 32bit value from various types of values.
  410. */
  411. uint32_t (*footprint) (starpu_data_handle_t handle);
  412. /**
  413. Return a 32bit footprint which characterizes the data allocation, to be used
  414. for indexing allocation cache.
  415. If not specified, the starpu_data_interface_ops::footprint method is
  416. used instead.
  417. */
  418. uint32_t (*alloc_footprint) (starpu_data_handle_t handle);
  419. /**
  420. Compare the data size and layout of two interfaces (nx, ny, ld, elemsize,
  421. etc.), to be used for indexing performance models. It should return 1 if
  422. the two interfaces size and layout match computation-wise, and 0 otherwise.
  423. */
  424. int (*compare) (void *data_interface_a, void *data_interface_b);
  425. /**
  426. Compare the data allocation of two interfaces etc.), to be used for indexing
  427. allocation cache. It should return
  428. 1 if the two interfaces are allocation-compatible, i.e. basically have the same alloc_size, and 0 otherwise.
  429. If not specified, the starpu_data_interface_ops::compare method is
  430. used instead.
  431. */
  432. int (*alloc_compare) (void *data_interface_a, void *data_interface_b);
  433. /**
  434. Dump the sizes of a handle to a file.
  435. This is required for performance models
  436. */
  437. void (*display) (starpu_data_handle_t handle, FILE *f);
  438. /**
  439. Describe the data into a string in a brief way, such as one
  440. letter to describe the type of data, and the data
  441. dimensions.
  442. This is required for tracing feedback.
  443. */
  444. starpu_ssize_t (*describe) (void *data_interface, char *buf, size_t size);
  445. /**
  446. An identifier that is unique to each interface.
  447. */
  448. enum starpu_data_interface_id interfaceid;
  449. /**
  450. Size of the interface data descriptor.
  451. */
  452. size_t interface_size;
  453. /**
  454. */
  455. char is_multiformat;
  456. /**
  457. If set to non-zero, StarPU will never try to reuse an allocated
  458. buffer for a different handle. This can be notably useful for
  459. application-defined interfaces which have a dynamic size, and for
  460. which it thus does not make sense to reuse the buffer since will
  461. probably not have the proper size.
  462. */
  463. char dontcache;
  464. /**
  465. */
  466. struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
  467. /**
  468. Pack the data handle into a contiguous buffer at the address
  469. allocated with <c>starpu_malloc_flags(ptr, size, 0)</c> (and thus
  470. returned in \p ptr) and set the size of the newly created buffer
  471. in \p count. If \p ptr is <c>NULL</c>, the function should not
  472. copy the data in the buffer but just set count to the size of the
  473. buffer which would have been allocated. The special value -1
  474. indicates the size is yet unknown.
  475. This method (and starpu_data_interface_ops::unpack_data) is required
  476. for disk support if the starpu_data_copy_methods::any_to_any method
  477. is not implemented (because the in-memory data layout is too
  478. complex).
  479. This is also required for MPI support if there is no registered MPI data type.
  480. */
  481. int (*pack_data) (starpu_data_handle_t handle, unsigned node, void **ptr, starpu_ssize_t *count);
  482. /**
  483. Unpack the data handle from the contiguous buffer at the address
  484. \p ptr of size \p count.
  485. The memory at the address \p ptr should be freed after the data unpacking operation.
  486. */
  487. int (*unpack_data) (starpu_data_handle_t handle, unsigned node, void *ptr, size_t count);
  488. /**
  489. Name of the interface
  490. */
  491. char *name;
  492. };
  493. /**
  494. @name Basic API
  495. @{
  496. */
  497. /**
  498. Register a piece of data into the handle located at the
  499. \p handleptr address. The \p data_interface buffer contains the initial
  500. description of the data in the \p home_node. The \p ops argument is a
  501. pointer to a structure describing the different methods used to
  502. manipulate this type of interface. See starpu_data_interface_ops for
  503. more details on this structure.
  504. If \p home_node is -1, StarPU will automatically allocate the memory when
  505. it is used for the first time in write-only mode. Once such data
  506. handle has been automatically allocated, it is possible to access it
  507. using any access mode.
  508. Note that StarPU supplies a set of predefined types of interface (e.g.
  509. vector or matrix) which can be registered by the means of helper
  510. functions (e.g. starpu_vector_data_register() or
  511. starpu_matrix_data_register()).
  512. */
  513. void starpu_data_register(starpu_data_handle_t *handleptr, int home_node, void *data_interface, struct starpu_data_interface_ops *ops);
  514. /**
  515. Register that a buffer for \p handle on \p node will be set. This is typically
  516. used by starpu_*_ptr_register helpers before setting the interface pointers for
  517. this node, to tell the core that that is now allocated.
  518. */
  519. void starpu_data_ptr_register(starpu_data_handle_t handle, unsigned node);
  520. /**
  521. Register a new piece of data into the handle \p handledst with the
  522. same interface as the handle \p handlesrc.
  523. */
  524. void starpu_data_register_same(starpu_data_handle_t *handledst, starpu_data_handle_t handlesrc);
  525. /**
  526. Return the pointer associated with \p handle on node \p node or <c>NULL</c>
  527. if handle’s interface does not support this operation or data for this
  528. \p handle is not allocated on that \p node.
  529. */
  530. void *starpu_data_handle_to_pointer(starpu_data_handle_t handle, unsigned node);
  531. /**
  532. Return whether the given \p ptr is within the data for \p handle on node \p
  533. node (1) or not (0). If the handle interface does not support this operation,
  534. and thus the result is unknown, -1 is returned.
  535. */
  536. int starpu_data_pointer_is_inside(starpu_data_handle_t handle, unsigned node, void *ptr);
  537. /**
  538. Return the local pointer associated with \p handle or <c>NULL</c> if
  539. \p handle’s interface does not have any data allocated locally.
  540. */
  541. void *starpu_data_get_local_ptr(starpu_data_handle_t handle);
  542. /**
  543. Return the interface associated with \p handle on \p memory_node.
  544. */
  545. void *starpu_data_get_interface_on_node(starpu_data_handle_t handle, unsigned memory_node);
  546. /**
  547. Return the unique identifier of the interface associated with
  548. the given \p handle.
  549. */
  550. enum starpu_data_interface_id starpu_data_get_interface_id(starpu_data_handle_t handle);
  551. /**
  552. Execute the packing operation of the interface of the data
  553. registered at \p handle (see starpu_data_interface_ops). This
  554. packing operation must allocate a buffer large enough at \p ptr and copy
  555. into the newly allocated buffer the data associated to \p handle. \p count
  556. will be set to the size of the allocated buffer. If \p ptr is <c>NULL</c>, the
  557. function should not copy the data in the buffer but just set \p count to
  558. the size of the buffer which would have been allocated. The special
  559. value -1 indicates the size is yet unknown.
  560. */
  561. int starpu_data_pack(starpu_data_handle_t handle, void **ptr, starpu_ssize_t *count);
  562. /**
  563. Unpack in handle the data located at \p ptr of size \p count as
  564. described by the interface of the data. The interface registered at
  565. \p handle must define a unpacking operation (see
  566. starpu_data_interface_ops).
  567. */
  568. int starpu_data_unpack(starpu_data_handle_t handle, void *ptr, size_t count);
  569. /**
  570. Return the size of the data associated with \p handle.
  571. */
  572. size_t starpu_data_get_size(starpu_data_handle_t handle);
  573. /**
  574. Return the size of the allocated data associated with \p handle.
  575. */
  576. size_t starpu_data_get_alloc_size(starpu_data_handle_t handle);
  577. /**
  578. Return the maximum size that the \p handle data may need to increase to.
  579. */
  580. starpu_ssize_t starpu_data_get_max_size(starpu_data_handle_t handle);
  581. /**
  582. Return the handle corresponding to the data pointed to by the \p ptr host pointer.
  583. */
  584. starpu_data_handle_t starpu_data_lookup(const void *ptr);
  585. int starpu_data_get_home_node(starpu_data_handle_t handle);
  586. /**
  587. Return the next available id for a newly created data interface
  588. (\ref DefiningANewDataInterface).
  589. */
  590. int starpu_data_interface_get_next_id(void);
  591. /**
  592. Copy \p size bytes from byte offset \p src_offset of \p src on \p src_node
  593. to byte offset \p dst_offset of \p dst on \p dst_node. This is to be used in
  594. the starpu_data_copy_methods::any_to_any copy method, which is provided with \p async_data to
  595. be passed to starpu_interface_copy(). this returns <c>-EAGAIN</c> if the
  596. transfer is still ongoing, or 0 if the transfer is already completed.
  597. */
  598. 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);
  599. /**
  600. When an asynchonous implementation of the data transfer is implemented, the call
  601. to the underlying CUDA, OpenCL, etc. call should be surrounded
  602. by calls to starpu_interface_start_driver_copy_async() and
  603. starpu_interface_end_driver_copy_async(), so that it is recorded in offline
  604. execution traces, and the timing of the submission is checked. \p start must
  605. point to a variable whose value will be passed unchanged to
  606. starpu_interface_end_driver_copy_async().
  607. */
  608. void starpu_interface_start_driver_copy_async(unsigned src_node, unsigned dst_node, double *start);
  609. /**
  610. See starpu_interface_start_driver_copy_async().
  611. */
  612. void starpu_interface_end_driver_copy_async(unsigned src_node, unsigned dst_node, double start);
  613. /**
  614. Record in offline execution traces the copy of \p size bytes from
  615. node \p src_node to node \p dst_node
  616. */
  617. void starpu_interface_data_copy(unsigned src_node, unsigned dst_node, size_t size);
  618. /**
  619. Allocate \p size bytes on node \p dst_node with the given allocation \p flags. This returns 0 if
  620. allocation failed, the allocation method should then return <c>-ENOMEM</c> as
  621. allocated size. Deallocation must be done with starpu_free_on_node_flags().
  622. */
  623. uintptr_t starpu_malloc_on_node_flags(unsigned dst_node, size_t size, int flags);
  624. /**
  625. Allocate \p size bytes on node \p dst_node with the default allocation flags. This returns 0 if
  626. allocation failed, the allocation method should then return <c>-ENOMEM</c> as
  627. allocated size. Deallocation must be done with starpu_free_on_node().
  628. */
  629. uintptr_t starpu_malloc_on_node(unsigned dst_node, size_t size);
  630. /**
  631. Free \p addr of \p size bytes on node \p dst_node which was previously allocated
  632. with starpu_malloc_on_node_flags() with the given allocation \p flags.
  633. */
  634. void starpu_free_on_node_flags(unsigned dst_node, uintptr_t addr, size_t size, int flags);
  635. /**
  636. Free \p addr of \p size bytes on node \p dst_node which was previously allocated
  637. with starpu_malloc_on_node().
  638. */
  639. void starpu_free_on_node(unsigned dst_node, uintptr_t addr, size_t size);
  640. /**
  641. Define the default flags for allocations performed by starpu_malloc_on_node() and
  642. starpu_free_on_node(). The default is \ref STARPU_MALLOC_PINNED | \ref STARPU_MALLOC_COUNT.
  643. */
  644. void starpu_malloc_on_node_set_default_flags(unsigned node, int flags);
  645. /** @} */
  646. /**
  647. @name Accessing Matrix Data Interfaces
  648. @{
  649. */
  650. extern struct starpu_data_interface_ops starpu_interface_matrix_ops;
  651. /**
  652. Matrix interface for dense matrices
  653. */
  654. struct starpu_matrix_interface
  655. {
  656. enum starpu_data_interface_id id; /**< Identifier of the interface */
  657. uintptr_t ptr; /**< local pointer of the matrix */
  658. uintptr_t dev_handle; /**< device handle of the matrix */
  659. size_t offset; /**< offset in the matrix */
  660. uint32_t nx; /**< number of elements on the x-axis of the matrix */
  661. uint32_t ny; /**< number of elements on the y-axis of the matrix */
  662. uint32_t ld; /**< number of elements between each row of the
  663. matrix. Maybe be equal to starpu_matrix_interface::nx
  664. when there is no padding.
  665. */
  666. size_t elemsize; /**< size of the elements of the matrix */
  667. size_t allocsize; /**< size actually currently allocated */
  668. };
  669. /**
  670. Register the \p nx x \p ny 2D matrix of \p elemsize-byte elements pointed
  671. by \p ptr and initialize \p handle to represent it. \p ld specifies the number
  672. of elements between rows. a value greater than \p nx adds padding, which
  673. can be useful for alignment purposes.
  674. Here an example of how to use the function.
  675. \code{.c}
  676. float *matrix;
  677. starpu_data_handle_t matrix_handle;
  678. matrix = (float*)malloc(width * height * sizeof(float));
  679. starpu_matrix_data_register(&matrix_handle, STARPU_MAIN_RAM, (uintptr_t)matrix, width, width, height, sizeof(float));
  680. \endcode
  681. */
  682. void starpu_matrix_data_register(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t ld, uint32_t nx, uint32_t ny, size_t elemsize);
  683. /**
  684. Similar to starpu_matrix_data_register, but additionally specifies which
  685. allocation size should be used instead of the initial nx*ny*elemsize.
  686. */
  687. void starpu_matrix_data_register_allocsize(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t ld, uint32_t nx, uint32_t ny, size_t elemsize, size_t allocsize);
  688. /**
  689. Register into the \p handle that to store data on node \p node it should use the
  690. buffer located at \p ptr, or device handle \p dev_handle and offset \p offset
  691. (for OpenCL, notably), with \p ld elements between rows.
  692. */
  693. void starpu_matrix_ptr_register(starpu_data_handle_t handle, unsigned node, uintptr_t ptr, uintptr_t dev_handle, size_t offset, uint32_t ld);
  694. /**
  695. Return the number of elements on the x-axis of the matrix
  696. designated by \p handle.
  697. */
  698. uint32_t starpu_matrix_get_nx(starpu_data_handle_t handle);
  699. /**
  700. Return the number of elements on the y-axis of the matrix
  701. designated by \p handle.
  702. */
  703. uint32_t starpu_matrix_get_ny(starpu_data_handle_t handle);
  704. /**
  705. Return the number of elements between each row of the matrix
  706. designated by \p handle. Maybe be equal to nx when there is no padding.
  707. */
  708. uint32_t starpu_matrix_get_local_ld(starpu_data_handle_t handle);
  709. /**
  710. Return the local pointer associated with \p handle.
  711. */
  712. uintptr_t starpu_matrix_get_local_ptr(starpu_data_handle_t handle);
  713. /**
  714. Return the size of the elements registered into the matrix
  715. designated by \p handle.
  716. */
  717. size_t starpu_matrix_get_elemsize(starpu_data_handle_t handle);
  718. /**
  719. Return the allocated size of the matrix designated by \p handle.
  720. */
  721. size_t starpu_matrix_get_allocsize(starpu_data_handle_t handle);
  722. #if defined(STARPU_HAVE_STATEMENT_EXPRESSIONS) && defined(STARPU_DEBUG)
  723. #define STARPU_MATRIX_CHECK(interface) STARPU_ASSERT_MSG((((struct starpu_matrix_interface *)(interface))->id) == STARPU_MATRIX_INTERFACE_ID, "Error. The given data is not a matrix.")
  724. #define STARPU_MATRIX_GET_PTR(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->ptr) ; })
  725. #define STARPU_MATRIX_GET_DEV_HANDLE(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->dev_handle) ; })
  726. #define STARPU_MATRIX_GET_OFFSET(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->offset) ; })
  727. #define STARPU_MATRIX_GET_NX(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->nx) ; })
  728. #define STARPU_MATRIX_GET_NY(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->ny) ; })
  729. #define STARPU_MATRIX_GET_LD(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->ld) ; })
  730. #define STARPU_MATRIX_GET_ELEMSIZE(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->elemsize) ; })
  731. #define STARPU_MATRIX_GET_ALLOCSIZE(interface) ({ STARPU_MATRIX_CHECK(interface); (((struct starpu_matrix_interface *)(interface))->allocsize) ; })
  732. #else
  733. /**
  734. Return a pointer to the matrix designated by \p interface, valid
  735. on CPUs and CUDA devices only. For OpenCL devices, the device handle
  736. and offset need to be used instead.
  737. */
  738. #define STARPU_MATRIX_GET_PTR(interface) (((struct starpu_matrix_interface *)(interface))->ptr)
  739. /**
  740. Return a device handle for the matrix designated by \p interface,
  741. to be used with OpenCL. The offset returned by
  742. ::STARPU_MATRIX_GET_OFFSET has to be used in
  743. addition to this.
  744. */
  745. #define STARPU_MATRIX_GET_DEV_HANDLE(interface) (((struct starpu_matrix_interface *)(interface))->dev_handle)
  746. /**
  747. Return the offset in the matrix designated by \p interface, to be
  748. used with the device handle.
  749. */
  750. #define STARPU_MATRIX_GET_OFFSET(interface) (((struct starpu_matrix_interface *)(interface))->offset)
  751. /**
  752. Return the number of elements on the x-axis of the matrix
  753. designated by \p interface.
  754. */
  755. #define STARPU_MATRIX_GET_NX(interface) (((struct starpu_matrix_interface *)(interface))->nx)
  756. /**
  757. Return the number of elements on the y-axis of the matrix
  758. designated by \p interface.
  759. */
  760. #define STARPU_MATRIX_GET_NY(interface) (((struct starpu_matrix_interface *)(interface))->ny)
  761. /**
  762. Return the number of elements between each row of the matrix
  763. designated by \p interface. May be equal to nx when there is no padding.
  764. */
  765. #define STARPU_MATRIX_GET_LD(interface) (((struct starpu_matrix_interface *)(interface))->ld)
  766. /**
  767. Return the size of the elements registered into the matrix
  768. designated by \p interface.
  769. */
  770. #define STARPU_MATRIX_GET_ELEMSIZE(interface) (((struct starpu_matrix_interface *)(interface))->elemsize)
  771. /**
  772. Return the allocated size of the matrix designated by \p interface.
  773. */
  774. #define STARPU_MATRIX_GET_ALLOCSIZE(interface) (((struct starpu_matrix_interface *)(interface))->allocsize)
  775. #endif
  776. /**
  777. Set the number of elements on the x-axis of the matrix
  778. designated by \p interface.
  779. */
  780. #define STARPU_MATRIX_SET_NX(interface, newnx) do { \
  781. STARPU_MATRIX_CHECK(interface); \
  782. (((struct starpu_matrix_interface *)(interface))->nx) = (newnx); \
  783. } while (0)
  784. /**
  785. Set the number of elements on the y-axis of the matrix
  786. designated by \p interface.
  787. */
  788. #define STARPU_MATRIX_SET_NY(interface, newny) do { \
  789. STARPU_MATRIX_CHECK(interface); \
  790. (((struct starpu_matrix_interface *)(interface))->ny) = (newny); \
  791. } while(0)
  792. /**
  793. Set the number of elements between each row of the matrix
  794. designated by \p interface. May be set to the same value as nx when there is
  795. no padding.
  796. */
  797. #define STARPU_MATRIX_SET_LD(interface, newld) do { \
  798. STARPU_MATRIX_CHECK(interface); \
  799. (((struct starpu_matrix_interface *)(interface))->ld) = (newld); \
  800. } while(0)
  801. /** @} */
  802. /**
  803. @name Accessing COO Data Interfaces
  804. @{
  805. */
  806. extern struct starpu_data_interface_ops starpu_interface_coo_ops;
  807. /**
  808. COO Matrices
  809. */
  810. struct starpu_coo_interface
  811. {
  812. enum starpu_data_interface_id id; /**< identifier of the interface */
  813. uint32_t *columns; /**< column array of the matrix */
  814. uint32_t *rows; /**< row array of the matrix */
  815. uintptr_t values; /**< values of the matrix */
  816. uint32_t nx; /**< number of elements on the x-axis of the matrix */
  817. uint32_t ny; /**< number of elements on the y-axis of the matrix */
  818. uint32_t n_values; /**< number of values registered in the matrix */
  819. size_t elemsize; /**< size of the elements of the matrix */
  820. };
  821. /**
  822. Register the \p nx x \p ny 2D matrix given in the COO format, using the
  823. \p columns, \p rows, \p values arrays, which must have \p n_values elements of
  824. size \p elemsize. Initialize \p handleptr.
  825. */
  826. void starpu_coo_data_register(starpu_data_handle_t *handleptr, int home_node, uint32_t nx, uint32_t ny, uint32_t n_values, uint32_t *columns, uint32_t *rows, uintptr_t values, size_t elemsize);
  827. /**
  828. Return a pointer to the column array of the matrix designated
  829. by \p interface.
  830. */
  831. #define STARPU_COO_GET_COLUMNS(interface) (((struct starpu_coo_interface *)(interface))->columns)
  832. /**
  833. Return a device handle for the column array of the matrix
  834. designated by \p interface, to be used with OpenCL. The offset
  835. returned by ::STARPU_COO_GET_OFFSET has to be used in addition to
  836. this.
  837. */
  838. #define STARPU_COO_GET_COLUMNS_DEV_HANDLE(interface) (((struct starpu_coo_interface *)(interface))->columns)
  839. /**
  840. Return a pointer to the rows array of the matrix designated by
  841. \p interface.
  842. */
  843. #define STARPU_COO_GET_ROWS(interface) (((struct starpu_coo_interface *)(interface))->rows)
  844. /**
  845. Return a device handle for the row array of the matrix
  846. designated by \p interface, to be used on OpenCL. The offset returned
  847. by ::STARPU_COO_GET_OFFSET has to be used in addition to this.
  848. */
  849. #define STARPU_COO_GET_ROWS_DEV_HANDLE(interface) (((struct starpu_coo_interface *)(interface))->rows)
  850. /**
  851. Return a pointer to the values array of the matrix designated
  852. by \p interface.
  853. */
  854. #define STARPU_COO_GET_VALUES(interface) (((struct starpu_coo_interface *)(interface))->values)
  855. /**
  856. Return a device handle for the value array of the matrix
  857. designated by \p interface, to be used on OpenCL. The offset returned
  858. by ::STARPU_COO_GET_OFFSET has to be used in addition to this.
  859. */
  860. #define STARPU_COO_GET_VALUES_DEV_HANDLE(interface) (((struct starpu_coo_interface *)(interface))->values)
  861. /**
  862. Return the offset in the arrays of the COO matrix designated by
  863. \p interface.
  864. */
  865. #define STARPU_COO_GET_OFFSET 0
  866. /**
  867. Return the number of elements on the x-axis of the matrix
  868. designated by \p interface.
  869. */
  870. #define STARPU_COO_GET_NX(interface) (((struct starpu_coo_interface *)(interface))->nx)
  871. /**
  872. Return the number of elements on the y-axis of the matrix
  873. designated by \p interface.
  874. */
  875. #define STARPU_COO_GET_NY(interface) (((struct starpu_coo_interface *)(interface))->ny)
  876. /**
  877. Return the number of values registered in the matrix designated
  878. by \p interface.
  879. */
  880. #define STARPU_COO_GET_NVALUES(interface) (((struct starpu_coo_interface *)(interface))->n_values)
  881. /**
  882. Return the size of the elements registered into the matrix
  883. designated by \p interface.
  884. */
  885. #define STARPU_COO_GET_ELEMSIZE(interface) (((struct starpu_coo_interface *)(interface))->elemsize)
  886. /** @} */
  887. /**
  888. @name Block Data Interface
  889. @{
  890. */
  891. extern struct starpu_data_interface_ops starpu_interface_block_ops;
  892. /* TODO: rename to 3dmatrix? */
  893. /* TODO: add allocsize support */
  894. /**
  895. Block interface for 3D dense blocks
  896. */
  897. struct starpu_block_interface
  898. {
  899. enum starpu_data_interface_id id; /**< identifier of the interface */
  900. uintptr_t ptr; /**< local pointer of the block */
  901. uintptr_t dev_handle; /**< device handle of the block. */
  902. size_t offset; /**< offset in the block. */
  903. uint32_t nx; /**< number of elements on the x-axis of the block. */
  904. uint32_t ny; /**< number of elements on the y-axis of the block. */
  905. uint32_t nz; /**< number of elements on the z-axis of the block. */
  906. uint32_t ldy; /**< number of elements between two lines */
  907. uint32_t ldz; /**< number of elements between two planes */
  908. size_t elemsize; /**< size of the elements of the block. */
  909. };
  910. /**
  911. Register the \p nx x \p ny x \p nz 3D matrix of \p elemsize byte elements
  912. pointed by \p ptr and initialize \p handle to represent it. Again, \p ldy and
  913. \p ldz specify the number of elements between rows and between z planes.
  914. Here an example of how to use the function.
  915. \code{.c}
  916. float *block;
  917. starpu_data_handle_t block_handle;
  918. block = (float*)malloc(nx*ny*nz*sizeof(float));
  919. starpu_block_data_register(&block_handle, STARPU_MAIN_RAM, (uintptr_t)block, nx, nx*ny, nx, ny, nz, sizeof(float));
  920. \endcode
  921. */
  922. void starpu_block_data_register(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx, uint32_t ny, uint32_t nz, size_t elemsize);
  923. /**
  924. Register into the \p handle that to store data on node \p node it should use the
  925. buffer located at \p ptr, or device handle \p dev_handle and offset \p offset
  926. (for OpenCL, notably), with \p ldy elements between rows and \p ldz
  927. elements between z planes.
  928. */
  929. void starpu_block_ptr_register(starpu_data_handle_t handle, unsigned node, uintptr_t ptr, uintptr_t dev_handle, size_t offset, uint32_t ldy, uint32_t ldz);
  930. /**
  931. Return the number of elements on the x-axis of the block
  932. designated by \p handle.
  933. */
  934. uint32_t starpu_block_get_nx(starpu_data_handle_t handle);
  935. /**
  936. Return the number of elements on the y-axis of the block
  937. designated by \p handle.
  938. */
  939. uint32_t starpu_block_get_ny(starpu_data_handle_t handle);
  940. /**
  941. Return the number of elements on the z-axis of the block
  942. designated by \p handle.
  943. */
  944. uint32_t starpu_block_get_nz(starpu_data_handle_t handle);
  945. /**
  946. Return the number of elements between each row of the block
  947. designated by \p handle, in the format of the current memory node.
  948. */
  949. uint32_t starpu_block_get_local_ldy(starpu_data_handle_t handle);
  950. /**
  951. Return the number of elements between each z plane of the block
  952. designated by \p handle, in the format of the current memory node.
  953. */
  954. uint32_t starpu_block_get_local_ldz(starpu_data_handle_t handle);
  955. /**
  956. Return the local pointer associated with \p handle.
  957. */
  958. uintptr_t starpu_block_get_local_ptr(starpu_data_handle_t handle);
  959. /**
  960. Return the size of the elements of the block designated by
  961. \p handle.
  962. */
  963. size_t starpu_block_get_elemsize(starpu_data_handle_t handle);
  964. #if defined(STARPU_HAVE_STATEMENT_EXPRESSIONS) && defined(STARPU_DEBUG)
  965. #define STARPU_BLOCK_CHECK(interface) STARPU_ASSERT_MSG((((struct starpu_block_interface *)(interface))->id) == STARPU_BLOCK_INTERFACE_ID, "Error. The given data is not a block.")
  966. #define STARPU_BLOCK_GET_PTR(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->ptr) ; })
  967. #define STARPU_BLOCK_GET_DEV_HANDLE(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->dev_handle) ; })
  968. #define STARPU_BLOCK_GET_OFFSET(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->offset) ; })
  969. #define STARPU_BLOCK_GET_NX(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->nx) ; })
  970. #define STARPU_BLOCK_GET_NY(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->ny) ; })
  971. #define STARPU_BLOCK_GET_NZ(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->nz) ; })
  972. #define STARPU_BLOCK_GET_LDY(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->ldy) ; })
  973. #define STARPU_BLOCK_GET_LDZ(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->ldz) ; })
  974. #define STARPU_BLOCK_GET_ELEMSIZE(interface) ({ STARPU_BLOCK_CHECK(interface); (((struct starpu_block_interface *)(interface))->elemsize) ; })
  975. #else
  976. /**
  977. Return a pointer to the block designated by \p interface.
  978. */
  979. #define STARPU_BLOCK_GET_PTR(interface) (((struct starpu_block_interface *)(interface))->ptr)
  980. /**
  981. Return a device handle for the block designated by \p interface,
  982. to be used on OpenCL. The offset returned by
  983. ::STARPU_BLOCK_GET_OFFSET has to be used in
  984. addition to this.
  985. */
  986. #define STARPU_BLOCK_GET_DEV_HANDLE(interface) (((struct starpu_block_interface *)(interface))->dev_handle)
  987. /**
  988. Return the offset in the block designated by \p interface, to be
  989. used with the device handle.
  990. */
  991. #define STARPU_BLOCK_GET_OFFSET(interface) (((struct starpu_block_interface *)(interface))->offset)
  992. /**
  993. Return the number of elements on the x-axis of the block
  994. designated by \p interface.
  995. */
  996. #define STARPU_BLOCK_GET_NX(interface) (((struct starpu_block_interface *)(interface))->nx)
  997. /**
  998. Return the number of elements on the y-axis of the block
  999. designated by \p interface.
  1000. */
  1001. #define STARPU_BLOCK_GET_NY(interface) (((struct starpu_block_interface *)(interface))->ny)
  1002. /**
  1003. Return the number of elements on the z-axis of the block
  1004. designated by \p interface.
  1005. */
  1006. #define STARPU_BLOCK_GET_NZ(interface) (((struct starpu_block_interface *)(interface))->nz)
  1007. /**
  1008. Return the number of elements between each row of the block
  1009. designated by \p interface. May be equal to nx when there is no padding.
  1010. */
  1011. #define STARPU_BLOCK_GET_LDY(interface) (((struct starpu_block_interface *)(interface))->ldy)
  1012. /**
  1013. Return the number of elements between each z plane of the block
  1014. designated by \p interface. May be equal to nx*ny when there is no
  1015. padding.
  1016. */
  1017. #define STARPU_BLOCK_GET_LDZ(interface) (((struct starpu_block_interface *)(interface))->ldz)
  1018. /**
  1019. Return the size of the elements of the block designated by
  1020. \p interface.
  1021. */
  1022. #define STARPU_BLOCK_GET_ELEMSIZE(interface) (((struct starpu_block_interface *)(interface))->elemsize)
  1023. #endif
  1024. /** @} */
  1025. /**
  1026. @name Tensor Data Interface
  1027. @{
  1028. */
  1029. extern struct starpu_data_interface_ops starpu_interface_tensor_ops;
  1030. /* TODO: rename to 4dtensor? */
  1031. /* TODO: add allocsize support */
  1032. /**
  1033. Tensor interface for 4D dense tensors
  1034. */
  1035. struct starpu_tensor_interface
  1036. {
  1037. enum starpu_data_interface_id id; /**< identifier of the interface */
  1038. uintptr_t ptr; /**< local pointer of the tensor */
  1039. uintptr_t dev_handle; /**< device handle of the tensor. */
  1040. size_t offset; /**< offset in the tensor. */
  1041. uint32_t nx; /**< number of elements on the x-axis of the tensor. */
  1042. uint32_t ny; /**< number of elements on the y-axis of the tensor. */
  1043. uint32_t nz; /**< number of elements on the z-axis of the tensor. */
  1044. uint32_t nt; /**< number of elements on the t-axis of the tensor. */
  1045. uint32_t ldy; /**< number of elements between two lines */
  1046. uint32_t ldz; /**< number of elements between two planes */
  1047. uint32_t ldt; /**< number of elements between two cubes */
  1048. size_t elemsize; /**< size of the elements of the tensor. */
  1049. };
  1050. /**
  1051. Register the \p nx x \p ny x \p nz x \p nt 4D tensor of \p elemsize byte elements
  1052. pointed by \p ptr and initialize \p handle to represent it. Again, \p ldy,
  1053. \p ldz, and \p ldt specify the number of elements between rows, between z planes and between t cubes.
  1054. Here an example of how to use the function.
  1055. \code{.c}
  1056. float *tensor;
  1057. starpu_data_handle_t tensor_handle;
  1058. tensor = (float*)malloc(nx*ny*nz*nt*sizeof(float));
  1059. starpu_tensor_data_register(&tensor_handle, STARPU_MAIN_RAM, (uintptr_t)tensor, nx, nx*ny, nx*ny*nz, nx, ny, nz, nt, sizeof(float));
  1060. \endcode
  1061. */
  1062. void starpu_tensor_data_register(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t ldt, uint32_t nx, uint32_t ny, uint32_t nz, uint32_t nt, size_t elemsize);
  1063. /**
  1064. Register into the \p handle that to store data on node \p node it should use the
  1065. buffer located at \p ptr, or device handle \p dev_handle and offset \p offset
  1066. (for OpenCL, notably), with \p ldy elements between rows, and \p ldz
  1067. elements between z planes, and \p ldt elements between t cubes.
  1068. */
  1069. void starpu_tensor_ptr_register(starpu_data_handle_t handle, unsigned node, uintptr_t ptr, uintptr_t dev_handle, size_t offset, uint32_t ldy, uint32_t ldz, uint32_t ldt);
  1070. /**
  1071. Return the number of elements on the x-axis of the tensor
  1072. designated by \p handle.
  1073. */
  1074. uint32_t starpu_tensor_get_nx(starpu_data_handle_t handle);
  1075. /**
  1076. Return the number of elements on the y-axis of the tensor
  1077. designated by \p handle.
  1078. */
  1079. uint32_t starpu_tensor_get_ny(starpu_data_handle_t handle);
  1080. /**
  1081. Return the number of elements on the z-axis of the tensor
  1082. designated by \p handle.
  1083. */
  1084. uint32_t starpu_tensor_get_nz(starpu_data_handle_t handle);
  1085. /**
  1086. Return the number of elements on the t-axis of the tensor
  1087. designated by \p handle.
  1088. */
  1089. uint32_t starpu_tensor_get_nt(starpu_data_handle_t handle);
  1090. /**
  1091. Return the number of elements between each row of the tensor
  1092. designated by \p handle, in the format of the current memory node.
  1093. */
  1094. uint32_t starpu_tensor_get_local_ldy(starpu_data_handle_t handle);
  1095. /**
  1096. Return the number of elements between each z plane of the tensor
  1097. designated by \p handle, in the format of the current memory node.
  1098. */
  1099. uint32_t starpu_tensor_get_local_ldz(starpu_data_handle_t handle);
  1100. /**
  1101. Return the number of elements between each t cubes of the tensor
  1102. designated by \p handle, in the format of the current memory node.
  1103. */
  1104. uint32_t starpu_tensor_get_local_ldt(starpu_data_handle_t handle);
  1105. /**
  1106. Return the local pointer associated with \p handle.
  1107. */
  1108. uintptr_t starpu_tensor_get_local_ptr(starpu_data_handle_t handle);
  1109. /**
  1110. Return the size of the elements of the tensor designated by
  1111. \p handle.
  1112. */
  1113. size_t starpu_tensor_get_elemsize(starpu_data_handle_t handle);
  1114. #if defined(STARPU_HAVE_STATEMENT_EXPRESSIONS) && defined(STARPU_DEBUG)
  1115. #define STARPU_TENSOR_CHECK(interface) STARPU_ASSERT_MSG((((struct starpu_tensor_interface *)(interface))->id) == STARPU_TENSOR_INTERFACE_ID, "Error. The given data is not a tensor.")
  1116. #define STARPU_TENSOR_GET_PTR(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->ptr) ; })
  1117. #define STARPU_TENSOR_GET_DEV_HANDLE(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->dev_handle) ; })
  1118. #define STARPU_TENSOR_GET_OFFSET(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->offset) ; })
  1119. #define STARPU_TENSOR_GET_NX(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->nx) ; })
  1120. #define STARPU_TENSOR_GET_NY(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->ny) ; })
  1121. #define STARPU_TENSOR_GET_NZ(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->nz) ; })
  1122. #define STARPU_TENSOR_GET_NT(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->nt) ; })
  1123. #define STARPU_TENSOR_GET_LDY(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->ldy) ; })
  1124. #define STARPU_TENSOR_GET_LDZ(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->ldz) ; })
  1125. #define STARPU_TENSOR_GET_LDT(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->ldt) ; })
  1126. #define STARPU_TENSOR_GET_ELEMSIZE(interface) ({ STARPU_TENSOR_CHECK(interface); (((struct starpu_tensor_interface *)(interface))->elemsize) ; })
  1127. #else
  1128. /**
  1129. Return a pointer to the tensor designated by \p interface.
  1130. */
  1131. #define STARPU_TENSOR_GET_PTR(interface) (((struct starpu_tensor_interface *)(interface))->ptr)
  1132. /**
  1133. Return a device handle for the tensor designated by \p interface,
  1134. to be used on OpenCL. The offset returned by
  1135. ::STARPU_TENSOR_GET_OFFSET has to be used in
  1136. addition to this.
  1137. */
  1138. #define STARPU_TENSOR_GET_DEV_HANDLE(interface) (((struct starpu_tensor_interface *)(interface))->dev_handle)
  1139. /**
  1140. Return the offset in the tensor designated by \p interface, to be
  1141. used with the device handle.
  1142. */
  1143. #define STARPU_TENSOR_GET_OFFSET(interface) (((struct starpu_tensor_interface *)(interface))->offset)
  1144. /**
  1145. Return the number of elements on the x-axis of the tensor
  1146. designated by \p interface.
  1147. */
  1148. #define STARPU_TENSOR_GET_NX(interface) (((struct starpu_tensor_interface *)(interface))->nx)
  1149. /**
  1150. Return the number of elements on the y-axis of the tensor
  1151. designated by \p interface.
  1152. */
  1153. #define STARPU_TENSOR_GET_NY(interface) (((struct starpu_tensor_interface *)(interface))->ny)
  1154. /**
  1155. Return the number of elements on the z-axis of the tensor
  1156. designated by \p interface.
  1157. */
  1158. #define STARPU_TENSOR_GET_NZ(interface) (((struct starpu_tensor_interface *)(interface))->nz)
  1159. /**
  1160. Return the number of elements on the t-axis of the tensor
  1161. designated by \p interface.
  1162. */
  1163. #define STARPU_TENSOR_GET_NT(interface) (((struct starpu_tensor_interface *)(interface))->nt)
  1164. /**
  1165. Return the number of elements between each row of the tensor
  1166. designated by \p interface. May be equal to nx when there is no padding.
  1167. */
  1168. #define STARPU_TENSOR_GET_LDY(interface) (((struct starpu_tensor_interface *)(interface))->ldy)
  1169. /**
  1170. Return the number of elements between each z plane of the tensor
  1171. designated by \p interface. May be equal to nx*ny when there is no
  1172. padding.
  1173. */
  1174. #define STARPU_TENSOR_GET_LDZ(interface) (((struct starpu_tensor_interface *)(interface))->ldz)
  1175. /**
  1176. Return the number of elements between each t cubes of the tensor
  1177. designated by \p interface. May be equal to nx*ny*nz when there is no
  1178. padding.
  1179. */
  1180. #define STARPU_TENSOR_GET_LDT(interface) (((struct starpu_tensor_interface *)(interface))->ldt)
  1181. /**
  1182. Return the size of the elements of the tensor designated by
  1183. \p interface.
  1184. */
  1185. #define STARPU_TENSOR_GET_ELEMSIZE(interface) (((struct starpu_tensor_interface *)(interface))->elemsize)
  1186. #endif
  1187. /** @} */
  1188. /**
  1189. @name Vector Data Interface
  1190. @{
  1191. */
  1192. extern struct starpu_data_interface_ops starpu_interface_vector_ops;
  1193. /**
  1194. */
  1195. struct starpu_vector_interface
  1196. {
  1197. enum starpu_data_interface_id id; /**< Identifier of the interface */
  1198. uintptr_t ptr; /**< local pointer of the vector */
  1199. uintptr_t dev_handle; /**< device handle of the vector. */
  1200. size_t offset; /**< offset in the vector */
  1201. uint32_t nx; /**< number of elements on the x-axis of the vector */
  1202. size_t elemsize; /**< size of the elements of the vector */
  1203. uint32_t slice_base; /**< vector slice base, used by the StarPU OpenMP runtime support */
  1204. size_t allocsize; /**< size actually currently allocated */
  1205. };
  1206. /**
  1207. Register the \p nx \p elemsize-byte elements pointed to by \p ptr and initialize \p handle to represent it.
  1208. Here an example of how to use the function.
  1209. \code{.c}
  1210. float vector[NX];
  1211. starpu_data_handle_t vector_handle;
  1212. starpu_vector_data_register(&vector_handle, STARPU_MAIN_RAM, (uintptr_t)vector, NX, sizeof(vector[0]));
  1213. \endcode
  1214. */
  1215. void starpu_vector_data_register(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t nx, size_t elemsize);
  1216. /**
  1217. Similar to starpu_matrix_data_register, but additionally specifies which
  1218. allocation size should be used instead of the initial nx*elemsize.
  1219. */
  1220. void starpu_vector_data_register_allocsize(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, uint32_t nx, size_t elemsize, size_t allocsize);
  1221. /**
  1222. Register into the \p handle that to store data on node \p node it should use the
  1223. buffer located at \p ptr, or device handle \p dev_handle and offset \p offset
  1224. (for OpenCL, notably)
  1225. */
  1226. void starpu_vector_ptr_register(starpu_data_handle_t handle, unsigned node, uintptr_t ptr, uintptr_t dev_handle, size_t offset);
  1227. /**
  1228. Return the number of elements registered into the array designated by \p handle.
  1229. */
  1230. uint32_t starpu_vector_get_nx(starpu_data_handle_t handle);
  1231. /**
  1232. Return the size of each element of the array designated by \p handle.
  1233. */
  1234. size_t starpu_vector_get_elemsize(starpu_data_handle_t handle);
  1235. /**
  1236. Return the allocated size of the array designated by \p handle.
  1237. */
  1238. size_t starpu_vector_get_allocsize(starpu_data_handle_t handle);
  1239. /**
  1240. Return the local pointer associated with \p handle.
  1241. */
  1242. uintptr_t starpu_vector_get_local_ptr(starpu_data_handle_t handle);
  1243. #if defined(STARPU_HAVE_STATEMENT_EXPRESSIONS) && defined(STARPU_DEBUG)
  1244. #define STARPU_VECTOR_CHECK(interface) STARPU_ASSERT_MSG((((struct starpu_vector_interface *)(interface))->id) == STARPU_VECTOR_INTERFACE_ID, "Error. The given data is not a vector.")
  1245. #define STARPU_VECTOR_GET_PTR(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->ptr); })
  1246. #define STARPU_VECTOR_GET_DEV_HANDLE(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->dev_handle); })
  1247. #define STARPU_VECTOR_GET_OFFSET(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->offset); })
  1248. #define STARPU_VECTOR_GET_NX(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->nx); })
  1249. #define STARPU_VECTOR_GET_ELEMSIZE(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->elemsize); })
  1250. #define STARPU_VECTOR_GET_ALLOCSIZE(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->allocsize); })
  1251. #define STARPU_VECTOR_GET_SLICE_BASE(interface) ({ STARPU_VECTOR_CHECK(interface); (((struct starpu_vector_interface *)(interface))->slice_base); })
  1252. #else
  1253. /**
  1254. Return a pointer to the array designated by \p interface, valid on
  1255. CPUs and CUDA only. For OpenCL, the device handle and offset need to
  1256. be used instead.
  1257. */
  1258. #define STARPU_VECTOR_GET_PTR(interface) (((struct starpu_vector_interface *)(interface))->ptr)
  1259. /**
  1260. Return a device handle for the array designated by \p interface,
  1261. to be used with OpenCL. the offset returned by ::STARPU_VECTOR_GET_OFFSET has to be used in
  1262. addition to this.
  1263. */
  1264. #define STARPU_VECTOR_GET_DEV_HANDLE(interface) (((struct starpu_vector_interface *)(interface))->dev_handle)
  1265. /**
  1266. Return the offset in the array designated by \p interface, to be
  1267. used with the device handle.
  1268. */
  1269. #define STARPU_VECTOR_GET_OFFSET(interface) (((struct starpu_vector_interface *)(interface))->offset)
  1270. /**
  1271. Return the number of elements registered into the array
  1272. designated by \p interface.
  1273. */
  1274. #define STARPU_VECTOR_GET_NX(interface) (((struct starpu_vector_interface *)(interface))->nx)
  1275. /**
  1276. Return the size of each element of the array designated by
  1277. \p interface.
  1278. */
  1279. #define STARPU_VECTOR_GET_ELEMSIZE(interface) (((struct starpu_vector_interface *)(interface))->elemsize)
  1280. /**
  1281. Return the size of each element of the array designated by
  1282. \p interface.
  1283. */
  1284. #define STARPU_VECTOR_GET_ALLOCSIZE(interface) (((struct starpu_vector_interface *)(interface))->allocsize)
  1285. /**
  1286. Return the OpenMP slice base annotation of each element of the array designated by
  1287. \p interface.
  1288. */
  1289. #define STARPU_VECTOR_GET_SLICE_BASE(interface) (((struct starpu_vector_interface *)(interface))->slice_base)
  1290. #endif
  1291. /**
  1292. Set the number of elements registered into the array designated by \p
  1293. interface.
  1294. */
  1295. #define STARPU_VECTOR_SET_NX(interface, newnx) do { \
  1296. STARPU_VECTOR_CHECK(interface); \
  1297. (((struct starpu_vector_interface *)(interface))->nx) = (newnx); \
  1298. } while(0)
  1299. /** @} */
  1300. /**
  1301. @name Variable Data Interface
  1302. @{
  1303. */
  1304. extern struct starpu_data_interface_ops starpu_interface_variable_ops;
  1305. /**
  1306. Variable interface for a single data (not a vector, a matrix, a list,
  1307. ...)
  1308. */
  1309. struct starpu_variable_interface
  1310. {
  1311. enum starpu_data_interface_id id; /**< Identifier of the interface */
  1312. uintptr_t ptr; /**< local pointer of the variable */
  1313. uintptr_t dev_handle; /**< device handle of the variable. */
  1314. size_t offset; /**< offset in the variable */
  1315. size_t elemsize; /**< size of the variable */
  1316. };
  1317. /**
  1318. Register the \p size byte element pointed to by \p ptr, which is
  1319. typically a scalar, and initialize \p handle to represent this data item.
  1320. Here an example of how to use the function.
  1321. \code{.c}
  1322. float var = 42.0;
  1323. starpu_data_handle_t var_handle;
  1324. starpu_variable_data_register(&var_handle, STARPU_MAIN_RAM, (uintptr_t)&var, sizeof(var));
  1325. \endcode
  1326. */
  1327. void starpu_variable_data_register(starpu_data_handle_t *handle, int home_node, uintptr_t ptr, size_t size);
  1328. /**
  1329. Register into the \p handle that to store data on node \p node it should use the
  1330. buffer located at \p ptr, or device handle \p dev_handle and offset \p offset
  1331. (for OpenCL, notably)
  1332. */
  1333. void starpu_variable_ptr_register(starpu_data_handle_t handle, unsigned node, uintptr_t ptr, uintptr_t dev_handle, size_t offset);
  1334. /**
  1335. Return the size of the variable designated by \p handle.
  1336. */
  1337. size_t starpu_variable_get_elemsize(starpu_data_handle_t handle);
  1338. /**
  1339. Return a pointer to the variable designated by \p handle.
  1340. */
  1341. uintptr_t starpu_variable_get_local_ptr(starpu_data_handle_t handle);
  1342. #if defined(STARPU_HAVE_STATEMENT_EXPRESSIONS) && defined(STARPU_DEBUG)
  1343. #define STARPU_VARIABLE_CHECK(interface) STARPU_ASSERT_MSG((((struct starpu_variable_interface *)(interface))->id) == STARPU_VARIABLE_INTERFACE_ID, "Error. The given data is not a variable.")
  1344. #define STARPU_VARIABLE_GET_PTR(interface) ({ STARPU_VARIABLE_CHECK(interface); (((struct starpu_variable_interface *)(interface))->ptr) ; })
  1345. #define STARPU_VARIABLE_GET_OFFSET(interface) ({ STARPU_VARIABLE_CHECK(interface); (((struct starpu_variable_interface *)(interface))->offset) ; })
  1346. #define STARPU_VARIABLE_GET_ELEMSIZE(interface) ({ STARPU_VARIABLE_CHECK(interface); (((struct starpu_variable_interface *)(interface))->elemsize) ; })
  1347. #define STARPU_VARIABLE_GET_DEV_HANDLE(interface) ({ STARPU_VARIABLE_CHECK(interface); (((struct starpu_variable_interface *)(interface))->ptr) ; })
  1348. #else
  1349. /**
  1350. Return a pointer to the variable designated by \p interface.
  1351. */
  1352. #define STARPU_VARIABLE_GET_PTR(interface) (((struct starpu_variable_interface *)(interface))->ptr)
  1353. /**
  1354. Return the offset in the variable designated by \p interface, to
  1355. be used with the device handle.
  1356. */
  1357. #define STARPU_VARIABLE_GET_OFFSET(interface) (((struct starpu_variable_interface *)(interface))->offset)
  1358. /**
  1359. Return the size of the variable designated by \p interface.
  1360. */
  1361. #define STARPU_VARIABLE_GET_ELEMSIZE(interface) (((struct starpu_variable_interface *)(interface))->elemsize)
  1362. /**
  1363. Return a device handle for the variable designated by
  1364. \p interface, to be used with OpenCL. The offset returned by
  1365. ::STARPU_VARIABLE_GET_OFFSET has to be
  1366. used in addition to this.
  1367. */
  1368. #define STARPU_VARIABLE_GET_DEV_HANDLE(interface) (((struct starpu_variable_interface *)(interface))->ptr)
  1369. #endif
  1370. /** @} */
  1371. /**
  1372. @name Void Data Interface
  1373. @{
  1374. */
  1375. extern struct starpu_data_interface_ops starpu_interface_void_ops;
  1376. /**
  1377. Register a void interface. There is no data really associated
  1378. to that interface, but it may be used as a synchronization mechanism.
  1379. It also permits to express an abstract piece of data that is managed
  1380. by the application internally: this makes it possible to forbid the
  1381. concurrent execution of different tasks accessing the same <c>void</c>
  1382. data in read-write concurrently.
  1383. */
  1384. void starpu_void_data_register(starpu_data_handle_t *handle);
  1385. /** @} */
  1386. /**
  1387. @name CSR Data Interface
  1388. @{
  1389. */
  1390. extern struct starpu_data_interface_ops starpu_interface_csr_ops;
  1391. /**
  1392. CSR interface for sparse matrices (compressed sparse row
  1393. representation)
  1394. */
  1395. struct starpu_csr_interface
  1396. {
  1397. enum starpu_data_interface_id id; /**< Identifier of the interface */
  1398. uint32_t nnz; /**< number of non-zero entries */
  1399. uint32_t nrow; /**< number of rows */
  1400. uintptr_t nzval; /**< non-zero values */
  1401. uint32_t *colind; /**< position of non-zero entries on the row */
  1402. uint32_t *rowptr; /**< index (in nzval) of the first entry of the row */
  1403. uint32_t firstentry; /**< k for k-based indexing (0 or 1 usually). also useful when partitionning the matrix. */
  1404. size_t elemsize; /**< size of the elements of the matrix */
  1405. };
  1406. /**
  1407. Register a CSR (Compressed Sparse Row Representation) sparse matrix.
  1408. */
  1409. void starpu_csr_data_register(starpu_data_handle_t *handle, int home_node, uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);
  1410. /**
  1411. Return the number of non-zero values in the matrix designated
  1412. by \p handle.
  1413. */
  1414. uint32_t starpu_csr_get_nnz(starpu_data_handle_t handle);
  1415. /**
  1416. Return the size of the row pointer array of the matrix
  1417. designated by \p handle.
  1418. */
  1419. uint32_t starpu_csr_get_nrow(starpu_data_handle_t handle);
  1420. /**
  1421. Return the index at which all arrays (the column indexes, the
  1422. row pointers...) of the matrix designated by \p handle.
  1423. */
  1424. uint32_t starpu_csr_get_firstentry(starpu_data_handle_t handle);
  1425. /**
  1426. Return a local pointer to the non-zero values of the matrix
  1427. designated by \p handle.
  1428. */
  1429. uintptr_t starpu_csr_get_local_nzval(starpu_data_handle_t handle);
  1430. /**
  1431. Return a local pointer to the column index of the matrix
  1432. designated by \p handle.
  1433. */
  1434. uint32_t *starpu_csr_get_local_colind(starpu_data_handle_t handle);
  1435. /**
  1436. Return a local pointer to the row pointer array of the matrix
  1437. designated by \p handle.
  1438. */
  1439. uint32_t *starpu_csr_get_local_rowptr(starpu_data_handle_t handle);
  1440. /**
  1441. Return the size of the elements registered into the matrix
  1442. designated by \p handle.
  1443. */
  1444. size_t starpu_csr_get_elemsize(starpu_data_handle_t handle);
  1445. /**
  1446. Return the number of non-zero values in the matrix designated
  1447. by \p interface.
  1448. */
  1449. #define STARPU_CSR_GET_NNZ(interface) (((struct starpu_csr_interface *)(interface))->nnz)
  1450. /**
  1451. Return the size of the row pointer array of the matrix
  1452. designated by \p interface.
  1453. */
  1454. #define STARPU_CSR_GET_NROW(interface) (((struct starpu_csr_interface *)(interface))->nrow)
  1455. /**
  1456. Return a pointer to the non-zero values of the matrix
  1457. designated by \p interface.
  1458. */
  1459. #define STARPU_CSR_GET_NZVAL(interface) (((struct starpu_csr_interface *)(interface))->nzval)
  1460. /**
  1461. Return a device handle for the array of non-zero values in the
  1462. matrix designated by \p interface. The offset returned by ::STARPU_CSR_GET_OFFSET
  1463. has to used in addition to this.
  1464. */
  1465. #define STARPU_CSR_GET_NZVAL_DEV_HANDLE(interface) (((struct starpu_csr_interface *)(interface))->nnz)
  1466. /**
  1467. Return a pointer to the column index of the matrix designated
  1468. by \p interface.
  1469. */
  1470. #define STARPU_CSR_GET_COLIND(interface) (((struct starpu_csr_interface *)(interface))->colind)
  1471. /**
  1472. Return a device handle for the column index of the matrix
  1473. designated by \p interface. The offset returned by ::STARPU_CSR_GET_OFFSET has to be used in
  1474. addition to this.
  1475. */
  1476. #define STARPU_CSR_GET_COLIND_DEV_HANDLE(interface) (((struct starpu_csr_interface *)(interface))->colind)
  1477. /**
  1478. Return a pointer to the row pointer array of the matrix
  1479. designated by \p interface.
  1480. */
  1481. #define STARPU_CSR_GET_ROWPTR(interface) (((struct starpu_csr_interface *)(interface))->rowptr)
  1482. /**
  1483. Return a device handle for the row pointer array of the matrix
  1484. designated by \p interface. The offset returned by ::STARPU_CSR_GET_OFFSET has to be used in
  1485. addition to this.
  1486. */
  1487. #define STARPU_CSR_GET_ROWPTR_DEV_HANDLE(interface) (((struct starpu_csr_interface *)(interface))->rowptr)
  1488. /**
  1489. Return the offset in the arrays (colind, rowptr, nzval) of the
  1490. matrix designated by \p interface, to be used with the device handles.
  1491. */
  1492. #define STARPU_CSR_GET_OFFSET 0
  1493. /**
  1494. Return the index at which all arrays (the column indexes, the
  1495. row pointers...) of the \p interface start.
  1496. */
  1497. #define STARPU_CSR_GET_FIRSTENTRY(interface) (((struct starpu_csr_interface *)(interface))->firstentry)
  1498. /**
  1499. Return the size of the elements registered into the matrix
  1500. designated by \p interface.
  1501. */
  1502. #define STARPU_CSR_GET_ELEMSIZE(interface) (((struct starpu_csr_interface *)(interface))->elemsize)
  1503. /** @} */
  1504. /**
  1505. @name BCSR Data Interface
  1506. @{
  1507. */
  1508. extern struct starpu_data_interface_ops starpu_interface_bcsr_ops;
  1509. /**
  1510. BCSR interface for sparse matrices (blocked compressed sparse
  1511. row representation)
  1512. */
  1513. struct starpu_bcsr_interface
  1514. {
  1515. enum starpu_data_interface_id id; /**< Identifier of the interface */
  1516. uint32_t nnz; /**< number of non-zero BLOCKS */
  1517. uint32_t nrow; /**< number of rows (in terms of BLOCKS) */
  1518. uintptr_t nzval; /**< non-zero values */
  1519. uint32_t *colind; /**< array of nnz elements, colind[i] is the block-column index for block i in nzval */
  1520. uint32_t *rowptr; /**< array of nrow+1
  1521. * elements, rowptr[i] is
  1522. * the block-index (in
  1523. * nzval) of the first block
  1524. * of row i. By convention,
  1525. * rowptr[nrow] is the
  1526. * number of blocks, this
  1527. * allows an easier access
  1528. * of the matrix's elements
  1529. * for the kernels. */
  1530. uint32_t firstentry; /**< k for k-based indexing (0 or 1 usually). Also useful when partitionning the matrix. */
  1531. uint32_t r; /**< height of the blocks */
  1532. uint32_t c; /**< width of the blocks */
  1533. size_t elemsize; /**< size of the elements of the matrix */
  1534. };
  1535. /**
  1536. This variant of starpu_data_register() uses the BCSR (Blocked
  1537. Compressed Sparse Row Representation) sparse matrix interface.
  1538. Register the sparse matrix made of \p nnz non-zero blocks of elements of
  1539. size \p elemsize stored in \p nzval and initializes \p handle to represent it.
  1540. Blocks have size \p r * \p c. \p nrow is the number of rows (in terms of
  1541. blocks), \p colind is an array of nnz elements, colind[i] is the block-column index for block i in \p nzval,
  1542. \p rowptr is an array of nrow+1 elements, rowptr[i] is the block-index (in \p nzval) of the first block of row i. By convention, rowptr[nrow] is the number of blocks, this allows an easier access of the matrix's elements for the kernels.
  1543. \p firstentry is the index of the first entry of the given arrays
  1544. (usually 0 or 1).
  1545. Here an example with the following matrix:
  1546. \code | 0 1 0 0 | \endcode
  1547. \code | 2 3 0 0 | \endcode
  1548. \code | 4 5 8 9 | \endcode
  1549. \code | 6 7 10 11 | \endcode
  1550. \code nzval = [0, 1, 2, 3] ++ [4, 5, 6, 7] ++ [8, 9, 10, 11] \endcode
  1551. \code colind = [0, 0, 1] \endcode
  1552. \code rowptr = [0, 1, 3] \endcode
  1553. \code r = c = 2 \endcode
  1554. which translates into the following code
  1555. \code{.c}
  1556. int R = 2; // Size of the blocks
  1557. int C = 2;
  1558. int NROWS = 2;
  1559. int NNZ_BLOCKS = 3; // out of 4
  1560. int NZVAL_SIZE = (R*C*NNZ_BLOCKS);
  1561. int nzval[NZVAL_SIZE] =
  1562. {
  1563. 0, 1, 2, 3, // First block
  1564. 4, 5, 6, 7, // Second block
  1565. 8, 9, 10, 11 // Third block
  1566. };
  1567. uint32_t colind[NNZ_BLOCKS] =
  1568. {
  1569. 0, // block-column index for first block in nzval
  1570. 0, // block-column index for second block in nzval
  1571. 1 // block-column index for third block in nzval
  1572. };
  1573. uint32_t rowptr[NROWS+1] =
  1574. {
  1575. 0, // block-index in nzval of the first block of the first row.
  1576. 1, // block-index in nzval of the first block of the second row.
  1577. NNZ_BLOCKS // number of blocks, to allow an easier element's access for the kernels
  1578. };
  1579. starpu_data_handle_t bcsr_handle;
  1580. starpu_bcsr_data_register(&bcsr_handle,
  1581. STARPU_MAIN_RAM,
  1582. NNZ_BLOCKS,
  1583. NROWS,
  1584. (uintptr_t) nzval,
  1585. colind,
  1586. rowptr,
  1587. 0, // firstentry
  1588. R,
  1589. C,
  1590. sizeof(nzval[0]));
  1591. \endcode
  1592. */
  1593. void starpu_bcsr_data_register(starpu_data_handle_t *handle, int 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);
  1594. /**
  1595. Return the number of non-zero elements in the matrix designated
  1596. by \p handle.
  1597. */
  1598. uint32_t starpu_bcsr_get_nnz(starpu_data_handle_t handle);
  1599. /**
  1600. Return the number of rows (in terms of blocks of size r*c) in
  1601. the matrix designated by \p handle.
  1602. */
  1603. uint32_t starpu_bcsr_get_nrow(starpu_data_handle_t handle);
  1604. /**
  1605. Return the index at which all arrays (the column indexes, the
  1606. row pointers...) of the matrix desginated by \p handle.
  1607. */
  1608. uint32_t starpu_bcsr_get_firstentry(starpu_data_handle_t handle);
  1609. /**
  1610. Return a pointer to the non-zero values of the matrix
  1611. designated by \p handle.
  1612. */
  1613. uintptr_t starpu_bcsr_get_local_nzval(starpu_data_handle_t handle);
  1614. /**
  1615. Return a pointer to the column index, which holds the positions
  1616. of the non-zero entries in the matrix designated by \p handle.
  1617. */
  1618. uint32_t *starpu_bcsr_get_local_colind(starpu_data_handle_t handle);
  1619. /**
  1620. Return the row pointer array of the matrix designated by
  1621. \p handle.
  1622. */
  1623. uint32_t *starpu_bcsr_get_local_rowptr(starpu_data_handle_t handle);
  1624. /**
  1625. Return the number of rows in a block.
  1626. */
  1627. uint32_t starpu_bcsr_get_r(starpu_data_handle_t handle);
  1628. /**
  1629. Return the number of columns in a block.
  1630. */
  1631. uint32_t starpu_bcsr_get_c(starpu_data_handle_t handle);
  1632. /**
  1633. Return the size of the elements in the matrix designated by
  1634. \p handle.
  1635. */
  1636. size_t starpu_bcsr_get_elemsize(starpu_data_handle_t handle);
  1637. /**
  1638. Return the number of non-zero values in the matrix designated
  1639. by \p interface.
  1640. */
  1641. #define STARPU_BCSR_GET_NNZ(interface) (((struct starpu_bcsr_interface *)(interface))->nnz)
  1642. /**
  1643. Return a pointer to the non-zero values of the matrix
  1644. designated by \p interface.
  1645. */
  1646. #define STARPU_BCSR_GET_NZVAL(interface) (((struct starpu_bcsr_interface *)(interface))->nzval)
  1647. /**
  1648. Return a device handle for the array of non-zero values in the
  1649. matrix designated by \p interface. The offset returned by ::STARPU_BCSR_GET_OFFSET has to be
  1650. used in addition to this.
  1651. */
  1652. #define STARPU_BCSR_GET_NZVAL_DEV_HANDLE(interface) (((struct starpu_bcsr_interface *)(interface))->nnz)
  1653. /**
  1654. Return a pointer to the column index of the matrix designated
  1655. by \p interface.
  1656. */
  1657. #define STARPU_BCSR_GET_COLIND(interface) (((struct starpu_bcsr_interface *)(interface))->colind)
  1658. /**
  1659. Return a device handle for the column index of the matrix
  1660. designated by \p interface. The offset returned by ::STARPU_BCSR_GET_OFFSET has to be used in
  1661. addition to this.
  1662. */
  1663. #define STARPU_BCSR_GET_COLIND_DEV_HANDLE(interface) (((struct starpu_bcsr_interface *)(interface))->colind)
  1664. /**
  1665. Return a pointer to the row pointer array of the matrix
  1666. designated by \p interface.
  1667. */
  1668. #define STARPU_BCSR_GET_ROWPTR(interface) (((struct starpu_bcsr_interface *)(interface))->rowptr)
  1669. /**
  1670. Return a device handle for the row pointer array of the matrix
  1671. designated by \p interface. The offset returned by ::STARPU_BCSR_GET_OFFSET has to be used in
  1672. addition to this.
  1673. */
  1674. #define STARPU_BCSR_GET_ROWPTR_DEV_HANDLE(interface) (((struct starpu_bcsr_interface *)(interface))->rowptr)
  1675. /**
  1676. Return the offset in the arrays (coling, rowptr, nzval) of the
  1677. matrix designated by \p interface, to be used with the device handles.
  1678. */
  1679. #define STARPU_BCSR_GET_OFFSET 0
  1680. /** @} */
  1681. /**
  1682. @name Multiformat Data Interface
  1683. @{
  1684. */
  1685. /**
  1686. Multiformat operations
  1687. */
  1688. struct starpu_multiformat_data_interface_ops
  1689. {
  1690. size_t cpu_elemsize; /**< size of each element on CPUs */
  1691. size_t opencl_elemsize; /**< size of each element on OpenCL devices */
  1692. struct starpu_codelet *cpu_to_opencl_cl; /**< pointer to a codelet which converts from CPU to OpenCL */
  1693. struct starpu_codelet *opencl_to_cpu_cl; /**< pointer to a codelet which converts from OpenCL to CPU */
  1694. size_t cuda_elemsize; /**< size of each element on CUDA devices */
  1695. struct starpu_codelet *cpu_to_cuda_cl; /**< pointer to a codelet which converts from CPU to CUDA */
  1696. struct starpu_codelet *cuda_to_cpu_cl; /**< pointer to a codelet which converts from CUDA to CPU */
  1697. size_t mic_elemsize; /**< size of each element on MIC devices */
  1698. struct starpu_codelet *cpu_to_mic_cl; /**< pointer to a codelet which converts from CPU to MIC */
  1699. struct starpu_codelet *mic_to_cpu_cl; /**< pointer to a codelet which converts from MIC to CPU */
  1700. };
  1701. struct starpu_multiformat_interface
  1702. {
  1703. enum starpu_data_interface_id id;
  1704. void *cpu_ptr;
  1705. void *cuda_ptr;
  1706. void *opencl_ptr;
  1707. void *mic_ptr;
  1708. uint32_t nx;
  1709. struct starpu_multiformat_data_interface_ops *ops;
  1710. };
  1711. /**
  1712. Register a piece of data that can be represented in different
  1713. ways, depending upon the processing unit that manipulates it. It
  1714. allows the programmer, for instance, to use an array of structures
  1715. when working on a CPU, and a structure of arrays when working on a
  1716. GPU. \p nobjects is the number of elements in the data. \p format_ops
  1717. describes the format.
  1718. */
  1719. void starpu_multiformat_data_register(starpu_data_handle_t *handle, int home_node, void *ptr, uint32_t nobjects, struct starpu_multiformat_data_interface_ops *format_ops);
  1720. /**
  1721. Return the local pointer to the data with CPU format.
  1722. */
  1723. #define STARPU_MULTIFORMAT_GET_CPU_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->cpu_ptr)
  1724. /**
  1725. Return the local pointer to the data with CUDA format.
  1726. */
  1727. #define STARPU_MULTIFORMAT_GET_CUDA_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->cuda_ptr)
  1728. /**
  1729. Return the local pointer to the data with OpenCL format.
  1730. */
  1731. #define STARPU_MULTIFORMAT_GET_OPENCL_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->opencl_ptr)
  1732. /**
  1733. Return the local pointer to the data with MIC format.
  1734. */
  1735. #define STARPU_MULTIFORMAT_GET_MIC_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->mic_ptr)
  1736. /**
  1737. Return the number of elements in the data.
  1738. */
  1739. #define STARPU_MULTIFORMAT_GET_NX(interface) (((struct starpu_multiformat_interface *)(interface))->nx)
  1740. /** @} */
  1741. /** @} */
  1742. #ifdef __cplusplus
  1743. }
  1744. #endif
  1745. #endif /* __STARPU_DATA_INTERFACES_H__ */