get_children_tasks.c 2.5 KB

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