test_interfaces.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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 *workers;
  153. static struct starpu_codelet cl;
  154. starpu_codelet_init(&cl);
  155. cl.nbuffers = 1;
  156. cl.modes[0] = STARPU_RW;
  157. if (type == STARPU_CPU_WORKER)
  158. {
  159. if (n_cpus == 0) return -ENODEV;
  160. if (id != -1 && id >= n_cpus)
  161. {
  162. FPRINTF(stderr, "Not enough CPU workers\n");
  163. return -ENODEV;
  164. }
  165. workers = cpu_workers;
  166. cl.cpu_funcs[0] = current_config->cpu_func;
  167. }
  168. else if (type == STARPU_CUDA_WORKER)
  169. {
  170. if (n_cudas == 0) return -ENODEV;
  171. if (id != -1 && id >= n_cudas)
  172. {
  173. FPRINTF(stderr, "Not enough CUDA workers\n");
  174. return -ENODEV;
  175. }
  176. workers = cuda_workers;
  177. cl.cuda_funcs[0] = current_config->cuda_func;
  178. }
  179. else if (type == STARPU_OPENCL_WORKER)
  180. {
  181. if (n_opencls == 0) return -ENODEV;
  182. if (id != -1 && id >= n_opencls)
  183. {
  184. FPRINTF(stderr, "Not enough OpenCL workers\n");
  185. return -ENODEV;
  186. }
  187. workers = opencl_workers;
  188. cl.opencl_funcs[0] = current_config->opencl_func;
  189. }
  190. else if (type == STARPU_MIC_WORKER)
  191. {
  192. if (n_mics == 0) return -ENODEV;
  193. if (id != -1 && id >= n_mics)
  194. {
  195. FPRINTF(stderr, "Not enough MIC workers\n");
  196. return -ENODEV;
  197. }
  198. workers = mic_workers;
  199. cl.cpu_funcs_name[0] = current_config->cpu_func_name;
  200. }
  201. else
  202. {
  203. return -ENODEV;
  204. }
  205. factor = -factor;
  206. struct starpu_task *task;
  207. task = starpu_task_build(&cl,
  208. STARPU_RW, *current_config->handle,
  209. STARPU_TASK_SYNCHRONOUS, 1,
  210. 0);
  211. task->cl_arg = &factor;
  212. task->cl_arg_size = sizeof(factor);
  213. if (id != -1)
  214. {
  215. task->execute_on_a_specific_worker = 1;
  216. task->workerid = workers[id];
  217. }
  218. *taskp = task;
  219. return 0;
  220. }
  221. /*
  222. * <device1>_to_<device2> functions.
  223. * They all create and submit a task that has to be executed on <device2>,
  224. * forcing a copy between <device1> and <device2>.
  225. */
  226. static enum exit_code ram_to_cuda(void)
  227. {
  228. int err;
  229. struct starpu_task *task;
  230. err = create_task(&task, STARPU_CUDA_WORKER, 0);
  231. if (err != 0)
  232. return NO_DEVICE;
  233. err = starpu_task_submit(task);
  234. if (err != 0)
  235. return TASK_SUBMISSION_FAILURE;
  236. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  237. return current_config->copy_failed;
  238. }
  239. static enum exit_code cuda_to_cuda(void)
  240. {
  241. int err;
  242. struct starpu_task *task;
  243. err = create_task(&task, STARPU_CUDA_WORKER, 1);
  244. if (err != 0)
  245. return NO_DEVICE;
  246. err = starpu_task_submit(task);
  247. if (err != 0)
  248. return TASK_SUBMISSION_FAILURE;
  249. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  250. return current_config->copy_failed;
  251. }
  252. static enum exit_code cuda_to_ram(void)
  253. {
  254. int err;
  255. struct starpu_task *task;
  256. err = create_task(&task, STARPU_CPU_WORKER, -1);
  257. if (err != 0)
  258. return NO_DEVICE;
  259. err = starpu_task_submit(task);
  260. if (err != 0)
  261. return TASK_SUBMISSION_FAILURE;
  262. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  263. return current_config->copy_failed;
  264. }
  265. static enum exit_code ram_to_opencl(void)
  266. {
  267. int err;
  268. struct starpu_task *task;
  269. err = create_task(&task, STARPU_OPENCL_WORKER, -1);
  270. if (err != 0)
  271. return NO_DEVICE;
  272. err = starpu_task_submit(task);
  273. if (err != 0)
  274. return TASK_SUBMISSION_FAILURE;
  275. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  276. return current_config->copy_failed;
  277. }
  278. static enum exit_code opencl_to_ram(void)
  279. {
  280. int err;
  281. struct starpu_task *task;
  282. err = create_task(&task, STARPU_CPU_WORKER, -1);
  283. if (err != 0)
  284. return NO_DEVICE;
  285. err = starpu_task_submit(task);
  286. if (err != 0)
  287. return TASK_SUBMISSION_FAILURE;
  288. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  289. return current_config->copy_failed;
  290. }
  291. static enum exit_code ram_to_mic()
  292. {
  293. int err;
  294. struct starpu_task *task;
  295. err = create_task(&task, STARPU_MIC_WORKER, -1);
  296. if (err != 0)
  297. return NO_DEVICE;
  298. err = starpu_task_submit(task);
  299. if (err != 0)
  300. return TASK_SUBMISSION_FAILURE;
  301. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  302. return current_config->copy_failed;
  303. }
  304. static enum exit_code mic_to_ram()
  305. {
  306. int err;
  307. struct starpu_task *task;
  308. err = create_task(&task, STARPU_CPU_WORKER, -1);
  309. if (err != 0)
  310. return NO_DEVICE;
  311. err = starpu_task_submit(task);
  312. if (err != 0)
  313. return TASK_SUBMISSION_FAILURE;
  314. FPRINTF(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
  315. return current_config->copy_failed;
  316. }
  317. /* End of the <device1>_to_<device2> functions. */
  318. static void run_cuda(int async, struct data_interface_test_summary *s)
  319. {
  320. /* RAM -> CUDA (-> CUDA) -> RAM */
  321. int err;
  322. err = ram_to_cuda();
  323. set_field(s, async==1?&s->cpu_to_cuda_async:&s->cpu_to_cuda, err);
  324. /* If this failed, there is no point in continuing. */
  325. if (err != SUCCESS)
  326. return;
  327. if (starpu_cuda_worker_get_count() >= 2)
  328. {
  329. err = cuda_to_cuda();
  330. }
  331. else
  332. {
  333. err = UNTESTED;
  334. }
  335. set_field(s, async==1?&s->cuda_to_cuda_async:&s->cuda_to_cuda, err);
  336. /* Even if cuda_to_cuda() failed, a valid copy is left on the first
  337. * cuda device, which means we can safely test cuda_to_ram() */
  338. err = cuda_to_ram();
  339. set_field(s, async==1?&s->cuda_to_cpu_async:&s->cuda_to_cpu, err);
  340. }
  341. static void run_opencl(int async, struct data_interface_test_summary *s)
  342. {
  343. /* RAM -> OpenCL -> RAM */
  344. int err;
  345. err = ram_to_opencl();
  346. set_field(s, async==1?&s->cpu_to_opencl_async:&s->cpu_to_opencl, err);
  347. if (err != SUCCESS)
  348. return;
  349. err = opencl_to_ram();
  350. set_field(s, async==1?&s->opencl_to_cpu_async:&s->opencl_to_cpu, err);
  351. }
  352. static void run_mic(int async, struct data_interface_test_summary *s)
  353. {
  354. int err;
  355. err = ram_to_mic();
  356. set_field(s, &s->cpu_to_mic_async, err);
  357. if (err != SUCCESS)
  358. return;
  359. err = mic_to_ram();
  360. set_field(s, &s->mic_to_cpu_async, err);
  361. }
  362. static void ram_to_ram(struct data_interface_test_summary *s)
  363. {
  364. int err;
  365. struct starpu_task *task;
  366. starpu_data_handle_t src, dst;
  367. void *src_interface, *dst_interface;
  368. src = *current_config->handle;
  369. dst = *current_config->dummy_handle;
  370. /* We do not care about the nodes */
  371. src_interface = starpu_data_get_interface_on_node(src, STARPU_MAIN_RAM);
  372. dst_interface = starpu_data_get_interface_on_node(dst, STARPU_MAIN_RAM);
  373. if (src->ops->copy_methods->ram_to_ram)
  374. src->ops->copy_methods->ram_to_ram(src_interface, STARPU_MAIN_RAM, dst_interface, STARPU_MAIN_RAM);
  375. else
  376. src->ops->copy_methods->any_to_any(src_interface, STARPU_MAIN_RAM, dst_interface, STARPU_MAIN_RAM, NULL);
  377. err = create_task(&task, STARPU_CPU_WORKER, -1);
  378. if (err != 0)
  379. goto out;
  380. task->handles[0] = dst;
  381. err = starpu_task_submit(task);
  382. if (err != 0)
  383. {
  384. err = TASK_SUBMISSION_FAILURE;
  385. goto out;
  386. }
  387. FPRINTF(stderr, "[%s] : %d\n", __starpu_func__, current_config->copy_failed);
  388. err = current_config->copy_failed;
  389. out:
  390. set_field(s, &s->cpu_to_cpu, err);
  391. }
  392. static void run_async(struct data_interface_test_summary *s)
  393. {
  394. int async = starpu_asynchronous_copy_disabled();
  395. if (async == 1)
  396. {
  397. FPRINTF(stderr, "Asynchronous copies have been disabled\n");
  398. return;
  399. }
  400. run_cuda(1, s);
  401. run_opencl(1, s);
  402. run_mic(1, s);
  403. }
  404. static void run_sync(struct data_interface_test_summary *s)
  405. {
  406. starpu_data_handle_t handle = *current_config->handle;
  407. struct starpu_data_copy_methods new_copy_methods;
  408. struct starpu_data_copy_methods *old_copy_methods;
  409. old_copy_methods = (struct starpu_data_copy_methods *) handle->ops->copy_methods;
  410. memcpy(&new_copy_methods, old_copy_methods, sizeof(struct starpu_data_copy_methods));
  411. new_copy_methods.ram_to_cuda_async = NULL;
  412. new_copy_methods.cuda_to_cuda_async = NULL;
  413. new_copy_methods.cuda_to_ram_async = NULL;
  414. new_copy_methods.ram_to_opencl_async = NULL;
  415. new_copy_methods.opencl_to_ram_async = NULL;
  416. new_copy_methods.ram_to_mic_async = NULL;
  417. new_copy_methods.mic_to_ram_async = NULL;
  418. handle->ops->copy_methods = &new_copy_methods;
  419. run_cuda(0, s);
  420. run_opencl(0, s);
  421. run_mic(0, s);
  422. handle->ops->copy_methods = old_copy_methods;
  423. }
  424. static void compare(struct data_interface_test_summary *s)
  425. {
  426. int err;
  427. void *interface_a, *interface_b;
  428. starpu_data_handle_t handle, dummy_handle;
  429. handle = *current_config->handle;
  430. dummy_handle = *current_config->dummy_handle;
  431. interface_a = starpu_data_get_interface_on_node(handle, STARPU_MAIN_RAM);
  432. interface_b = starpu_data_get_interface_on_node(dummy_handle, STARPU_MAIN_RAM);
  433. err = handle->ops->compare(interface_a, interface_b);
  434. s->compare = (err == 0) ? FAILURE : SUCCESS;
  435. set_field(s, &s->compare, s->compare);
  436. }
  437. static void to_pointer(struct data_interface_test_summary *s)
  438. {
  439. starpu_data_handle_t handle;
  440. s->to_pointer = UNTESTED;
  441. handle = *current_config->handle;
  442. if (handle->ops->to_pointer)
  443. {
  444. unsigned int node;
  445. unsigned int tests = 0;
  446. for (node = 0; node < STARPU_MAXNODES; node++)
  447. {
  448. if (starpu_node_get_kind(node) != STARPU_CPU_RAM)
  449. continue;
  450. if (!starpu_data_test_if_allocated_on_node(handle, node))
  451. continue;
  452. void *data_interface = starpu_data_get_interface_on_node(handle, node);
  453. void *ptr = handle->ops->to_pointer(data_interface, node);
  454. if (starpu_data_lookup(ptr) != handle)
  455. {
  456. s->to_pointer = FAILURE;
  457. break;
  458. }
  459. tests++;
  460. }
  461. if (tests > 0)
  462. s->to_pointer = SUCCESS;
  463. }
  464. set_field(s, &s->to_pointer, s->to_pointer);
  465. }
  466. static void pointer_is_inside(struct data_interface_test_summary *s)
  467. {
  468. starpu_data_handle_t handle;
  469. s->pointer_is_inside = UNTESTED;
  470. handle = *current_config->handle;
  471. if (handle->ops->pointer_is_inside && handle->ops->to_pointer)
  472. {
  473. unsigned int node;
  474. unsigned int tests = 0;
  475. for (node = 0; node < STARPU_MAXNODES; node++)
  476. {
  477. if (starpu_node_get_kind(node) != STARPU_CPU_RAM)
  478. continue;
  479. if (!starpu_data_test_if_allocated_on_node(handle, node))
  480. continue;
  481. void *data_interface = starpu_data_get_interface_on_node(handle, node);
  482. void *ptr = handle->ops->to_pointer(data_interface, node);
  483. if (starpu_data_lookup(ptr) != handle)
  484. {
  485. s->pointer_is_inside = FAILURE;
  486. break;
  487. }
  488. if (!starpu_data_pointer_is_inside(handle, node, ptr))
  489. {
  490. s->pointer_is_inside = FAILURE;
  491. break;
  492. }
  493. tests++;
  494. }
  495. if (tests > 0)
  496. s->pointer_is_inside = SUCCESS;
  497. }
  498. set_field(s, &s->pointer_is_inside, s->pointer_is_inside);
  499. }
  500. static void pack_unpack(struct data_interface_test_summary *s)
  501. {
  502. starpu_data_handle_t handle;
  503. starpu_data_handle_t dummy_handle;
  504. int err = UNTESTED;
  505. handle = *current_config->handle;
  506. dummy_handle = *current_config->dummy_handle;
  507. if (handle->ops->pack_data && handle->ops->unpack_data)
  508. {
  509. void *ptr = NULL;
  510. starpu_ssize_t size = 0;
  511. starpu_data_pack(handle, &ptr, &size);
  512. if (size != 0)
  513. {
  514. struct starpu_task *task;
  515. void *mem = (void *)starpu_malloc_on_node_flags(STARPU_MAIN_RAM, size, 0);
  516. starpu_data_unpack(dummy_handle, mem, size);
  517. starpu_data_unpack(dummy_handle, ptr, size);
  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. }