starpu_data_interfaces.h 20 KB

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