matrix_interface.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include <common/config.h>
  18. #include <datawizard/coherency.h>
  19. #include <datawizard/copy_driver.h>
  20. #include <datawizard/filters.h>
  21. #include <common/hash.h>
  22. #include <starpu_cuda.h>
  23. #include <starpu_opencl.h>
  24. #include <drivers/opencl/driver_opencl.h>
  25. static int dummy_copy_ram_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)));
  26. #ifdef STARPU_USE_CUDA
  27. static int copy_ram_to_cuda(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)));
  28. static int copy_cuda_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)));
  29. static int copy_ram_to_cuda_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), cudaStream_t *stream);
  30. static int copy_cuda_to_ram_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), cudaStream_t *stream);
  31. #endif
  32. #ifdef STARPU_USE_OPENCL
  33. static int copy_ram_to_opencl(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)));
  34. static int copy_opencl_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)));
  35. static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), void *_event);
  36. static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), void *_event);
  37. #endif
  38. static const struct starpu_data_copy_methods matrix_copy_data_methods_s = {
  39. .ram_to_ram = dummy_copy_ram_to_ram,
  40. .ram_to_spu = NULL,
  41. #ifdef STARPU_USE_CUDA
  42. .ram_to_cuda = copy_ram_to_cuda,
  43. .cuda_to_ram = copy_cuda_to_ram,
  44. .ram_to_cuda_async = copy_ram_to_cuda_async,
  45. .cuda_to_ram_async = copy_cuda_to_ram_async,
  46. #endif
  47. #ifdef STARPU_USE_OPENCL
  48. .ram_to_opencl = copy_ram_to_opencl,
  49. .opencl_to_ram = copy_opencl_to_ram,
  50. .ram_to_opencl_async = copy_ram_to_opencl_async,
  51. .opencl_to_ram_async = copy_opencl_to_ram_async,
  52. #endif
  53. .cuda_to_cuda = NULL,
  54. .cuda_to_spu = NULL,
  55. .spu_to_ram = NULL,
  56. .spu_to_cuda = NULL,
  57. .spu_to_spu = NULL
  58. };
  59. static void register_matrix_handle(starpu_data_handle handle, uint32_t home_node, void *interface);
  60. static size_t allocate_matrix_buffer_on_node(void *interface_, uint32_t dst_node);
  61. static void free_matrix_buffer_on_node(void *interface, uint32_t node);
  62. static size_t matrix_interface_get_size(starpu_data_handle handle);
  63. static uint32_t footprint_matrix_interface_crc32(starpu_data_handle handle);
  64. static int matrix_compare(void *interface_a, void *interface_b);
  65. static void display_matrix_interface(starpu_data_handle handle, FILE *f);
  66. #ifdef STARPU_USE_GORDON
  67. static int convert_matrix_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss);
  68. #endif
  69. struct starpu_data_interface_ops_t _starpu_interface_matrix_ops = {
  70. .register_data_handle = register_matrix_handle,
  71. .allocate_data_on_node = allocate_matrix_buffer_on_node,
  72. .free_data_on_node = free_matrix_buffer_on_node,
  73. .copy_methods = &matrix_copy_data_methods_s,
  74. .get_size = matrix_interface_get_size,
  75. .footprint = footprint_matrix_interface_crc32,
  76. .compare = matrix_compare,
  77. #ifdef STARPU_USE_GORDON
  78. .convert_to_gordon = convert_matrix_to_gordon,
  79. #endif
  80. .interfaceid = STARPU_MATRIX_INTERFACE_ID,
  81. .interface_size = sizeof(starpu_matrix_interface_t),
  82. .display = display_matrix_interface
  83. };
  84. #ifdef STARPU_USE_GORDON
  85. static int convert_matrix_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss)
  86. {
  87. size_t elemsize = GET_MATRIX_ELEMSIZE(interface);
  88. uint32_t nx = STARPU_MATRIX_GET_NX(interface);
  89. uint32_t ny = STARPU_MATRIX_GET_NY(interface);
  90. uint32_t ld = STARPU_MATRIX_GET_LD(interface);
  91. *ptr = STARPU_MATRIX_GET_PTR(interface);
  92. /* The gordon_stride_init function may use a contiguous buffer
  93. * in case nx = ld (in that case, (*ss).size = elemsize*nx*ny */
  94. *ss = gordon_stride_init(ny, nx*elemsize, ld*elemsize);
  95. return 0;
  96. }
  97. #endif
  98. static void register_matrix_handle(starpu_data_handle handle, uint32_t home_node, void *interface)
  99. {
  100. starpu_matrix_interface_t *matrix_interface = interface;
  101. unsigned node;
  102. for (node = 0; node < STARPU_MAXNODES; node++)
  103. {
  104. starpu_matrix_interface_t *local_interface =
  105. starpu_data_get_interface_on_node(handle, node);
  106. if (node == home_node) {
  107. local_interface->ptr = matrix_interface->ptr;
  108. local_interface->dev_handle = matrix_interface->dev_handle;
  109. local_interface->offset = matrix_interface->offset;
  110. local_interface->ld = matrix_interface->ld;
  111. }
  112. else {
  113. local_interface->ptr = 0;
  114. local_interface->dev_handle = 0;
  115. local_interface->offset = 0;
  116. local_interface->ld = 0;
  117. }
  118. local_interface->nx = matrix_interface->nx;
  119. local_interface->ny = matrix_interface->ny;
  120. local_interface->elemsize = matrix_interface->elemsize;
  121. }
  122. }
  123. /* declare a new data with the matrix interface */
  124. void starpu_matrix_data_register(starpu_data_handle *handleptr, uint32_t home_node,
  125. uintptr_t ptr, uint32_t ld, uint32_t nx,
  126. uint32_t ny, size_t elemsize)
  127. {
  128. starpu_matrix_interface_t interface = {
  129. .ptr = ptr,
  130. .ld = ld,
  131. .nx = nx,
  132. .ny = ny,
  133. .elemsize = elemsize,
  134. .dev_handle = ptr,
  135. .offset = 0
  136. };
  137. starpu_data_register(handleptr, home_node, &interface, &_starpu_interface_matrix_ops);
  138. }
  139. static uint32_t footprint_matrix_interface_crc32(starpu_data_handle handle)
  140. {
  141. return _starpu_crc32_be(starpu_matrix_get_nx(handle), starpu_matrix_get_ny(handle));
  142. }
  143. static int matrix_compare(void *interface_a, void *interface_b)
  144. {
  145. starpu_matrix_interface_t *matrix_a = interface_a;
  146. starpu_matrix_interface_t *matrix_b = interface_b;
  147. /* Two matricess are considered compatible if they have the same size */
  148. return ((matrix_a->nx == matrix_b->nx)
  149. && (matrix_a->ny == matrix_b->ny)
  150. && (matrix_a->elemsize == matrix_b->elemsize));
  151. }
  152. static void display_matrix_interface(starpu_data_handle handle, FILE *f)
  153. {
  154. starpu_matrix_interface_t *interface =
  155. starpu_data_get_interface_on_node(handle, 0);
  156. fprintf(f, "%u\t%u\t", interface->nx, interface->ny);
  157. }
  158. static size_t matrix_interface_get_size(starpu_data_handle handle)
  159. {
  160. starpu_matrix_interface_t *interface =
  161. starpu_data_get_interface_on_node(handle, 0);
  162. size_t size;
  163. size = (size_t)interface->nx*interface->ny*interface->elemsize;
  164. return size;
  165. }
  166. /* offer an access to the data parameters */
  167. uint32_t starpu_matrix_get_nx(starpu_data_handle handle)
  168. {
  169. starpu_matrix_interface_t *interface =
  170. starpu_data_get_interface_on_node(handle, 0);
  171. return interface->nx;
  172. }
  173. uint32_t starpu_matrix_get_ny(starpu_data_handle handle)
  174. {
  175. starpu_matrix_interface_t *interface =
  176. starpu_data_get_interface_on_node(handle, 0);
  177. return interface->ny;
  178. }
  179. uint32_t starpu_matrix_get_local_ld(starpu_data_handle handle)
  180. {
  181. unsigned node;
  182. node = _starpu_get_local_memory_node();
  183. STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
  184. starpu_matrix_interface_t *interface =
  185. starpu_data_get_interface_on_node(handle, node);
  186. return interface->ld;
  187. }
  188. uintptr_t starpu_matrix_get_local_ptr(starpu_data_handle handle)
  189. {
  190. unsigned node;
  191. node = _starpu_get_local_memory_node();
  192. STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
  193. starpu_matrix_interface_t *interface =
  194. starpu_data_get_interface_on_node(handle, node);
  195. return interface->ptr;
  196. }
  197. size_t starpu_matrix_get_elemsize(starpu_data_handle handle)
  198. {
  199. starpu_matrix_interface_t *interface =
  200. starpu_data_get_interface_on_node(handle, 0);
  201. return interface->elemsize;
  202. }
  203. /* memory allocation/deallocation primitives for the matrix interface */
  204. /* returns the size of the allocated area */
  205. static size_t allocate_matrix_buffer_on_node(void *interface_, uint32_t dst_node)
  206. {
  207. uintptr_t addr = 0;
  208. unsigned fail = 0;
  209. size_t allocated_memory;
  210. #ifdef STARPU_USE_CUDA
  211. cudaError_t status;
  212. #endif
  213. starpu_matrix_interface_t *interface = interface_;
  214. uint32_t nx = interface->nx;
  215. uint32_t ny = interface->ny;
  216. uint32_t ld = nx; // by default
  217. size_t elemsize = interface->elemsize;
  218. starpu_node_kind kind = _starpu_get_node_kind(dst_node);
  219. switch(kind) {
  220. case STARPU_CPU_RAM:
  221. addr = (uintptr_t)malloc((size_t)nx*ny*elemsize);
  222. if (!addr)
  223. fail = 1;
  224. break;
  225. #ifdef STARPU_USE_CUDA
  226. case STARPU_CUDA_RAM:
  227. status = cudaMalloc((void **)&addr, (size_t)nx*ny*elemsize);
  228. if (!addr || status != cudaSuccess)
  229. {
  230. if (STARPU_UNLIKELY(status != cudaErrorMemoryAllocation))
  231. STARPU_CUDA_REPORT_ERROR(status);
  232. fail = 1;
  233. }
  234. ld = nx;
  235. break;
  236. #endif
  237. #ifdef STARPU_USE_OPENCL
  238. case STARPU_OPENCL_RAM:
  239. {
  240. int ret;
  241. void *ptr;
  242. ret = _starpu_opencl_allocate_memory(&ptr, nx*ny*elemsize, CL_MEM_READ_WRITE);
  243. addr = (uintptr_t)ptr;
  244. if (ret) {
  245. fail = 1;
  246. }
  247. break;
  248. }
  249. #endif
  250. default:
  251. assert(0);
  252. }
  253. if (!fail) {
  254. /* allocation succeeded */
  255. allocated_memory = (size_t)nx*ny*elemsize;
  256. /* update the data properly in consequence */
  257. interface->ptr = addr;
  258. interface->dev_handle = addr;
  259. interface->offset = 0;
  260. interface->ld = ld;
  261. } else {
  262. /* allocation failed */
  263. allocated_memory = 0;
  264. }
  265. return allocated_memory;
  266. }
  267. static void free_matrix_buffer_on_node(void *interface, uint32_t node)
  268. {
  269. starpu_matrix_interface_t *matrix_interface = interface;
  270. #ifdef STARPU_USE_CUDA
  271. cudaError_t status;
  272. #endif
  273. starpu_node_kind kind = _starpu_get_node_kind(node);
  274. switch(kind) {
  275. case STARPU_CPU_RAM:
  276. free((void*)matrix_interface->ptr);
  277. break;
  278. #ifdef STARPU_USE_CUDA
  279. case STARPU_CUDA_RAM:
  280. status = cudaFree((void*)matrix_interface->ptr);
  281. if (STARPU_UNLIKELY(status))
  282. STARPU_CUDA_REPORT_ERROR(status);
  283. break;
  284. #endif
  285. #ifdef STARPU_USE_OPENCL
  286. case STARPU_OPENCL_RAM:
  287. clReleaseMemObject((void *)matrix_interface->ptr);
  288. break;
  289. #endif
  290. default:
  291. assert(0);
  292. }
  293. }
  294. #ifdef STARPU_USE_CUDA
  295. static int copy_cuda_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)))
  296. {
  297. starpu_matrix_interface_t *src_matrix = src_interface;
  298. starpu_matrix_interface_t *dst_matrix = dst_interface;
  299. size_t elemsize = src_matrix->elemsize;
  300. cudaError_t cures;
  301. cures = cudaMemcpy2D((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  302. (char *)src_matrix->ptr, src_matrix->ld*elemsize,
  303. src_matrix->nx*elemsize, src_matrix->ny, cudaMemcpyDeviceToHost);
  304. if (STARPU_UNLIKELY(cures))
  305. STARPU_CUDA_REPORT_ERROR(cures);
  306. STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  307. return 0;
  308. }
  309. static int copy_ram_to_cuda(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)))
  310. {
  311. starpu_matrix_interface_t *src_matrix = src_interface;
  312. starpu_matrix_interface_t *dst_matrix = dst_interface;
  313. size_t elemsize = src_matrix->elemsize;
  314. cudaError_t cures;
  315. cures = cudaMemcpy2D((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  316. (char *)src_matrix->ptr, src_matrix->ld*elemsize,
  317. src_matrix->nx*elemsize, src_matrix->ny, cudaMemcpyHostToDevice);
  318. if (STARPU_UNLIKELY(cures))
  319. STARPU_CUDA_REPORT_ERROR(cures);
  320. cures = cudaThreadSynchronize();
  321. if (STARPU_UNLIKELY(cures))
  322. STARPU_CUDA_REPORT_ERROR(cures);
  323. STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  324. return 0;
  325. }
  326. static int copy_cuda_to_ram_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), cudaStream_t *stream)
  327. {
  328. starpu_matrix_interface_t *src_matrix = src_interface;
  329. starpu_matrix_interface_t *dst_matrix = dst_interface;
  330. size_t elemsize = src_matrix->elemsize;
  331. cudaError_t cures;
  332. cures = cudaMemcpy2DAsync((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  333. (char *)src_matrix->ptr, (size_t)src_matrix->ld*elemsize,
  334. (size_t)src_matrix->nx*elemsize, src_matrix->ny,
  335. cudaMemcpyDeviceToHost, *stream);
  336. if (cures)
  337. {
  338. cures = cudaMemcpy2D((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  339. (char *)src_matrix->ptr, (size_t)src_matrix->ld*elemsize,
  340. (size_t)src_matrix->nx*elemsize, (size_t)src_matrix->ny,
  341. cudaMemcpyDeviceToHost);
  342. if (STARPU_UNLIKELY(cures))
  343. STARPU_CUDA_REPORT_ERROR(cures);
  344. cures = cudaThreadSynchronize();
  345. if (STARPU_UNLIKELY(cures))
  346. STARPU_CUDA_REPORT_ERROR(cures);
  347. return 0;
  348. }
  349. STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  350. return EAGAIN;
  351. }
  352. static int copy_ram_to_cuda_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), cudaStream_t *stream)
  353. {
  354. starpu_matrix_interface_t *src_matrix = src_interface;
  355. starpu_matrix_interface_t *dst_matrix = dst_interface;
  356. size_t elemsize = src_matrix->elemsize;
  357. cudaError_t cures;
  358. cures = cudaMemcpy2DAsync((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  359. (char *)src_matrix->ptr, src_matrix->ld*elemsize,
  360. src_matrix->nx*elemsize, src_matrix->ny,
  361. cudaMemcpyHostToDevice, *stream);
  362. if (cures)
  363. {
  364. cures = cudaMemcpy2D((char *)dst_matrix->ptr, dst_matrix->ld*elemsize,
  365. (char *)src_matrix->ptr, src_matrix->ld*elemsize,
  366. src_matrix->nx*elemsize, src_matrix->ny, cudaMemcpyHostToDevice);
  367. cudaThreadSynchronize();
  368. if (STARPU_UNLIKELY(cures))
  369. STARPU_CUDA_REPORT_ERROR(cures);
  370. return 0;
  371. }
  372. STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  373. return EAGAIN;
  374. }
  375. #endif // STARPU_USE_CUDA
  376. #ifdef STARPU_USE_OPENCL
  377. static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), void *_event)
  378. {
  379. starpu_matrix_interface_t *src_matrix = src_interface;
  380. starpu_matrix_interface_t *dst_matrix = dst_interface;
  381. int err,ret;
  382. /* XXX non contiguous matrices are not supported with OpenCL yet ! (TODO) */
  383. STARPU_ASSERT((src_matrix->ld == src_matrix->nx) && (dst_matrix->ld == dst_matrix->nx));
  384. err = _starpu_opencl_copy_ram_to_opencl_async_sync((void*)src_matrix->ptr, (cl_mem)dst_matrix->dev_handle,
  385. src_matrix->nx*src_matrix->ny*src_matrix->elemsize,
  386. dst_matrix->offset, (cl_event*)_event, &ret);
  387. if (STARPU_UNLIKELY(err))
  388. STARPU_OPENCL_REPORT_ERROR(err);
  389. STARPU_TRACE_DATA_COPY(src_node, dst_node, src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  390. return ret;
  391. }
  392. static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)), void *_event)
  393. {
  394. starpu_matrix_interface_t *src_matrix = src_interface;
  395. starpu_matrix_interface_t *dst_matrix = dst_interface;
  396. int err, ret;
  397. /* XXX non contiguous matrices are not supported with OpenCL yet ! (TODO) */
  398. STARPU_ASSERT((src_matrix->ld == src_matrix->nx) && (dst_matrix->ld == dst_matrix->nx));
  399. err = _starpu_opencl_copy_opencl_to_ram_async_sync((cl_mem)src_matrix->dev_handle, (void*)dst_matrix->ptr,
  400. src_matrix->nx*src_matrix->ny*src_matrix->elemsize,
  401. src_matrix->offset, (cl_event*)_event, &ret);
  402. if (STARPU_UNLIKELY(err))
  403. STARPU_OPENCL_REPORT_ERROR(err);
  404. STARPU_TRACE_DATA_COPY(src_node, dst_node, src_matrix->nx*src_matrix->ny*src_matrix->elemsize);
  405. return ret;
  406. }
  407. static int copy_ram_to_opencl(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)))
  408. {
  409. return copy_ram_to_opencl_async(src_interface, src_node, dst_interface, dst_node, NULL);
  410. }
  411. static int copy_opencl_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)))
  412. {
  413. return copy_opencl_to_ram_async(src_interface, src_node, dst_interface, dst_node, NULL);
  414. }
  415. #endif
  416. /* as not all platform easily have a lib installed ... */
  417. static int dummy_copy_ram_to_ram(void *src_interface, unsigned src_node __attribute__((unused)), void *dst_interface, unsigned dst_node __attribute__((unused)))
  418. {
  419. starpu_matrix_interface_t *src_matrix = src_interface;
  420. starpu_matrix_interface_t *dst_matrix = dst_interface;
  421. unsigned y;
  422. uint32_t nx = dst_matrix->nx;
  423. uint32_t ny = dst_matrix->ny;
  424. size_t elemsize = dst_matrix->elemsize;
  425. uint32_t ld_src = src_matrix->ld;
  426. uint32_t ld_dst = dst_matrix->ld;
  427. uintptr_t ptr_src = src_matrix->ptr;
  428. uintptr_t ptr_dst = dst_matrix->ptr;
  429. for (y = 0; y < ny; y++)
  430. {
  431. uint32_t src_offset = y*ld_src*elemsize;
  432. uint32_t dst_offset = y*ld_dst*elemsize;
  433. memcpy((void *)(ptr_dst + dst_offset),
  434. (void *)(ptr_src + src_offset), nx*elemsize);
  435. }
  436. STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)nx*ny*elemsize);
  437. return 0;
  438. }