test_interfaces.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2020 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. /* XXX Why cant we dereference a handle without this one ? */
  18. #include <core/sched_policy.h>
  19. #include <assert.h>
  20. #include "test_interfaces.h"
  21. #include "../../helper.h"
  22. /*
  23. * This is definitely note thread-safe.
  24. */
  25. static struct test_config *current_config;
  26. /* TODO :
  27. - OpenCL to OpenCL support
  28. */
  29. static char *enum_to_string(int exit_code)
  30. {
  31. switch (exit_code)
  32. {
  33. case SUCCESS:
  34. return "Success";
  35. case FAILURE:
  36. return "Failure";
  37. case UNTESTED:
  38. return "Untested";
  39. case NO_DEVICE:
  40. return "No device available";
  41. case TASK_SUBMISSION_FAILURE:
  42. return "Task submission failed";
  43. default:
  44. assert(0);
  45. }
  46. }
  47. void data_interface_test_summary_print(FILE *f, struct data_interface_test_summary *s)
  48. {
  49. if (!f)
  50. f = stderr;
  51. FPRINTF(f, "%s : %s\n", current_config->name, enum_to_string(s->success));
  52. FPRINTF(f, "Asynchronous :\n");
  53. FPRINTF(f, "\tCPU -> CUDA : %s\n", enum_to_string(s->cpu_to_cuda_async));
  54. FPRINTF(f, "\tCUDA -> CUDA : %s\n", enum_to_string(s->cuda_to_cuda_async));
  55. FPRINTF(f, "\tCUDA -> CPU : %s\n", enum_to_string(s->cuda_to_cpu_async));
  56. FPRINTF(f, "\n");
  57. FPRINTF(f, "\tCPU -> OpenCL : %s\n", enum_to_string(s->cpu_to_opencl_async));
  58. FPRINTF(f, "\tOpenCL -> CPU : %s\n", enum_to_string(s->opencl_to_cpu_async));
  59. FPRINTF(f, "\n");
  60. FPRINTF(f, "\tCPU -> MIC : %s\n", enum_to_string(s->cpu_to_mic_async));
  61. FPRINTF(f, "\tMIC -> CPU : %s\n", enum_to_string(s->mic_to_cpu_async));
  62. FPRINTF(f, "\n");
  63. FPRINTF(f, "Synchronous :\n");
  64. FPRINTF(f, "\tCPU -> CUDA : %s\n", enum_to_string(s->cpu_to_cuda));
  65. FPRINTF(f, "\tCUDA -> CUDA : %s\n", enum_to_string(s->cuda_to_cuda));
  66. FPRINTF(f, "\tCUDA -> CPU : %s\n", enum_to_string(s->cuda_to_cpu));
  67. FPRINTF(f, "\n");
  68. FPRINTF(f, "\tCPU -> OpenCL : %s\n", enum_to_string(s->cpu_to_opencl));
  69. FPRINTF(f, "\tOpenCL -> CPU : %s\n", enum_to_string(s->opencl_to_cpu));
  70. FPRINTF(f, "\n");
  71. FPRINTF(f, "\tCPU -> MIC : %s\n", enum_to_string(s->cpu_to_mic));
  72. FPRINTF(f, "\tMIC -> CPU : %s\n", enum_to_string(s->mic_to_cpu));
  73. FPRINTF(f, "\n");
  74. FPRINTF(f, "CPU -> CPU : %s\n", enum_to_string(s->cpu_to_cpu));
  75. FPRINTF(f, "to_pointer() : %s\n", enum_to_string(s->to_pointer));
  76. FPRINTF(f, "pointer_is_inside() : %s\n", enum_to_string(s->pointer_is_inside));
  77. FPRINTF(f, "compare() : %s\n", enum_to_string(s->compare));
  78. FPRINTF(f, "pack_unpack() : %s\n", enum_to_string(s->pack));
  79. }
  80. int data_interface_test_summary_success(struct data_interface_test_summary *s)
  81. {
  82. return s->success;
  83. }
  84. static void set_field(struct data_interface_test_summary *s, int *field, int ret)
  85. {
  86. *field = ret;
  87. if (ret == FAILURE) s->success = ret;
  88. }
  89. static void summary_init(struct data_interface_test_summary *s)
  90. {
  91. s->cpu_to_cpu = UNTESTED;
  92. s->compare = UNTESTED;
  93. s->cpu_to_cuda = UNTESTED;
  94. s->cuda_to_cuda = UNTESTED;
  95. s->cuda_to_cpu = UNTESTED;
  96. s->cpu_to_cuda_async = UNTESTED;
  97. s->cuda_to_cpu_async = UNTESTED;
  98. s->cuda_to_cuda_async = UNTESTED;
  99. s->cpu_to_opencl = UNTESTED;
  100. s->opencl_to_cpu = UNTESTED;
  101. s->cpu_to_opencl_async = UNTESTED;
  102. s->opencl_to_cpu_async = UNTESTED;
  103. s->cpu_to_mic = UNTESTED;
  104. s->mic_to_cpu = UNTESTED;
  105. s->cpu_to_mic_async = UNTESTED;
  106. s->mic_to_cpu_async = UNTESTED;
  107. s->to_pointer = UNTESTED;
  108. s->pointer_is_inside = UNTESTED;
  109. s->pack = UNTESTED;
  110. s->success = SUCCESS;
  111. };
  112. /*
  113. * This variable has to be either -1 or 1.
  114. * The kernels should check that the ith value stored in the data interface is
  115. * equal to i, if factor == 1, or -i, if factor == -1.
  116. */
  117. static int factor = -1;
  118. /*
  119. * Creates a complete task, only knowing on what device it should be executed.
  120. * Note that the global variable <current_config> is heavily used here.
  121. * Arguments :
  122. * - taskp : a pointer to a valid task
  123. * - type : STARPU_{CPU,CUDA,OPENCL}_WORKER.
  124. * - id: when positive, should be the worker id
  125. * Return values :
  126. * -ENODEV
  127. * 0 : success.
  128. */
  129. static int create_task(struct starpu_task **taskp, enum starpu_worker_archtype type, int id)
  130. {
  131. static int cpu_workers[STARPU_MAXCPUS];
  132. static int cuda_workers[STARPU_MAXCUDADEVS];
  133. static int opencl_workers[STARPU_MAXOPENCLDEVS];
  134. static int mic_workers[STARPU_MAXMICDEVS];
  135. static int n_cpus = -1;
  136. static int n_cudas = -1;
  137. static int n_opencls = -1;
  138. static int n_mics = -1;
  139. if (n_cpus == -1) /* First time here */
  140. {
  141. /* We do not check the return values of the calls to
  142. * starpu_worker_get_ids_by_type now, because it is simpler to
  143. * detect a problem in the switch that comes right after this
  144. * block of code. */
  145. n_cpus = starpu_worker_get_ids_by_type(STARPU_CPU_WORKER, cpu_workers, STARPU_MAXCPUS);
  146. n_cudas = starpu_worker_get_ids_by_type(STARPU_CUDA_WORKER, cuda_workers, STARPU_MAXCUDADEVS);
  147. n_opencls = starpu_worker_get_ids_by_type(STARPU_OPENCL_WORKER, opencl_workers, STARPU_MAXOPENCLDEVS);
  148. n_mics = starpu_worker_get_ids_by_type(STARPU_MIC_WORKER, mic_workers, STARPU_MAXMICDEVS);
  149. }
  150. int *workers;
  151. static struct starpu_codelet cl;
  152. starpu_codelet_init(&cl);
  153. cl.nbuffers = 1;
  154. cl.modes[0] = STARPU_RW;
  155. if (type == STARPU_CPU_WORKER)
  156. {
  157. if (n_cpus == 0) return -ENODEV;
  158. if (id != -1 && id >= n_cpus)
  159. {
  160. FPRINTF(stderr, "Not enough CPU workers\n");
  161. return -ENODEV;
  162. }
  163. workers = cpu_workers;
  164. cl.cpu_funcs[0] = current_config->cpu_func;
  165. }
  166. else if (type == STARPU_CUDA_WORKER)
  167. {
  168. if (n_cudas == 0) return -ENODEV;
  169. if (id != -1 && id >= n_cudas)
  170. {
  171. FPRINTF(stderr, "Not enough CUDA workers\n");
  172. return -ENODEV;
  173. }
  174. workers = cuda_workers;
  175. cl.cuda_funcs[0] = current_config->cuda_func;
  176. }
  177. else if (type == STARPU_OPENCL_WORKER)
  178. {
  179. if (n_opencls == 0) return -ENODEV;
  180. if (id != -1 && id >= n_opencls)
  181. {
  182. FPRINTF(stderr, "Not enough OpenCL workers\n");
  183. return -ENODEV;
  184. }
  185. workers = opencl_workers;
  186. cl.opencl_funcs[0] = current_config->opencl_func;
  187. }
  188. else if (type == STARPU_MIC_WORKER)
  189. {
  190. if (n_mics == 0) return -ENODEV;
  191. if (id != -1 && id >= n_mics)
  192. {
  193. FPRINTF(stderr, "Not enough MIC workers\n");
  194. return -ENODEV;
  195. }
  196. workers = mic_workers;
  197. cl.cpu_funcs_name[0] = current_config->cpu_func_name;
  198. }
  199. else
  200. {
  201. return -ENODEV;
  202. }
  203. factor = -factor;
  204. struct starpu_task *task;
  205. task = starpu_task_build(&cl,
  206. STARPU_RW, *current_config->handle,
  207. STARPU_TASK_SYNCHRONOUS, 1,
  208. 0);
  209. task->cl_arg = &factor;
  210. task->cl_arg_size = sizeof(factor);
  211. if (id != -1)
  212. {
  213. task->execute_on_a_specific_worker = 1;
  214. task->workerid = workers[id];
  215. }
  216. *taskp = task;
  217. return 0;
  218. }
  219. /*
  220. * <device1>_to_<device2> functions.
  221. * They all create and submit a task that has to be executed on <device2>,
  222. * forcing a copy between <device1> and <device2>.
  223. */
  224. static enum exit_code ram_to_cuda(void)
  225. {
  226. int err;
  227. struct starpu_task *task;
  228. err = create_task(&task, STARPU_CUDA_WORKER, 0);
  229. if (err != 0)
  230. return NO_DEVICE;
  231. err = starpu_task_submit(task);
  232. if (err != 0)
  233. return TASK_SUBMISSION_FAILURE;
  234. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  235. return current_config->copy_failed;
  236. }
  237. static enum exit_code cuda_to_cuda(void)
  238. {
  239. int err;
  240. struct starpu_task *task;
  241. err = create_task(&task, STARPU_CUDA_WORKER, 1);
  242. if (err != 0)
  243. return NO_DEVICE;
  244. err = starpu_task_submit(task);
  245. if (err != 0)
  246. return TASK_SUBMISSION_FAILURE;
  247. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  248. return current_config->copy_failed;
  249. }
  250. static enum exit_code cuda_to_ram(void)
  251. {
  252. int err;
  253. struct starpu_task *task;
  254. err = create_task(&task, STARPU_CPU_WORKER, -1);
  255. if (err != 0)
  256. return NO_DEVICE;
  257. err = starpu_task_submit(task);
  258. if (err != 0)
  259. return TASK_SUBMISSION_FAILURE;
  260. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  261. return current_config->copy_failed;
  262. }
  263. static enum exit_code ram_to_opencl(void)
  264. {
  265. int err;
  266. struct starpu_task *task;
  267. err = create_task(&task, STARPU_OPENCL_WORKER, -1);
  268. if (err != 0)
  269. return NO_DEVICE;
  270. err = starpu_task_submit(task);
  271. if (err != 0)
  272. return TASK_SUBMISSION_FAILURE;
  273. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  274. return current_config->copy_failed;
  275. }
  276. static enum exit_code opencl_to_ram(void)
  277. {
  278. int err;
  279. struct starpu_task *task;
  280. err = create_task(&task, STARPU_CPU_WORKER, -1);
  281. if (err != 0)
  282. return NO_DEVICE;
  283. err = starpu_task_submit(task);
  284. if (err != 0)
  285. return TASK_SUBMISSION_FAILURE;
  286. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  287. return current_config->copy_failed;
  288. }
  289. static enum exit_code ram_to_mic()
  290. {
  291. int err;
  292. struct starpu_task *task;
  293. err = create_task(&task, STARPU_MIC_WORKER, -1);
  294. if (err != 0)
  295. return NO_DEVICE;
  296. err = starpu_task_submit(task);
  297. if (err != 0)
  298. return TASK_SUBMISSION_FAILURE;
  299. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  300. return current_config->copy_failed;
  301. }
  302. static enum exit_code mic_to_ram()
  303. {
  304. int err;
  305. struct starpu_task *task;
  306. err = create_task(&task, STARPU_CPU_WORKER, -1);
  307. if (err != 0)
  308. return NO_DEVICE;
  309. err = starpu_task_submit(task);
  310. if (err != 0)
  311. return TASK_SUBMISSION_FAILURE;
  312. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  313. return current_config->copy_failed;
  314. }
  315. /* End of the <device1>_to_<device2> functions. */
  316. static void run_cuda(int async, struct data_interface_test_summary *s)
  317. {
  318. /* RAM -> CUDA (-> CUDA) -> RAM */
  319. int err;
  320. err = ram_to_cuda();
  321. set_field(s, async==1?&s->cpu_to_cuda_async:&s->cpu_to_cuda, err);
  322. /* If this failed, there is no point in continuing. */
  323. if (err != SUCCESS)
  324. return;
  325. if (starpu_cuda_worker_get_count() >= 2)
  326. {
  327. err = cuda_to_cuda();
  328. }
  329. else
  330. {
  331. err = UNTESTED;
  332. }
  333. set_field(s, async==1?&s->cuda_to_cuda_async:&s->cuda_to_cuda, err);
  334. /* Even if cuda_to_cuda() failed, a valid copy is left on the first
  335. * cuda device, which means we can safely test cuda_to_ram() */
  336. err = cuda_to_ram();
  337. set_field(s, async==1?&s->cuda_to_cpu_async:&s->cuda_to_cpu, err);
  338. }
  339. static void run_opencl(int async, struct data_interface_test_summary *s)
  340. {
  341. /* RAM -> OpenCL -> RAM */
  342. int err;
  343. err = ram_to_opencl();
  344. set_field(s, async==1?&s->cpu_to_opencl_async:&s->cpu_to_opencl, err);
  345. if (err != SUCCESS)
  346. return;
  347. err = opencl_to_ram();
  348. set_field(s, async==1?&s->opencl_to_cpu_async:&s->opencl_to_cpu, err);
  349. }
  350. static void run_mic(int async, struct data_interface_test_summary *s)
  351. {
  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_unpack(dummy_handle, mem, size);
  515. starpu_data_unpack(dummy_handle, ptr, size);
  516. factor = -factor;
  517. err = create_task(&task, STARPU_CPU_WORKER, -1);
  518. if (err != SUCCESS) goto out;
  519. task->handles[0] = dummy_handle;
  520. err = starpu_task_submit(task);
  521. if (err != 0)
  522. {
  523. err = TASK_SUBMISSION_FAILURE;
  524. goto out;
  525. }
  526. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  527. err = current_config->copy_failed;
  528. }
  529. }
  530. out:
  531. set_field(s, &s->pack, err);
  532. }
  533. static int load_conf(struct test_config *config)
  534. {
  535. if (!config ||
  536. #ifdef STARPU_USE_CPU
  537. !config->cpu_func ||
  538. !config->dummy_handle ||
  539. #endif
  540. #ifdef STARPU_USE_CUDA
  541. !config->cuda_func ||
  542. #endif
  543. #ifdef STARPU_USE_OPENCL
  544. !config->opencl_func ||
  545. #endif
  546. #ifdef STARPU_USE_MIC
  547. !config->cpu_func_name ||
  548. #endif
  549. !config->handle)
  550. {
  551. return 1;
  552. }
  553. current_config = config;
  554. return 0;
  555. }
  556. void run_tests(struct test_config *conf, struct data_interface_test_summary *s)
  557. {
  558. summary_init(s);
  559. if (load_conf(conf) == 1)
  560. {
  561. FPRINTF(stderr, "Failed to load conf.\n");
  562. }
  563. run_async(s);
  564. run_sync(s);
  565. ram_to_ram(s);
  566. compare(s);
  567. to_pointer(s);
  568. pointer_is_inside(s);
  569. pack_unpack(s);
  570. }