get_children_tasks.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2015-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. #include "../helper.h"
  18. /*
  19. * Check that starpu_task_get_task_succs returns the set of children tasks
  20. */
  21. void func_cpu(void *descr[], void *_args)
  22. {
  23. (void)descr;
  24. (void)_args;
  25. }
  26. struct starpu_codelet codelet_w =
  27. {
  28. .modes = { STARPU_W },
  29. .cpu_funcs = {func_cpu},
  30. .cpu_funcs_name = {"func_cpu"},
  31. .nbuffers = 1
  32. };
  33. struct starpu_codelet codelet_r =
  34. {
  35. .modes = { STARPU_R },
  36. .cpu_funcs = {func_cpu},
  37. .cpu_funcs_name = {"func_cpu"},
  38. .nbuffers = 1
  39. };
  40. int main(void)
  41. {
  42. int ret;
  43. starpu_data_handle_t h;
  44. ret = starpu_init(NULL);
  45. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  46. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  47. starpu_void_data_register(&h);
  48. starpu_tag_t tag_init = 0;
  49. starpu_tag_declare_deps_array((starpu_tag_t) 1, 1, &tag_init);
  50. struct starpu_task *task1 = starpu_task_build(&codelet_w, STARPU_W, h, STARPU_TAG, (starpu_tag_t) 1, 0);
  51. struct starpu_task *task2 = starpu_task_build(&codelet_r, STARPU_R, h, 0);
  52. struct starpu_task *task3 = starpu_task_build(&codelet_r, STARPU_R, h, 0);
  53. ret = starpu_task_submit(task1);
  54. if (ret == -ENODEV) goto enodev;
  55. ret = starpu_task_submit(task2);
  56. if (ret == -ENODEV) goto enodev;
  57. ret = starpu_task_submit(task3);
  58. if (ret == -ENODEV) goto enodev;
  59. struct starpu_task *tasks[4];
  60. ret = starpu_task_get_task_succs(task1, sizeof(tasks)/sizeof(*tasks), tasks);
  61. STARPU_ASSERT(ret == 2);
  62. STARPU_ASSERT(tasks[0] == task2 || tasks[1] == task2);
  63. STARPU_ASSERT(tasks[0] == task3 || tasks[1] == task3);
  64. starpu_tag_notify_from_apps(0);
  65. starpu_data_unregister(h);
  66. starpu_shutdown();
  67. STARPU_RETURN(ret?0:1);
  68. enodev:
  69. starpu_shutdown();
  70. fprintf(stderr, "WARNING: No one can execute this task\n");
  71. /* yes, we do not perform the computation but we did detect that no one
  72. * could perform the kernel, so this is not an error from StarPU */
  73. return STARPU_TEST_SKIPPED;
  74. }