get_children_tasks.c 2.4 KB

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