starpu_data_interfaces.h 20 KB

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