test_interfaces.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU 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. * StarPU 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 <datawizard/coherency.h>
  18. #include <assert.h>
  19. #include "test_interfaces.h"
  20. #include "../../helper.h"
  21. /*
  22. * This is definitely note thread-safe.
  23. */
  24. static struct test_config *current_config;
  25. /* TODO :
  26. - OpenCL to OpenCL support
  27. */
  28. static char *enum_to_string(int exit_code)
  29. {
  30. switch (exit_code)
  31. {
  32. case SUCCESS:
  33. return "Success";
  34. case FAILURE:
  35. return "Failure";
  36. case UNTESTED:
  37. return "Untested";
  38. case NO_DEVICE:
  39. return "No device available";
  40. case TASK_SUBMISSION_FAILURE:
  41. return "Task submission failed";
  42. default:
  43. assert(0);
  44. }
  45. }
  46. void data_interface_test_summary_print(FILE *f, struct data_interface_test_summary *s)
  47. {
  48. if (!f)
  49. f = stderr;
  50. FPRINTF(f, "%s : %s\n", current_config->name, enum_to_string(s->success));
  51. FPRINTF(f, "Asynchronous :\n");
  52. FPRINTF(f, "\tCPU -> CUDA : %s\n", enum_to_string(s->cpu_to_cuda_async));
  53. FPRINTF(f, "\tCUDA -> CUDA : %s\n", enum_to_string(s->cuda_to_cuda_async));
  54. FPRINTF(f, "\tCUDA -> CPU : %s\n", enum_to_string(s->cuda_to_cpu_async));
  55. FPRINTF(f, "\n");
  56. FPRINTF(f, "\tCPU -> OpenCL : %s\n", enum_to_string(s->cpu_to_opencl_async));
  57. FPRINTF(f, "\tOpenCL -> CPU : %s\n", enum_to_string(s->opencl_to_cpu_async));
  58. FPRINTF(f, "\n");
  59. FPRINTF(f, "\tCPU -> MIC : %s\n", enum_to_string(s->cpu_to_mic_async));
  60. FPRINTF(f, "\tMIC -> CPU : %s\n", enum_to_string(s->mic_to_cpu_async));
  61. FPRINTF(f, "\n");
  62. FPRINTF(f, "Synchronous :\n");
  63. FPRINTF(f, "\tCPU -> CUDA : %s\n", enum_to_string(s->cpu_to_cuda));
  64. FPRINTF(f, "\tCUDA -> CUDA : %s\n", enum_to_string(s->cuda_to_cuda));
  65. FPRINTF(f, "\tCUDA -> CPU : %s\n", enum_to_string(s->cuda_to_cpu));
  66. FPRINTF(f, "\n");
  67. FPRINTF(f, "\tCPU -> OpenCL : %s\n", enum_to_string(s->cpu_to_opencl));
  68. FPRINTF(f, "\tOpenCL -> CPU : %s\n", enum_to_string(s->opencl_to_cpu));
  69. FPRINTF(f, "\n");
  70. FPRINTF(f, "\tCPU -> MIC : %s\n", enum_to_string(s->cpu_to_mic));
  71. FPRINTF(f, "\tMIC -> CPU : %s\n", enum_to_string(s->mic_to_cpu));
  72. FPRINTF(f, "\n");
  73. FPRINTF(f, "CPU -> CPU : %s\n", enum_to_string(s->cpu_to_cpu));
  74. FPRINTF(f, "to_pointer() : %s\n", enum_to_string(s->to_pointer));
  75. FPRINTF(f, "pointer_is_inside() : %s\n", enum_to_string(s->pointer_is_inside));
  76. FPRINTF(f, "compare() : %s\n", enum_to_string(s->compare));
  77. FPRINTF(f, "pack_unpack() : %s\n", enum_to_string(s->pack));
  78. }
  79. int data_interface_test_summary_success(struct data_interface_test_summary *s)
  80. {
  81. return s->success;
  82. }
  83. static void set_field(struct data_interface_test_summary *s, int *field, int ret)
  84. {
  85. *field = ret;
  86. if (ret == FAILURE) s->success = ret;
  87. }
  88. static void summary_init(struct data_interface_test_summary *s)
  89. {
  90. s->cpu_to_cpu = UNTESTED;
  91. s->compare = UNTESTED;
  92. s->cpu_to_cuda = UNTESTED;
  93. s->cuda_to_cuda = UNTESTED;
  94. s->cuda_to_cpu = UNTESTED;
  95. s->cpu_to_cuda_async = UNTESTED;
  96. s->cuda_to_cpu_async = UNTESTED;
  97. s->cuda_to_cuda_async = UNTESTED;
  98. s->cpu_to_opencl = UNTESTED;
  99. s->opencl_to_cpu = UNTESTED;
  100. s->cpu_to_opencl_async = UNTESTED;
  101. s->opencl_to_cpu_async = UNTESTED;
  102. s->cpu_to_mic = UNTESTED;
  103. s->mic_to_cpu = UNTESTED;
  104. s->cpu_to_mic_async = UNTESTED;
  105. s->mic_to_cpu_async = UNTESTED;
  106. s->to_pointer = UNTESTED;
  107. s->pointer_is_inside = UNTESTED;
  108. s->pack = UNTESTED;
  109. s->success = SUCCESS;
  110. };
  111. /*
  112. * This variable has to be either -1 or 1.
  113. * The kernels should check that the ith value stored in the data interface is
  114. * equal to i, if factor == 1, or -i, if factor == -1.
  115. */
  116. static int factor = -1;
  117. /*
  118. * Creates a complete task, only knowing on what device it should be executed.
  119. * Note that the global variable <current_config> is heavily used here.
  120. * Arguments :
  121. * - taskp : a pointer to a valid task
  122. * - type : STARPU_{CPU,CUDA,OPENCL}_WORKER.
  123. * - id: when positive, should be the worker id
  124. * Return values :
  125. * -ENODEV
  126. * 0 : success.
  127. */
  128. static int create_task(struct starpu_task **taskp, enum starpu_worker_archtype type, int id)
  129. {
  130. static int cpu_workers[STARPU_MAXCPUS];
  131. static int cuda_workers[STARPU_MAXCUDADEVS];
  132. static int opencl_workers[STARPU_MAXOPENCLDEVS];
  133. static int mic_workers[STARPU_MAXMICDEVS];
  134. static int n_cpus = -1;
  135. static int n_cudas = -1;
  136. static int n_opencls = -1;
  137. static int n_mics = -1;
  138. if (n_cpus == -1) /* First time here */
  139. {
  140. /* We do not check the return values of the calls to
  141. * starpu_worker_get_ids_by_type now, because it is simpler to
  142. * detect a problem in the switch that comes right after this
  143. * block of code. */
  144. n_cpus = starpu_worker_get_ids_by_type(STARPU_CPU_WORKER, cpu_workers, STARPU_MAXCPUS);
  145. n_cudas = starpu_worker_get_ids_by_type(STARPU_CUDA_WORKER, cuda_workers, STARPU_MAXCUDADEVS);
  146. n_opencls = starpu_worker_get_ids_by_type(STARPU_OPENCL_WORKER, opencl_workers, STARPU_MAXOPENCLDEVS);
  147. n_mics = starpu_worker_get_ids_by_type(STARPU_MIC_WORKER, mic_workers, STARPU_MAXMICDEVS);
  148. }
  149. int *workers;
  150. static struct starpu_codelet cl;
  151. starpu_codelet_init(&cl);
  152. cl.nbuffers = 1;
  153. cl.modes[0] = STARPU_RW;
  154. if (type == STARPU_CPU_WORKER)
  155. {
  156. if (n_cpus == 0) return -ENODEV;
  157. if (id != -1 && id >= n_cpus)
  158. {
  159. FPRINTF(stderr, "Not enough CPU workers\n");
  160. return -ENODEV;
  161. }
  162. workers = cpu_workers;
  163. cl.cpu_funcs[0] = current_config->cpu_func;
  164. }
  165. else if (type == STARPU_CUDA_WORKER)
  166. {
  167. if (n_cudas == 0) return -ENODEV;
  168. if (id != -1 && id >= n_cudas)
  169. {
  170. FPRINTF(stderr, "Not enough CUDA workers\n");
  171. return -ENODEV;
  172. }
  173. workers = cuda_workers;
  174. cl.cuda_funcs[0] = current_config->cuda_func;
  175. }
  176. else if (type == STARPU_OPENCL_WORKER)
  177. {
  178. if (n_opencls == 0) return -ENODEV;
  179. if (id != -1 && id >= n_opencls)
  180. {
  181. FPRINTF(stderr, "Not enough OpenCL workers\n");
  182. return -ENODEV;
  183. }
  184. workers = opencl_workers;
  185. cl.opencl_funcs[0] = current_config->opencl_func;
  186. }
  187. else if (type == STARPU_MIC_WORKER)
  188. {
  189. if (n_mics == 0) return -ENODEV;
  190. if (id != -1 && id >= n_mics)
  191. {
  192. FPRINTF(stderr, "Not enough MIC workers\n");
  193. return -ENODEV;
  194. }
  195. workers = mic_workers;
  196. cl.cpu_funcs_name[0] = current_config->cpu_func_name;
  197. }
  198. else
  199. {
  200. return -ENODEV;
  201. }
  202. factor = -factor;
  203. struct starpu_task *task;
  204. task = starpu_task_build(&cl,
  205. STARPU_RW, *current_config->handle,
  206. STARPU_TASK_SYNCHRONOUS, 1,
  207. 0);
  208. task->cl_arg = &factor;
  209. task->cl_arg_size = sizeof(factor);
  210. if (id != -1)
  211. {
  212. task->execute_on_a_specific_worker = 1;
  213. task->workerid = workers[id];
  214. }
  215. *taskp = task;
  216. return 0;
  217. }
  218. /*
  219. * <device1>_to_<device2> functions.
  220. * They all create and submit a task that has to be executed on <device2>,
  221. * forcing a copy between <device1> and <device2>.
  222. */
  223. static enum exit_code ram_to_cuda(void)
  224. {
  225. int err;
  226. struct starpu_task *task;
  227. err = create_task(&task, STARPU_CUDA_WORKER, 0);
  228. if (err != 0)
  229. return NO_DEVICE;
  230. err = starpu_task_submit(task);
  231. if (err != 0)
  232. return TASK_SUBMISSION_FAILURE;
  233. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  234. return current_config->copy_failed;
  235. }
  236. static enum exit_code cuda_to_cuda(void)
  237. {
  238. int err;
  239. struct starpu_task *task;
  240. err = create_task(&task, STARPU_CUDA_WORKER, 1);
  241. if (err != 0)
  242. return NO_DEVICE;
  243. err = starpu_task_submit(task);
  244. if (err != 0)
  245. return TASK_SUBMISSION_FAILURE;
  246. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  247. return current_config->copy_failed;
  248. }
  249. static enum exit_code cuda_to_ram(void)
  250. {
  251. int err;
  252. struct starpu_task *task;
  253. err = create_task(&task, STARPU_CPU_WORKER, -1);
  254. if (err != 0)
  255. return NO_DEVICE;
  256. err = starpu_task_submit(task);
  257. if (err != 0)
  258. return TASK_SUBMISSION_FAILURE;
  259. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  260. return current_config->copy_failed;
  261. }
  262. static enum exit_code ram_to_opencl(void)
  263. {
  264. int err;
  265. struct starpu_task *task;
  266. err = create_task(&task, STARPU_OPENCL_WORKER, -1);
  267. if (err != 0)
  268. return NO_DEVICE;
  269. err = starpu_task_submit(task);
  270. if (err != 0)
  271. return TASK_SUBMISSION_FAILURE;
  272. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  273. return current_config->copy_failed;
  274. }
  275. static enum exit_code opencl_to_ram(void)
  276. {
  277. int err;
  278. struct starpu_task *task;
  279. err = create_task(&task, STARPU_CPU_WORKER, -1);
  280. if (err != 0)
  281. return NO_DEVICE;
  282. err = starpu_task_submit(task);
  283. if (err != 0)
  284. return TASK_SUBMISSION_FAILURE;
  285. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  286. return current_config->copy_failed;
  287. }
  288. static enum exit_code ram_to_mic()
  289. {
  290. int err;
  291. struct starpu_task *task;
  292. err = create_task(&task, STARPU_MIC_WORKER, -1);
  293. if (err != 0)
  294. return NO_DEVICE;
  295. err = starpu_task_submit(task);
  296. if (err != 0)
  297. return TASK_SUBMISSION_FAILURE;
  298. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  299. return current_config->copy_failed;
  300. }
  301. static enum exit_code mic_to_ram()
  302. {
  303. int err;
  304. struct starpu_task *task;
  305. err = create_task(&task, STARPU_CPU_WORKER, -1);
  306. if (err != 0)
  307. return NO_DEVICE;
  308. err = starpu_task_submit(task);
  309. if (err != 0)
  310. return TASK_SUBMISSION_FAILURE;
  311. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  312. return current_config->copy_failed;
  313. }
  314. /* End of the <device1>_to_<device2> functions. */
  315. static void run_cuda(int async, struct data_interface_test_summary *s)
  316. {
  317. /* RAM -> CUDA (-> CUDA) -> RAM */
  318. int err;
  319. err = ram_to_cuda();
  320. set_field(s, async==1?&s->cpu_to_cuda_async:&s->cpu_to_cuda, err);
  321. /* If this failed, there is no point in continuing. */
  322. if (err != SUCCESS)
  323. return;
  324. if (starpu_cuda_worker_get_count() >= 2)
  325. {
  326. err = cuda_to_cuda();
  327. }
  328. else
  329. {
  330. err = UNTESTED;
  331. }
  332. set_field(s, async==1?&s->cuda_to_cuda_async:&s->cuda_to_cuda, err);
  333. /* Even if cuda_to_cuda() failed, a valid copy is left on the first
  334. * cuda device, which means we can safely test cuda_to_ram() */
  335. err = cuda_to_ram();
  336. set_field(s, async==1?&s->cuda_to_cpu_async:&s->cuda_to_cpu, err);
  337. }
  338. static void run_opencl(int async, struct data_interface_test_summary *s)
  339. {
  340. /* RAM -> OpenCL -> RAM */
  341. int err;
  342. err = ram_to_opencl();
  343. set_field(s, async==1?&s->cpu_to_opencl_async:&s->cpu_to_opencl, err);
  344. if (err != SUCCESS)
  345. return;
  346. err = opencl_to_ram();
  347. set_field(s, async==1?&s->opencl_to_cpu_async:&s->opencl_to_cpu, err);
  348. }
  349. static void run_mic(int async, struct data_interface_test_summary *s)
  350. {
  351. (void)async;
  352. int err;
  353. err = ram_to_mic();
  354. set_field(s, &s->cpu_to_mic_async, err);
  355. if (err != SUCCESS)
  356. return;
  357. err = mic_to_ram();
  358. set_field(s, &s->mic_to_cpu_async, err);
  359. }
  360. static void ram_to_ram(struct data_interface_test_summary *s)
  361. {
  362. int err;
  363. struct starpu_task *task;
  364. starpu_data_handle_t src, dst;
  365. void *src_interface, *dst_interface;
  366. src = *current_config->handle;
  367. dst = *current_config->dummy_handle;
  368. /* We do not care about the nodes */
  369. src_interface = starpu_data_get_interface_on_node(src, STARPU_MAIN_RAM);
  370. dst_interface = starpu_data_get_interface_on_node(dst, STARPU_MAIN_RAM);
  371. if (src->ops->copy_methods->ram_to_ram)
  372. src->ops->copy_methods->ram_to_ram(src_interface, STARPU_MAIN_RAM, dst_interface, STARPU_MAIN_RAM);
  373. else
  374. src->ops->copy_methods->any_to_any(src_interface, STARPU_MAIN_RAM, dst_interface, STARPU_MAIN_RAM, NULL);
  375. err = create_task(&task, STARPU_CPU_WORKER, -1);
  376. if (err != 0)
  377. goto out;
  378. task->handles[0] = dst;
  379. err = starpu_task_submit(task);
  380. if (err != 0)
  381. {
  382. err = TASK_SUBMISSION_FAILURE;
  383. goto out;
  384. }
  385. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  386. err = current_config->copy_failed;
  387. out:
  388. set_field(s, &s->cpu_to_cpu, err);
  389. }
  390. static void run_async(struct data_interface_test_summary *s)
  391. {
  392. int async = starpu_asynchronous_copy_disabled();
  393. if (async == 1)
  394. {
  395. FPRINTF(stderr, "Asynchronous copies have been disabled\n");
  396. return;
  397. }
  398. run_cuda(1, s);
  399. run_opencl(1, s);
  400. run_mic(1, s);
  401. }
  402. static void run_sync(struct data_interface_test_summary *s)
  403. {
  404. starpu_data_handle_t handle = *current_config->handle;
  405. struct starpu_data_copy_methods new_copy_methods;
  406. struct starpu_data_copy_methods *old_copy_methods;
  407. old_copy_methods = (struct starpu_data_copy_methods *) handle->ops->copy_methods;
  408. memcpy(&new_copy_methods, old_copy_methods, sizeof(struct starpu_data_copy_methods));
  409. new_copy_methods.ram_to_cuda_async = NULL;
  410. new_copy_methods.cuda_to_cuda_async = NULL;
  411. new_copy_methods.cuda_to_ram_async = NULL;
  412. new_copy_methods.ram_to_opencl_async = NULL;
  413. new_copy_methods.opencl_to_ram_async = NULL;
  414. new_copy_methods.ram_to_mic_async = NULL;
  415. new_copy_methods.mic_to_ram_async = NULL;
  416. handle->ops->copy_methods = &new_copy_methods;
  417. run_cuda(0, s);
  418. run_opencl(0, s);
  419. run_mic(0, s);
  420. handle->ops->copy_methods = old_copy_methods;
  421. }
  422. static void compare(struct data_interface_test_summary *s)
  423. {
  424. int err;
  425. void *interface_a, *interface_b;
  426. starpu_data_handle_t handle, dummy_handle;
  427. handle = *current_config->handle;
  428. dummy_handle = *current_config->dummy_handle;
  429. interface_a = starpu_data_get_interface_on_node(handle, STARPU_MAIN_RAM);
  430. interface_b = starpu_data_get_interface_on_node(dummy_handle, STARPU_MAIN_RAM);
  431. err = handle->ops->compare(interface_a, interface_b);
  432. s->compare = (err == 0) ? FAILURE : SUCCESS;
  433. set_field(s, &s->compare, s->compare);
  434. }
  435. static void to_pointer(struct data_interface_test_summary *s)
  436. {
  437. starpu_data_handle_t handle;
  438. s->to_pointer = UNTESTED;
  439. handle = *current_config->handle;
  440. if (handle->ops->to_pointer)
  441. {
  442. unsigned int node;
  443. unsigned int tests = 0;
  444. for (node = 0; node < STARPU_MAXNODES; node++)
  445. {
  446. if (starpu_node_get_kind(node) != STARPU_CPU_RAM)
  447. continue;
  448. if (!starpu_data_test_if_allocated_on_node(handle, node))
  449. continue;
  450. void *data_interface = starpu_data_get_interface_on_node(handle, node);
  451. void *ptr = handle->ops->to_pointer(data_interface, node);
  452. if (starpu_data_lookup(ptr) != handle)
  453. {
  454. s->to_pointer = FAILURE;
  455. break;
  456. }
  457. tests++;
  458. }
  459. if (tests > 0)
  460. s->to_pointer = SUCCESS;
  461. }
  462. set_field(s, &s->to_pointer, s->to_pointer);
  463. }
  464. static void pointer_is_inside(struct data_interface_test_summary *s)
  465. {
  466. starpu_data_handle_t handle;
  467. s->pointer_is_inside = UNTESTED;
  468. handle = *current_config->handle;
  469. if (handle->ops->pointer_is_inside && handle->ops->to_pointer)
  470. {
  471. unsigned int node;
  472. unsigned int tests = 0;
  473. for (node = 0; node < STARPU_MAXNODES; node++)
  474. {
  475. if (starpu_node_get_kind(node) != STARPU_CPU_RAM)
  476. continue;
  477. if (!starpu_data_test_if_allocated_on_node(handle, node))
  478. continue;
  479. void *data_interface = starpu_data_get_interface_on_node(handle, node);
  480. void *ptr = handle->ops->to_pointer(data_interface, node);
  481. if (starpu_data_lookup(ptr) != handle)
  482. {
  483. s->pointer_is_inside = FAILURE;
  484. break;
  485. }
  486. if (!starpu_data_pointer_is_inside(handle, node, ptr))
  487. {
  488. s->pointer_is_inside = FAILURE;
  489. break;
  490. }
  491. tests++;
  492. }
  493. if (tests > 0)
  494. s->pointer_is_inside = SUCCESS;
  495. }
  496. set_field(s, &s->pointer_is_inside, s->pointer_is_inside);
  497. }
  498. static void pack_unpack(struct data_interface_test_summary *s)
  499. {
  500. starpu_data_handle_t handle;
  501. starpu_data_handle_t dummy_handle;
  502. int err = UNTESTED;
  503. handle = *current_config->handle;
  504. dummy_handle = *current_config->dummy_handle;
  505. if (handle->ops->pack_data && handle->ops->unpack_data)
  506. {
  507. void *ptr = NULL;
  508. starpu_ssize_t size = 0;
  509. starpu_data_pack(handle, &ptr, &size);
  510. if (size != 0)
  511. {
  512. struct starpu_task *task;
  513. void *mem = (void *)starpu_malloc_on_node_flags(STARPU_MAIN_RAM, size, 0);
  514. starpu_data_acquire(dummy_handle, STARPU_W);
  515. starpu_data_unpack(dummy_handle, mem, size);
  516. starpu_data_unpack(dummy_handle, ptr, size);
  517. starpu_data_release(dummy_handle);
  518. factor = -factor;
  519. err = create_task(&task, STARPU_CPU_WORKER, -1);
  520. if (err != SUCCESS) goto out;
  521. task->handles[0] = dummy_handle;
  522. err = starpu_task_submit(task);
  523. if (err != 0)
  524. {
  525. err = TASK_SUBMISSION_FAILURE;
  526. goto out;
  527. }
  528. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  529. err = current_config->copy_failed;
  530. }
  531. }
  532. out:
  533. set_field(s, &s->pack, err);
  534. }
  535. static int load_conf(struct test_config *config)
  536. {
  537. if (!config ||
  538. #ifdef STARPU_USE_CPU
  539. !config->cpu_func ||
  540. !config->dummy_handle ||
  541. #endif
  542. #ifdef STARPU_USE_CUDA
  543. !config->cuda_func ||
  544. #endif
  545. #ifdef STARPU_USE_OPENCL
  546. !config->opencl_func ||
  547. #endif
  548. #ifdef STARPU_USE_MIC
  549. !config->cpu_func_name ||
  550. #endif
  551. !config->handle)
  552. {
  553. return 1;
  554. }
  555. current_config = config;
  556. return 0;
  557. }
  558. void run_tests(struct test_config *conf, struct data_interface_test_summary *s)
  559. {
  560. summary_init(s);
  561. if (load_conf(conf) == 1)
  562. {
  563. FPRINTF(stderr, "Failed to load conf.\n");
  564. }
  565. run_async(s);
  566. run_sync(s);
  567. ram_to_ram(s);
  568. compare(s);
  569. to_pointer(s);
  570. pointer_is_inside(s);
  571. pack_unpack(s);
  572. }