xgemm.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2010 Mehdi Juhoor
  5. * Copyright (C) 2017 Erwan Leria
  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. /*
  19. * Simple parallel GEMM implementation: partition the output matrix in the two
  20. * dimensions, and the input matrices in the corresponding dimension, and
  21. * perform the output computations in parallel.
  22. */
  23. #ifndef TYPE
  24. #error "Do not compile xgemm.c directly, compile sgemm.c or dgemm.c"
  25. #endif
  26. #include <limits.h>
  27. #include <string.h>
  28. #include <unistd.h>
  29. #include <math.h>
  30. #include <sys/types.h>
  31. #include <starpu.h>
  32. #include <starpu_fxt.h>
  33. #include <common/blas.h>
  34. #ifdef STARPU_USE_CUDA
  35. #include <cuda.h>
  36. #include <starpu_cublas_v2.h>
  37. static const TYPE p1 = 1.0;
  38. static const TYPE m1 = -1.0;
  39. static const TYPE v0 = 0.0;
  40. #endif
  41. static unsigned niter = 10;
  42. static unsigned nsleeps = 1;
  43. static unsigned nslicesx = 4;
  44. static unsigned nslicesy = 4;
  45. static unsigned nslicesz = 4;
  46. #if defined(STARPU_QUICK_CHECK) && !defined(STARPU_SIMGRID)
  47. static unsigned xdim = 256;
  48. static unsigned ydim = 256;
  49. static unsigned zdim = 64;
  50. #else
  51. static unsigned xdim = 960*4;
  52. static unsigned ydim = 960*4;
  53. static unsigned zdim = 960*4;
  54. #endif
  55. static unsigned check = 0;
  56. static unsigned bound = 0;
  57. static unsigned print_hostname = 0;
  58. static unsigned tiled = 0;
  59. static TYPE *A, *B, *C;
  60. static starpu_data_handle_t A_handle, B_handle, C_handle;
  61. #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
  62. #define PRINTF(fmt, ...) do { if (!getenv("STARPU_SSILENT")) {printf(fmt, ## __VA_ARGS__); fflush(stdout); }} while(0)
  63. static int check_output(void)
  64. {
  65. /* compute C = C - AB */
  66. CPU_GEMM("N", "N", ydim, xdim, zdim, (TYPE)-1.0f, A, ydim, B, zdim, (TYPE)1.0f, C, ydim);
  67. /* make sure C = 0 */
  68. TYPE err;
  69. err = CPU_ASUM(xdim*ydim, C, 1);
  70. if (err < EPSILON*xdim*ydim*zdim)
  71. {
  72. FPRINTF(stderr, "Results are OK\n");
  73. return 0;
  74. }
  75. else
  76. {
  77. int max;
  78. max = CPU_IAMAX(xdim*ydim, C, 1);
  79. FPRINTF(stderr, "There were errors ... err = %f\n", err);
  80. FPRINTF(stderr, "Max error : %e\n", C[max]);
  81. return 1;
  82. }
  83. }
  84. static void init_problem_data(void)
  85. {
  86. #ifndef STARPU_SIMGRID
  87. unsigned i,j;
  88. #endif
  89. starpu_malloc_flags((void **)&A, zdim*ydim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  90. starpu_malloc_flags((void **)&B, xdim*zdim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  91. starpu_malloc_flags((void **)&C, xdim*ydim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  92. #ifndef STARPU_SIMGRID
  93. /* fill the A and B matrices */
  94. for (j=0; j < ydim; j++)
  95. {
  96. for (i=0; i < zdim; i++)
  97. {
  98. A[j+i*ydim] = (TYPE)(starpu_drand48());
  99. }
  100. }
  101. for (j=0; j < zdim; j++)
  102. {
  103. for (i=0; i < xdim; i++)
  104. {
  105. B[j+i*zdim] = (TYPE)(starpu_drand48());
  106. }
  107. }
  108. for (j=0; j < ydim; j++)
  109. {
  110. for (i=0; i < xdim; i++)
  111. {
  112. C[j+i*ydim] = (TYPE)(0);
  113. }
  114. }
  115. #endif
  116. }
  117. static void partition_mult_data(void)
  118. {
  119. unsigned x, y, z;
  120. starpu_matrix_data_register(&A_handle, STARPU_MAIN_RAM, (uintptr_t)A,
  121. ydim, ydim, zdim, sizeof(TYPE));
  122. starpu_matrix_data_register(&B_handle, STARPU_MAIN_RAM, (uintptr_t)B,
  123. zdim, zdim, xdim, sizeof(TYPE));
  124. starpu_matrix_data_register(&C_handle, STARPU_MAIN_RAM, (uintptr_t)C,
  125. ydim, ydim, xdim, sizeof(TYPE));
  126. struct starpu_data_filter vert;
  127. memset(&vert, 0, sizeof(vert));
  128. vert.filter_func = starpu_matrix_filter_vertical_block;
  129. vert.nchildren = nslicesx;
  130. struct starpu_data_filter horiz;
  131. memset(&horiz, 0, sizeof(horiz));
  132. horiz.filter_func = starpu_matrix_filter_block;
  133. horiz.nchildren = nslicesy;
  134. if (tiled)
  135. {
  136. struct starpu_data_filter vertA;
  137. memset(&vertA, 0, sizeof(vertA));
  138. vertA.filter_func = starpu_matrix_filter_vertical_block;
  139. vertA.nchildren = nslicesz;
  140. struct starpu_data_filter horizB;
  141. memset(&horizB, 0, sizeof(horizB));
  142. horizB.filter_func = starpu_matrix_filter_block;
  143. horizB.nchildren = nslicesz;
  144. starpu_data_map_filters(A_handle, 2, &vertA, &horiz);
  145. starpu_data_map_filters(B_handle, 2, &vert, &horizB);
  146. starpu_data_map_filters(C_handle, 2, &vert, &horiz);
  147. for (y = 0; y < nslicesy; y++)
  148. for (z = 0; z < nslicesz; z++)
  149. starpu_data_set_coordinates(starpu_data_get_sub_data(A_handle, 2, z, y), 2, z, y);
  150. for (x = 0; x < nslicesx; x++)
  151. for (z = 0; z < nslicesz; z++)
  152. starpu_data_set_coordinates(starpu_data_get_sub_data(B_handle, 2, x, z), 2, x, z);
  153. }
  154. else
  155. {
  156. starpu_data_partition(B_handle, &vert);
  157. starpu_data_partition(A_handle, &horiz);
  158. starpu_data_map_filters(C_handle, 2, &vert, &horiz);
  159. }
  160. for (x = 0; x < nslicesx; x++)
  161. for (y = 0; y < nslicesy; y++)
  162. starpu_data_set_coordinates(starpu_data_get_sub_data(C_handle, 2, x, y), 2, x, y);
  163. }
  164. #ifdef STARPU_USE_CUDA
  165. static void cublas_mult(void *descr[], void *arg, const TYPE *beta)
  166. {
  167. (void)arg;
  168. TYPE *subA = (TYPE *)STARPU_MATRIX_GET_PTR(descr[0]);
  169. TYPE *subB = (TYPE *)STARPU_MATRIX_GET_PTR(descr[1]);
  170. TYPE *subC = (TYPE *)STARPU_MATRIX_GET_PTR(descr[2]);
  171. unsigned nxC = STARPU_MATRIX_GET_NX(descr[2]);
  172. unsigned nyC = STARPU_MATRIX_GET_NY(descr[2]);
  173. unsigned nyA = STARPU_MATRIX_GET_NY(descr[0]);
  174. unsigned ldA = STARPU_MATRIX_GET_LD(descr[0]);
  175. unsigned ldB = STARPU_MATRIX_GET_LD(descr[1]);
  176. unsigned ldC = STARPU_MATRIX_GET_LD(descr[2]);
  177. cublasStatus_t status = CUBLAS_GEMM(starpu_cublas_get_local_handle(),
  178. CUBLAS_OP_N, CUBLAS_OP_N,
  179. nxC, nyC, nyA,
  180. &p1, subA, ldA, subB, ldB,
  181. beta, subC, ldC);
  182. if (status != CUBLAS_STATUS_SUCCESS)
  183. STARPU_CUBLAS_REPORT_ERROR(status);
  184. }
  185. static void cublas_gemm0(void *descr[], void *arg)
  186. {
  187. cublas_mult(descr, arg, &v0);
  188. }
  189. static void cublas_gemm(void *descr[], void *arg)
  190. {
  191. cublas_mult(descr, arg, &p1);
  192. }
  193. #endif
  194. void cpu_mult(void *descr[], void *arg, TYPE beta)
  195. {
  196. (void)arg;
  197. TYPE *subA = (TYPE *)STARPU_MATRIX_GET_PTR(descr[0]);
  198. TYPE *subB = (TYPE *)STARPU_MATRIX_GET_PTR(descr[1]);
  199. TYPE *subC = (TYPE *)STARPU_MATRIX_GET_PTR(descr[2]);
  200. unsigned nxC = STARPU_MATRIX_GET_NX(descr[2]);
  201. unsigned nyC = STARPU_MATRIX_GET_NY(descr[2]);
  202. unsigned nyA = STARPU_MATRIX_GET_NY(descr[0]);
  203. unsigned ldA = STARPU_MATRIX_GET_LD(descr[0]);
  204. unsigned ldB = STARPU_MATRIX_GET_LD(descr[1]);
  205. unsigned ldC = STARPU_MATRIX_GET_LD(descr[2]);
  206. int worker_size = starpu_combined_worker_get_size();
  207. if (worker_size == 1)
  208. {
  209. /* Sequential CPU task */
  210. CPU_GEMM("N", "N", nxC, nyC, nyA, (TYPE)1.0, subA, ldA, subB, ldB, beta, subC, ldC);
  211. }
  212. else
  213. {
  214. /* Parallel CPU task */
  215. unsigned rank = starpu_combined_worker_get_rank();
  216. unsigned block_size = (nyC + worker_size - 1)/worker_size;
  217. unsigned new_nyC = STARPU_MIN(nyC, block_size*(rank+1)) - block_size*rank;
  218. STARPU_ASSERT(nyC == STARPU_MATRIX_GET_NY(descr[1]));
  219. TYPE *new_subB = &subB[block_size*rank];
  220. TYPE *new_subC = &subC[block_size*rank];
  221. CPU_GEMM("N", "N", nxC, new_nyC, nyA, (TYPE)1.0, subA, ldA, new_subB, ldB, beta, new_subC, ldC);
  222. }
  223. }
  224. void cpu_gemm0(void *descr[], void *arg)
  225. {
  226. cpu_mult(descr, arg, 0.);
  227. }
  228. void cpu_gemm(void *descr[], void *arg)
  229. {
  230. cpu_mult(descr, arg, 1.);
  231. }
  232. static struct starpu_perfmodel starpu_gemm_model =
  233. {
  234. .type = STARPU_HISTORY_BASED,
  235. .symbol = STARPU_GEMM_STR(gemm)
  236. };
  237. static struct starpu_codelet cl_gemm0 =
  238. {
  239. .type = STARPU_SEQ, /* changed to STARPU_SPMD if -spmd is passed */
  240. .max_parallelism = INT_MAX,
  241. .cpu_funcs = {cpu_gemm0},
  242. .cpu_funcs_name = {"cpu_gemm0"},
  243. #ifdef STARPU_USE_CUDA
  244. .cuda_funcs = {cublas_gemm0},
  245. #elif defined(STARPU_SIMGRID)
  246. .cuda_funcs = {(void*)1},
  247. #endif
  248. .cuda_flags = {STARPU_CUDA_ASYNC},
  249. .nbuffers = 3,
  250. .modes = {STARPU_R, STARPU_R, STARPU_W},
  251. .model = &starpu_gemm_model
  252. };
  253. static struct starpu_codelet cl_gemm =
  254. {
  255. .type = STARPU_SEQ, /* changed to STARPU_SPMD if -spmd is passed */
  256. .max_parallelism = INT_MAX,
  257. .cpu_funcs = {cpu_gemm},
  258. .cpu_funcs_name = {"cpu_gemm"},
  259. #ifdef STARPU_USE_CUDA
  260. .cuda_funcs = {cublas_gemm},
  261. #elif defined(STARPU_SIMGRID)
  262. .cuda_funcs = {(void*)1},
  263. #endif
  264. .cuda_flags = {STARPU_CUDA_ASYNC},
  265. .nbuffers = 3,
  266. .modes = {STARPU_R, STARPU_R, STARPU_RW},
  267. .model = &starpu_gemm_model
  268. };
  269. static void parse_args(int argc, char **argv)
  270. {
  271. int i;
  272. for (i = 1; i < argc; i++)
  273. {
  274. if (strcmp(argv[i], "-3d") == 0)
  275. {
  276. tiled = 1;
  277. }
  278. else if (strcmp(argv[i], "-nblocks") == 0)
  279. {
  280. char *argptr;
  281. nslicesx = strtol(argv[++i], &argptr, 10);
  282. nslicesy = nslicesx;
  283. nslicesz = nslicesx;
  284. if (nslicesx == 0)
  285. {
  286. fprintf(stderr, "the number of blocks in X cannot be 0!\n");
  287. exit(EXIT_FAILURE);
  288. }
  289. if (nslicesy == 0)
  290. {
  291. fprintf(stderr, "the number of blocks in Y cannot be 0!\n");
  292. exit(EXIT_FAILURE);
  293. }
  294. }
  295. else if (strcmp(argv[i], "-nblocksx") == 0)
  296. {
  297. char *argptr;
  298. nslicesx = strtol(argv[++i], &argptr, 10);
  299. if (nslicesx == 0)
  300. {
  301. fprintf(stderr, "the number of blocks in X cannot be 0!\n");
  302. exit(EXIT_FAILURE);
  303. }
  304. }
  305. else if (strcmp(argv[i], "-nblocksy") == 0)
  306. {
  307. char *argptr;
  308. nslicesy = strtol(argv[++i], &argptr, 10);
  309. if (nslicesy == 0)
  310. {
  311. fprintf(stderr, "the number of blocks in Y cannot be 0!\n");
  312. exit(EXIT_FAILURE);
  313. }
  314. }
  315. else if (strcmp(argv[i], "-nblocksz") == 0)
  316. {
  317. char *argptr;
  318. nslicesz = strtol(argv[++i], &argptr, 10);
  319. if (nslicesz == 0)
  320. {
  321. fprintf(stderr, "the number of blocks in Z cannot be 0!\n");
  322. exit(EXIT_FAILURE);
  323. }
  324. }
  325. else if (strcmp(argv[i], "-x") == 0)
  326. {
  327. char *argptr;
  328. xdim = strtol(argv[++i], &argptr, 10);
  329. }
  330. else if (strcmp(argv[i], "-xy") == 0)
  331. {
  332. char *argptr;
  333. xdim = ydim = strtol(argv[++i], &argptr, 10);
  334. }
  335. else if (strcmp(argv[i], "-y") == 0)
  336. {
  337. char *argptr;
  338. ydim = strtol(argv[++i], &argptr, 10);
  339. }
  340. else if (strcmp(argv[i], "-z") == 0)
  341. {
  342. char *argptr;
  343. zdim = strtol(argv[++i], &argptr, 10);
  344. }
  345. else if (strcmp(argv[i], "-size") == 0)
  346. {
  347. char *argptr;
  348. xdim = ydim = zdim = strtol(argv[++i], &argptr, 10);
  349. }
  350. else if (strcmp(argv[i], "-iter") == 0)
  351. {
  352. char *argptr;
  353. niter = strtol(argv[++i], &argptr, 10);
  354. }
  355. else if (strcmp(argv[i], "-nsleeps") == 0)
  356. {
  357. char *argptr;
  358. nsleeps = strtol(argv[++i], &argptr, 10);
  359. }
  360. else if (strcmp(argv[i], "-bound") == 0)
  361. {
  362. bound = 1;
  363. }
  364. else if (strcmp(argv[i], "-hostname") == 0)
  365. {
  366. print_hostname = 1;
  367. }
  368. else if (strcmp(argv[i], "-check") == 0)
  369. {
  370. check = 1;
  371. }
  372. else if (strcmp(argv[i], "-spmd") == 0)
  373. {
  374. cl_gemm0.type = STARPU_SPMD;
  375. }
  376. else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
  377. {
  378. fprintf(stderr,"Usage: %s [-3d] [-nblocks n] [-nblocksx x] [-nblocksy y] [-nblocksz z] [-x x] [-y y] [-xy n] [-z z] [-size size] [-iter iter] [-bound] [-check] [-spmd] [-hostname] [-nsleeps nsleeps]\n", argv[0]);
  379. if (tiled)
  380. fprintf(stderr,"Currently selected: %ux%u * %ux%u and %ux%ux%u blocks (size %ux%u length %u), %u iterations, %u sleeps\n", zdim, ydim, xdim, zdim, nslicesx, nslicesy, nslicesz, xdim / nslicesx, ydim / nslicesy, zdim / nslicesz, niter, nsleeps);
  381. else
  382. fprintf(stderr,"Currently selected: %ux%u * %ux%u and %ux%u blocks (size %ux%u length %u), %u iterations, %u sleeps\n", zdim, ydim, xdim, zdim, nslicesx, nslicesy, xdim / nslicesx, ydim / nslicesy, zdim, niter, nsleeps);
  383. exit(EXIT_SUCCESS);
  384. }
  385. else
  386. {
  387. fprintf(stderr,"Unrecognized option %s\n", argv[i]);
  388. exit(EXIT_FAILURE);
  389. }
  390. }
  391. }
  392. int main(int argc, char **argv)
  393. {
  394. double start, end;
  395. int ret;
  396. parse_args(argc, argv);
  397. #ifdef STARPU_QUICK_CHECK
  398. niter /= 10;
  399. #endif
  400. starpu_fxt_autostart_profiling(0);
  401. ret = starpu_init(NULL);
  402. if (ret == -ENODEV)
  403. return 77;
  404. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  405. starpu_cublas_init();
  406. init_problem_data();
  407. partition_mult_data();
  408. PRINTF("# ");
  409. if (print_hostname)
  410. PRINTF("node\t");
  411. PRINTF("x\ty\tz\tms\tGFlops");
  412. if (bound)
  413. PRINTF("\tTms\tTGFlops\tTims\tTiGFlops");
  414. PRINTF("\n");
  415. unsigned sleeps;
  416. for (sleeps = 0; sleeps < nsleeps; sleeps++)
  417. {
  418. if (bound)
  419. starpu_bound_start(0, 0);
  420. starpu_fxt_start_profiling();
  421. start = starpu_timing_now();
  422. unsigned x, y, z, iter;
  423. for (iter = 0; iter < niter; iter++)
  424. {
  425. if (tiled)
  426. {
  427. for (x = 0; x < nslicesx; x++)
  428. for (y = 0; y < nslicesy; y++)
  429. {
  430. starpu_data_handle_t Ctile = starpu_data_get_sub_data(C_handle, 2, x, y);
  431. for (z = 0; z < nslicesz; z++)
  432. {
  433. struct starpu_task *task = starpu_task_create();
  434. if (z == 0)
  435. task->cl = &cl_gemm0;
  436. else
  437. task->cl = &cl_gemm;
  438. task->handles[0] = starpu_data_get_sub_data(A_handle, 2, z, y);
  439. task->handles[1] = starpu_data_get_sub_data(B_handle, 2, x, z);
  440. task->handles[2] = Ctile;
  441. task->flops = 2ULL * (xdim/nslicesx) * (ydim/nslicesy) * (zdim/nslicesz);
  442. ret = starpu_task_submit(task);
  443. if (ret == -ENODEV)
  444. {
  445. check = 0;
  446. ret = 77;
  447. goto enodev;
  448. }
  449. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  450. }
  451. starpu_data_wont_use(Ctile);
  452. }
  453. }
  454. else
  455. {
  456. for (x = 0; x < nslicesx; x++)
  457. for (y = 0; y < nslicesy; y++)
  458. {
  459. struct starpu_task *task = starpu_task_create();
  460. task->cl = &cl_gemm0;
  461. task->handles[0] = starpu_data_get_sub_data(A_handle, 1, y);
  462. task->handles[1] = starpu_data_get_sub_data(B_handle, 1, x);
  463. task->handles[2] = starpu_data_get_sub_data(C_handle, 2, x, y);
  464. task->flops = 2ULL * (xdim/nslicesx) * (ydim/nslicesy) * zdim;
  465. ret = starpu_task_submit(task);
  466. if (ret == -ENODEV)
  467. {
  468. check = 0;
  469. ret = 77;
  470. goto enodev;
  471. }
  472. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  473. starpu_data_wont_use(starpu_data_get_sub_data(C_handle, 2, x, y));
  474. }
  475. }
  476. starpu_task_wait_for_all();
  477. }
  478. end = starpu_timing_now();
  479. starpu_fxt_stop_profiling();
  480. if (bound)
  481. starpu_bound_stop();
  482. double timing = end - start;
  483. double min, min_int;
  484. double flops = 2.0*((unsigned long long)niter)*((unsigned long long)xdim)
  485. *((unsigned long long)ydim)*((unsigned long long)zdim);
  486. if (bound)
  487. starpu_bound_compute(&min, &min_int, 1);
  488. if (print_hostname)
  489. {
  490. char hostname[255];
  491. gethostname(hostname, 255);
  492. PRINTF("%s\t", hostname);
  493. }
  494. PRINTF("%u\t%u\t%u\t%.0f\t%.1f", xdim, ydim, zdim, timing/niter/1000.0, flops/timing/1000.0);
  495. if (bound)
  496. PRINTF("\t%.0f\t%.1f\t%.0f\t%.1f", min, flops/min/1000000.0, min_int, flops/min_int/1000000.0);
  497. PRINTF("\n");
  498. if (sleeps < nsleeps-1)
  499. {
  500. sleep(10);
  501. }
  502. }
  503. enodev:
  504. starpu_data_unpartition(C_handle, STARPU_MAIN_RAM);
  505. starpu_data_unpartition(B_handle, STARPU_MAIN_RAM);
  506. starpu_data_unpartition(A_handle, STARPU_MAIN_RAM);
  507. starpu_data_unregister(A_handle);
  508. starpu_data_unregister(B_handle);
  509. starpu_data_unregister(C_handle);
  510. #ifndef STARPU_SIMGRID
  511. if (check)
  512. ret = check_output();
  513. #endif
  514. starpu_free_flags(A, zdim*ydim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  515. starpu_free_flags(B, xdim*zdim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  516. starpu_free_flags(C, xdim*ydim*sizeof(TYPE), STARPU_MALLOC_PINNED|STARPU_MALLOC_SIMULATION_FOLDED);
  517. starpu_cublas_shutdown();
  518. starpu_shutdown();
  519. return ret;
  520. }