starpu_data_interfaces.h 21 KB

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