starpu_data_interfaces.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011-2012 Institut National de Recherche en Informatique et Automatique
  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_GORDON
  22. /* to get the gordon_strideSize_t data structure from gordon */
  23. #include <gordon.h>
  24. #endif
  25. #ifdef STARPU_USE_CUDA
  26. /* to use CUDA streams */
  27. # ifdef STARPU_DONT_INCLUDE_CUDA_HEADERS
  28. typedef void *cudaStream_t;
  29. # else
  30. # include <cuda_runtime.h>
  31. # endif
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. /* The following structures are used to describe data interfaces */
  38. /* This structure contains the different methods to transfer data between the
  39. * different types of memory nodes */
  40. struct starpu_data_copy_methods
  41. {
  42. /* src type is ram */
  43. int (*ram_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  44. int (*ram_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  45. int (*ram_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  46. int (*ram_to_spu)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  47. /* src type is cuda */
  48. int (*cuda_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  49. int (*cuda_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  50. int (*cuda_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  51. int (*cuda_to_spu)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  52. /* src type is spu */
  53. int (*spu_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  54. int (*spu_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  55. int (*spu_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  56. int (*spu_to_spu)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  57. /* src type is opencl */
  58. int (*opencl_to_ram)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  59. int (*opencl_to_cuda)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  60. int (*opencl_to_opencl)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  61. int (*opencl_to_spu)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  62. #ifdef STARPU_USE_CUDA
  63. /* for asynchronous CUDA transfers */
  64. int (*ram_to_cuda_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cudaStream_t stream);
  65. int (*cuda_to_ram_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cudaStream_t stream);
  66. int (*cuda_to_cuda_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cudaStream_t stream);
  67. #endif
  68. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  69. /* for asynchronous OpenCL transfers */
  70. int (*ram_to_opencl_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  71. int (*opencl_to_ram_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  72. int (*opencl_to_opencl_async)(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cl_event *event);
  73. #endif
  74. };
  75. enum starpu_data_interface_id
  76. {
  77. STARPU_MATRIX_INTERFACE_ID=0,
  78. STARPU_BLOCK_INTERFACE_ID=1,
  79. STARPU_VECTOR_INTERFACE_ID=2,
  80. STARPU_CSR_INTERFACE_ID=3,
  81. STARPU_BCSR_INTERFACE_ID=4,
  82. STARPU_VARIABLE_INTERFACE_ID=5,
  83. STARPU_VOID_INTERFACE_ID=6,
  84. STARPU_MULTIFORMAT_INTERFACE_ID=7,
  85. STARPU_COO_INTERFACE_ID=8,
  86. STARPU_MAX_INTERFACE_ID=9 /* maximum number of data interfaces */
  87. };
  88. struct starpu_data_interface_ops
  89. {
  90. /* Register an existing interface into a data handle. */
  91. void (*register_data_handle)(starpu_data_handle_t handle,
  92. uint32_t home_node, void *data_interface);
  93. /* Allocate data for the interface on a given node. */
  94. starpu_ssize_t (*allocate_data_on_node)(void *data_interface, uint32_t node);
  95. /* Free data of the interface on a given node. */
  96. void (*free_data_on_node)(void *data_interface, uint32_t node);
  97. /* ram/cuda/spu/opencl synchronous and asynchronous transfer methods */
  98. struct starpu_data_copy_methods *copy_methods;
  99. /* Return the current pointer (if any) for the handle on the given node. */
  100. void * (*handle_to_pointer)(starpu_data_handle_t handle, uint32_t node);
  101. /* Return an estimation of the size of data, for performance models */
  102. size_t (*get_size)(starpu_data_handle_t handle);
  103. /* Return a 32bit footprint which characterizes the data size */
  104. uint32_t (*footprint)(starpu_data_handle_t handle);
  105. /* Compare the data size of two interfaces */
  106. int (*compare)(void *data_interface_a, void *data_interface_b);
  107. /* Dump the sizes of a handle to a file */
  108. void (*display)(starpu_data_handle_t handle, FILE *f);
  109. #ifdef STARPU_USE_GORDON
  110. /* Convert the data size to the spu size format */
  111. int (*convert_to_gordon)(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
  112. #endif
  113. /* an identifier that is unique to each interface */
  114. enum starpu_data_interface_id interfaceid;
  115. /* The size of the interface data descriptor */
  116. size_t interface_size;
  117. int is_multiformat;
  118. struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
  119. /* Pack the data handle into a contiguous buffer at the address ptr */
  120. int (*pack_data)(starpu_data_handle_t handle, uint32_t node, void **ptr);
  121. /* Unpack the data handle from the contiguous buffer at the address ptr */
  122. int (*unpack_data)(starpu_data_handle_t handle, uint32_t node, void *ptr);
  123. };
  124. /* Return the next available id for a data interface */
  125. int starpu_data_interface_get_next_id(void);
  126. void starpu_data_register(starpu_data_handle_t *handleptr, uint32_t home_node, void *data_interface, struct starpu_data_interface_ops *ops);
  127. void starpu_data_register_same(starpu_data_handle_t *handledst, starpu_data_handle_t handlesrc);
  128. /* Return the pointer associated with HANDLE on node NODE or NULL if HANDLE's
  129. * interface does not support this operation or data for this handle is not
  130. * allocated on that node. */
  131. void *starpu_handle_to_pointer(starpu_data_handle_t handle, uint32_t node);
  132. /* Return the local pointer associated with HANDLE or NULL if HANDLE's
  133. * interface does not have data allocated locally */
  134. void *starpu_handle_get_local_ptr(starpu_data_handle_t handle);
  135. /* "node" means memory node: 0 for main RAM, then 1, 2, etc. for various GPUs,
  136. * etc.
  137. *
  138. * On registration, the source of data is usually a pointer in RAM, in which
  139. * case 0 should be passed.
  140. */
  141. void *starpu_data_get_interface_on_node(starpu_data_handle_t handle, unsigned memory_node);
  142. #ifdef STARPU_DEVEL
  143. # warning the declaration below is needed for the spvm example (dw_block_spmv.c:110) which filters a data in sub-data with a different interface. However exposing a private object is certainly not something to do. Either turn the object public or find another way to specify interfaces when filtering
  144. #endif /* STARPU_DEVEL */
  145. extern struct starpu_data_interface_ops _starpu_interface_matrix_ops;
  146. /* Matrix interface for dense matrices */
  147. struct starpu_matrix_interface
  148. {
  149. uintptr_t ptr;
  150. uintptr_t dev_handle;
  151. size_t offset;
  152. uint32_t nx;
  153. uint32_t ny;
  154. uint32_t ld;
  155. size_t elemsize;
  156. };
  157. void starpu_matrix_data_register(starpu_data_handle_t *handle, uint32_t home_node, uintptr_t ptr, uint32_t ld, uint32_t nx, uint32_t ny, size_t elemsize);
  158. uint32_t starpu_matrix_get_nx(starpu_data_handle_t handle);
  159. uint32_t starpu_matrix_get_ny(starpu_data_handle_t handle);
  160. uint32_t starpu_matrix_get_local_ld(starpu_data_handle_t handle);
  161. uintptr_t starpu_matrix_get_local_ptr(starpu_data_handle_t handle);
  162. size_t starpu_matrix_get_elemsize(starpu_data_handle_t handle);
  163. /* helper methods */
  164. #define STARPU_MATRIX_GET_PTR(interface) (((struct starpu_matrix_interface *)(interface))->ptr)
  165. #define STARPU_MATRIX_GET_DEV_HANDLE(interface) (((struct starpu_matrix_interface *)(interface))->dev_handle)
  166. #define STARPU_MATRIX_GET_OFFSET(interface) (((struct starpu_matrix_interface *)(interface))->offset)
  167. #define STARPU_MATRIX_GET_NX(interface) (((struct starpu_matrix_interface *)(interface))->nx)
  168. #define STARPU_MATRIX_GET_NY(interface) (((struct starpu_matrix_interface *)(interface))->ny)
  169. #define STARPU_MATRIX_GET_LD(interface) (((struct starpu_matrix_interface *)(interface))->ld)
  170. #define STARPU_MATRIX_GET_ELEMSIZE(interface) (((struct starpu_matrix_interface *)(interface))->elemsize)
  171. /*
  172. * COO matrices.
  173. */
  174. struct starpu_coo_interface
  175. {
  176. uint32_t *columns;
  177. uint32_t *rows;
  178. uintptr_t values;
  179. uint32_t nx;
  180. uint32_t ny;
  181. uint32_t n_values;
  182. size_t elemsize;
  183. };
  184. void
  185. starpu_coo_data_register(starpu_data_handle_t *handleptr, uint32_t home_node,
  186. uint32_t nx, uint32_t ny, uint32_t n_values,
  187. uint32_t *columns, uint32_t *rows,
  188. uintptr_t values, size_t elemsize);
  189. #define STARPU_COO_GET_COLUMNS(interface) \
  190. (((struct starpu_coo_interface *)(interface))->columns)
  191. #define STARPU_COO_GET_COLUMNS_DEV_HANDLE(interface) \
  192. (((struct starpu_coo_interface *)(interface))->columns)
  193. #define STARPU_COO_GET_ROWS(interface) \
  194. (((struct starpu_coo_interface *)(interface))->rows)
  195. #define STARPU_COO_GET_ROWS_DEV_HANDLE(interface) \
  196. (((struct starpu_coo_interface *)(interface))->rows)
  197. #define STARPU_COO_GET_VALUES(interface) \
  198. (((struct starpu_coo_interface *)(interface))->values)
  199. #define STARPU_COO_GET_VALUES_DEV_HANDLE(interface) \
  200. (((struct starpu_coo_interface *)(interface))->values)
  201. #define STARPU_COO_GET_OFFSET 0
  202. #define STARPU_COO_GET_NX(interface) \
  203. (((struct starpu_coo_interface *)(interface))->nx)
  204. #define STARPU_COO_GET_NY(interface) \
  205. (((struct starpu_coo_interface *)(interface))->ny)
  206. #define STARPU_COO_GET_NVALUES(interface) \
  207. (((struct starpu_coo_interface *)(interface))->n_values)
  208. #define STARPU_COO_GET_ELEMSIZE(interface) \
  209. (((struct starpu_coo_interface *)(interface))->elemsize)
  210. /* BLOCK interface for 3D dense blocks */
  211. /* TODO: rename to 3dmatrix? */
  212. struct starpu_block_interface
  213. {
  214. uintptr_t ptr;
  215. uintptr_t dev_handle;
  216. size_t offset;
  217. uint32_t nx;
  218. uint32_t ny;
  219. uint32_t nz;
  220. uint32_t ldy; /* number of elements between two lines */
  221. uint32_t ldz; /* number of elements between two planes */
  222. size_t elemsize;
  223. };
  224. void starpu_block_data_register(starpu_data_handle_t *handle, uint32_t home_node, uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx, uint32_t ny, uint32_t nz, size_t elemsize);
  225. uint32_t starpu_block_get_nx(starpu_data_handle_t handle);
  226. uint32_t starpu_block_get_ny(starpu_data_handle_t handle);
  227. uint32_t starpu_block_get_nz(starpu_data_handle_t handle);
  228. uint32_t starpu_block_get_local_ldy(starpu_data_handle_t handle);
  229. uint32_t starpu_block_get_local_ldz(starpu_data_handle_t handle);
  230. uintptr_t starpu_block_get_local_ptr(starpu_data_handle_t handle);
  231. size_t starpu_block_get_elemsize(starpu_data_handle_t handle);
  232. /* helper methods */
  233. #define STARPU_BLOCK_GET_PTR(interface) (((struct starpu_block_interface *)(interface))->ptr)
  234. #define STARPU_BLOCK_GET_DEV_HANDLE(interface) (((struct starpu_block_interface *)(interface))->dev_handle)
  235. #define STARPU_BLOCK_GET_OFFSET(interface) (((struct starpu_block_interface *)(interface))->offset)
  236. #define STARPU_BLOCK_GET_NX(interface) (((struct starpu_block_interface *)(interface))->nx)
  237. #define STARPU_BLOCK_GET_NY(interface) (((struct starpu_block_interface *)(interface))->ny)
  238. #define STARPU_BLOCK_GET_NZ(interface) (((struct starpu_block_interface *)(interface))->nz)
  239. #define STARPU_BLOCK_GET_LDY(interface) (((struct starpu_block_interface *)(interface))->ldy)
  240. #define STARPU_BLOCK_GET_LDZ(interface) (((struct starpu_block_interface *)(interface))->ldz)
  241. #define STARPU_BLOCK_GET_ELEMSIZE(interface) (((struct starpu_block_interface *)(interface))->elemsize)
  242. /* vector interface for contiguous (non-strided) buffers */
  243. struct starpu_vector_interface
  244. {
  245. uintptr_t ptr;
  246. uintptr_t dev_handle;
  247. size_t offset;
  248. uint32_t nx;
  249. size_t elemsize;
  250. };
  251. void starpu_vector_data_register(starpu_data_handle_t *handle, uint32_t home_node, uintptr_t ptr, uint32_t nx, size_t elemsize);
  252. uint32_t starpu_vector_get_nx(starpu_data_handle_t handle);
  253. size_t starpu_vector_get_elemsize(starpu_data_handle_t handle);
  254. uintptr_t starpu_vector_get_local_ptr(starpu_data_handle_t handle);
  255. /* helper methods */
  256. #define STARPU_VECTOR_GET_PTR(interface) (((struct starpu_vector_interface *)(interface))->ptr)
  257. #define STARPU_VECTOR_GET_DEV_HANDLE(interface) (((struct starpu_vector_interface *)(interface))->dev_handle)
  258. #define STARPU_VECTOR_GET_OFFSET(interface) (((struct starpu_vector_interface *)(interface))->offset)
  259. #define STARPU_VECTOR_GET_NX(interface) (((struct starpu_vector_interface *)(interface))->nx)
  260. #define STARPU_VECTOR_GET_ELEMSIZE(interface) (((struct starpu_vector_interface *)(interface))->elemsize)
  261. /* variable interface for a single data (not a vector, a matrix, a list, ...) */
  262. struct starpu_variable_interface
  263. {
  264. uintptr_t ptr;
  265. size_t elemsize;
  266. /* No dev_handle, since it can not be filtered, offset will always be zero */
  267. };
  268. void starpu_variable_data_register(starpu_data_handle_t *handle, uint32_t home_node, uintptr_t ptr, size_t size);
  269. size_t starpu_variable_get_elemsize(starpu_data_handle_t handle);
  270. uintptr_t starpu_variable_get_local_ptr(starpu_data_handle_t handle);
  271. /* helper methods */
  272. #define STARPU_VARIABLE_GET_PTR(interface) (((struct starpu_variable_interface *)(interface))->ptr)
  273. #define STARPU_VARIABLE_GET_ELEMSIZE(interface) (((struct starpu_variable_interface *)(interface))->elemsize)
  274. #define STARPU_VARIABLE_GET_DEV_HANDLE(interface) \
  275. (((struct starpu_variable_interface *)(interface))->ptr)
  276. #define STARPU_VARIABLE_GET_OFFSET 0
  277. /* void interface. There is no data really associated to that interface, but it
  278. * may be used as a synchronization mechanism. It also permits to express an
  279. * abstract piece of data that is managed by the application internally: this
  280. * makes it possible to forbid the concurrent execution of different tasks
  281. * accessing the same "void" data in read-write concurrently. */
  282. void starpu_void_data_register(starpu_data_handle_t *handle);
  283. /* CSR interface for sparse matrices (compressed sparse row representation) */
  284. struct starpu_csr_interface
  285. {
  286. uint32_t nnz; /* number of non-zero entries */
  287. uint32_t nrow; /* number of rows */
  288. uintptr_t nzval; /* non-zero values */
  289. uint32_t *colind; /* position of non-zero entries on the row */
  290. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  291. /* k for k-based indexing (0 or 1 usually) */
  292. /* also useful when partitionning the matrix ... */
  293. uint32_t firstentry;
  294. size_t elemsize;
  295. };
  296. void starpu_csr_data_register(starpu_data_handle_t *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);
  297. uint32_t starpu_csr_get_nnz(starpu_data_handle_t handle);
  298. uint32_t starpu_csr_get_nrow(starpu_data_handle_t handle);
  299. uint32_t starpu_csr_get_firstentry(starpu_data_handle_t handle);
  300. uintptr_t starpu_csr_get_local_nzval(starpu_data_handle_t handle);
  301. uint32_t *starpu_csr_get_local_colind(starpu_data_handle_t handle);
  302. uint32_t *starpu_csr_get_local_rowptr(starpu_data_handle_t handle);
  303. size_t starpu_csr_get_elemsize(starpu_data_handle_t handle);
  304. #define STARPU_CSR_GET_NNZ(interface) (((struct starpu_csr_interface *)(interface))->nnz)
  305. #define STARPU_CSR_GET_NROW(interface) (((struct starpu_csr_interface *)(interface))->nrow)
  306. #define STARPU_CSR_GET_NZVAL(interface) (((struct starpu_csr_interface *)(interface))->nzval)
  307. #define STARPU_CSR_GET_NZVAL_DEV_HANDLE \
  308. (((struct starpu_csr_interface *)(interface))->nnz)
  309. #define STARPU_CSR_GET_COLIND(interface) (((struct starpu_csr_interface *)(interface))->colind)
  310. #define STARPU_CSR_GET_COLIND_DEV_HANDLE(interface) \
  311. (((struct starpu_csr_interface *)(interface))->colind)
  312. #define STARPU_CSR_GET_ROWPTR(interface) (((struct starpu_csr_interface *)(interface))->rowptr)
  313. #define STARPU_CSR_GET_ROWPTR_DEV_HANDLE \
  314. (((struct starpu_csr_interface *)(interface))->rowptr)
  315. #define STARPU_CSR_GET_OFFSET 0
  316. #define STARPU_CSR_GET_FIRSTENTRY(interface) (((struct starpu_csr_interface *)(interface))->firstentry)
  317. #define STARPU_CSR_GET_ELEMSIZE(interface) (((struct starpu_csr_interface *)(interface))->elemsize)
  318. /* BCSR interface for sparse matrices (blocked compressed sparse row
  319. * representation) */
  320. struct starpu_bcsr_interface
  321. {
  322. uint32_t nnz; /* number of non-zero BLOCKS */
  323. uint32_t nrow; /* number of rows (in terms of BLOCKS) */
  324. uintptr_t nzval; /* non-zero values */
  325. uint32_t *colind; /* position of non-zero entried on the row */
  326. /* uint32_t *rowind; */ /* position of non-zero entried on the col */
  327. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  328. /* k for k-based indexing (0 or 1 usually) */
  329. /* also useful when partitionning the matrix ... */
  330. uint32_t firstentry;
  331. /* size of the blocks */
  332. uint32_t r;
  333. uint32_t c;
  334. size_t elemsize;
  335. };
  336. void starpu_bcsr_data_register(starpu_data_handle_t *handle, uint32_t 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);
  337. #define STARPU_BCSR_GET_NNZ(interface) (((struct starpu_bcsr_interface *)(interface))->nnz)
  338. #define STARPU_BCSR_GET_NZVAL(interface) (((struct starpu_bcsr_interface *)(interface))->nzval)
  339. #define STARPU_BCSR_GET_NZVAL_DEV_HANDLE(interface) \
  340. (((struct starpu_bcsr_interface *)(interface))->nnz)
  341. #define STARPU_BCSR_GET_COLIND(interface) (((struct starpu_bcsr_interface *)(interface))->colind)
  342. #define STARPU_BCSR_GET_COLIND_DEV_HANDLE(interface) \
  343. (((struct starpu_bcsr_interface *)(interface))->colind)
  344. #define STARPU_BCSR_GET_ROWPTR(interface) (((struct starpu_bcsr_interface *)(interface))->rowptr)
  345. #define STARPU_BCSR_GET_ROWPTR_DEV_HANDLE(interface) \
  346. (((struct starpu_bcsr_interface *)(interface))->rowptr)
  347. #define STARPU_BCSR_GET_OFFSET 0
  348. uint32_t starpu_bcsr_get_nnz(starpu_data_handle_t handle);
  349. uint32_t starpu_bcsr_get_nrow(starpu_data_handle_t handle);
  350. uint32_t starpu_bcsr_get_firstentry(starpu_data_handle_t handle);
  351. uintptr_t starpu_bcsr_get_local_nzval(starpu_data_handle_t handle);
  352. uint32_t *starpu_bcsr_get_local_colind(starpu_data_handle_t handle);
  353. uint32_t *starpu_bcsr_get_local_rowptr(starpu_data_handle_t handle);
  354. uint32_t starpu_bcsr_get_r(starpu_data_handle_t handle);
  355. uint32_t starpu_bcsr_get_c(starpu_data_handle_t handle);
  356. size_t starpu_bcsr_get_elemsize(starpu_data_handle_t handle);
  357. /*
  358. * Multiformat interface
  359. */
  360. struct starpu_multiformat_data_interface_ops
  361. {
  362. size_t cpu_elemsize;
  363. size_t opencl_elemsize;
  364. struct starpu_codelet *cpu_to_opencl_cl;
  365. struct starpu_codelet *opencl_to_cpu_cl;
  366. size_t cuda_elemsize;
  367. struct starpu_codelet *cpu_to_cuda_cl;
  368. struct starpu_codelet *cuda_to_cpu_cl;
  369. };
  370. struct starpu_multiformat_interface
  371. {
  372. void *cpu_ptr;
  373. void *cuda_ptr;
  374. void *opencl_ptr;
  375. uint32_t nx;
  376. struct starpu_multiformat_data_interface_ops *ops;
  377. };
  378. void starpu_multiformat_data_register(starpu_data_handle_t *handle, uint32_t home_node, void *ptr, uint32_t nobjects, struct starpu_multiformat_data_interface_ops *format_ops);
  379. #define STARPU_MULTIFORMAT_GET_CPU_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->cpu_ptr)
  380. #define STARPU_MULTIFORMAT_GET_CUDA_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->cuda_ptr)
  381. #define STARPU_MULTIFORMAT_GET_OPENCL_PTR(interface) (((struct starpu_multiformat_interface *)(interface))->opencl_ptr)
  382. #define STARPU_MULTIFORMAT_GET_NX(interface) (((struct starpu_multiformat_interface *)(interface))->nx)
  383. enum starpu_data_interface_id starpu_handle_get_interface_id(starpu_data_handle_t handle);
  384. int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr);
  385. int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr);
  386. size_t starpu_handle_get_size(starpu_data_handle_t handle);
  387. /* Lookup a ram pointer into a StarPU handle */
  388. extern starpu_data_handle_t starpu_data_lookup(const void *ptr);
  389. #ifdef __cplusplus
  390. }
  391. #endif
  392. #endif /* __STARPU_DATA_INTERFACES_H__ */