get_children_tasks.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017 CNRS
  4. * Copyright (C) 2015-2016 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <starpu.h>
  18. #include "../helper.h"
  19. /*
  20. * Check that starpu_task_get_task_succs returns the set of children tasks
  21. */
  22. void func_cpu(void *descr[], void *_args)
  23. {
  24. (void)descr;
  25. (void)_args;
  26. }
  27. struct starpu_codelet codelet_w =
  28. {
  29. .modes = { STARPU_W },
  30. .cpu_funcs = {func_cpu},
  31. .cpu_funcs_name = {"func_cpu"},
  32. .nbuffers = 1
  33. };
  34. struct starpu_codelet codelet_r =
  35. {
  36. .modes = { STARPU_R },
  37. .cpu_funcs = {func_cpu},
  38. .cpu_funcs_name = {"func_cpu"},
  39. .nbuffers = 1
  40. };
  41. int main(void)
  42. {
  43. int ret;
  44. starpu_data_handle_t h;
  45. ret = starpu_init(NULL);
  46. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  48. starpu_void_data_register(&h);
  49. starpu_tag_t tag_init = 0;
  50. starpu_tag_declare_deps_array((starpu_tag_t) 1, 1, &tag_init);
  51. struct starpu_task *task1 = starpu_task_build(&codelet_w, STARPU_W, h, STARPU_TAG, (starpu_tag_t) 1, 0);
  52. struct starpu_task *task2 = starpu_task_build(&codelet_r, STARPU_R, h, 0);
  53. struct starpu_task *task3 = starpu_task_build(&codelet_r, STARPU_R, h, 0);
  54. ret = starpu_task_submit(task1);
  55. if (ret == -ENODEV) goto enodev;
  56. ret = starpu_task_submit(task2);
  57. if (ret == -ENODEV) goto enodev;
  58. ret = starpu_task_submit(task3);
  59. if (ret == -ENODEV) goto enodev;
  60. struct starpu_task *tasks[4];
  61. ret = starpu_task_get_task_succs(task1, sizeof(tasks)/sizeof(*tasks), tasks);
  62. STARPU_ASSERT(ret == 2);
  63. STARPU_ASSERT(tasks[0] == task2 || tasks[1] == task2);
  64. STARPU_ASSERT(tasks[0] == task3 || tasks[1] == task3);
  65. starpu_tag_notify_from_apps(0);
  66. starpu_data_unregister(h);
  67. starpu_shutdown();
  68. STARPU_RETURN(ret?0:1);
  69. enodev:
  70. starpu_shutdown();
  71. fprintf(stderr, "WARNING: No one can execute this task\n");
  72. /* yes, we do not perform the computation but we did detect that no one
  73. * could perform the kernel, so this is not an error from StarPU */
  74. return STARPU_TEST_SKIPPED;
  75. }