modular_parallel_heft.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-2015,2017 Inria
  4. * Copyright (C) 2014,2015,2017 CNRS
  5. * Copyright (C) 2013-2015,2017,2018-2019 Université de Bordeaux
  6. * Copyright (C) 2013 Simon Archipoff
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include <starpu_sched_component.h>
  20. #include <starpu_scheduler.h>
  21. #include <core/detect_combined_workers.h>
  22. #include <float.h>
  23. #include <limits.h>
  24. /* The scheduling strategy look like this :
  25. *
  26. * |
  27. * window_component
  28. * |
  29. * mct_component <--push-- perfmodel_select_component --push--> eager_component
  30. * | |
  31. * | |
  32. * >----------------------------------------------------<
  33. * | |
  34. * best_impl_component best_impl_component
  35. * | |
  36. * prio_component prio_component
  37. * | |
  38. * worker_component worker_component
  39. *
  40. * A window contain the tasks that failed to be pushed, so as when the prio_components reclaim
  41. * tasks by calling can_push to their parent (classically, just after a successful pop have
  42. * been made by its associated worker_component), this call goes up to the window_component which
  43. * pops a task from its local queue and try to schedule it by pushing it to the
  44. * decision_component.
  45. * Finally, the task will be pushed to the prio_component which is the direct
  46. * parent in the tree of the worker_component the task has been scheduled on. This
  47. * component will push the task on its local queue if no one of the two thresholds
  48. * have been reached for it, or send a push_error signal to its parent.
  49. */
  50. static void initialize_parallel_heft_center_policy(unsigned sched_ctx_id)
  51. {
  52. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_mct_create, NULL,
  53. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  54. STARPU_SCHED_SIMPLE_COMBINED_WORKERS |
  55. STARPU_SCHED_SIMPLE_PERFMODEL |
  56. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  57. STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO |
  58. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  59. STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO |
  60. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  61. }
  62. static void deinitialize_parallel_heft_center_policy(unsigned sched_ctx_id)
  63. {
  64. struct starpu_sched_tree *t = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  65. starpu_sched_tree_destroy(t);
  66. }
  67. struct starpu_sched_policy _starpu_sched_modular_parallel_heft_policy =
  68. {
  69. .init_sched = initialize_parallel_heft_center_policy,
  70. .deinit_sched = deinitialize_parallel_heft_center_policy,
  71. .add_workers = starpu_sched_tree_add_workers,
  72. .remove_workers = starpu_sched_tree_remove_workers,
  73. .push_task = starpu_sched_tree_push_task,
  74. .pop_task = starpu_sched_tree_pop_task,
  75. .pre_exec_hook = starpu_sched_component_worker_pre_exec_hook,
  76. .post_exec_hook = starpu_sched_component_worker_post_exec_hook,
  77. .pop_every_task = NULL,
  78. .policy_name = "modular-pheft",
  79. .policy_description = "parallel heft modular policy",
  80. .worker_type = STARPU_WORKER_LIST,
  81. };