xgemm.c 16 KB

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