test_interfaces.c 16 KB

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