test_interfaces.c 17 KB

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