modular_heft_prio.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2013 Simon Archipoff
  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_sched_component.h>
  18. #include <starpu_scheduler.h>
  19. #include <float.h>
  20. #include <limits.h>
  21. /* The scheduling strategy look like this :
  22. *
  23. * |
  24. * window_component
  25. * |
  26. * mct_component <--push-- perfmodel_select_component --push--> eager_component
  27. * | | | |
  28. * prio prio prio |
  29. * | | | |
  30. * eager eager eager |
  31. * | | | |
  32. * >--------------------------------------------------------------<
  33. * | |
  34. * best_impl_component best_impl_component
  35. * | |
  36. * worker_component worker_component
  37. *
  38. * A window contain the tasks that failed to be pushed, so as when the prio_components reclaim
  39. * tasks by calling can_push to their parent (classically, just after a successful pop have
  40. * been made by its associated worker_component), this call goes up to the window_component which
  41. * pops a task from its local queue and try to schedule it by pushing it to the
  42. * decision_component.
  43. * Finally, the task will be pushed to the prio_component which is the direct
  44. * parent in the tree of the worker_component the task has been scheduled on. This
  45. * component will push the task on its local queue if no one of the two thresholds
  46. * have been reached for it, or send a push_error signal to its parent.
  47. */
  48. static void initialize_heft_prio_policy(unsigned sched_ctx_id)
  49. {
  50. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_mct_create, NULL,
  51. STARPU_SCHED_SIMPLE_DECIDE_MEMNODES |
  52. STARPU_SCHED_SIMPLE_PERFMODEL |
  53. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  54. STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO |
  55. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  56. STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO |
  57. STARPU_SCHED_SIMPLE_FIFOS_BELOW_READY |
  58. STARPU_SCHED_SIMPLE_FIFOS_BELOW_EXP |
  59. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  60. }
  61. static void deinitialize_heft_prio_policy(unsigned sched_ctx_id)
  62. {
  63. struct starpu_sched_tree *t = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  64. starpu_sched_tree_destroy(t);
  65. }
  66. struct starpu_sched_policy _starpu_sched_modular_heft_prio_policy =
  67. {
  68. .init_sched = initialize_heft_prio_policy,
  69. .deinit_sched = deinitialize_heft_prio_policy,
  70. .add_workers = starpu_sched_tree_add_workers,
  71. .remove_workers = starpu_sched_tree_remove_workers,
  72. .push_task = starpu_sched_tree_push_task,
  73. .pop_task = starpu_sched_tree_pop_task,
  74. .pre_exec_hook = starpu_sched_component_worker_pre_exec_hook,
  75. .post_exec_hook = starpu_sched_component_worker_post_exec_hook,
  76. .pop_every_task = NULL,
  77. .policy_name = "modular-heft-prio",
  78. .policy_description = "heft+prio modular policy",
  79. .worker_type = STARPU_WORKER_LIST,
  80. .prefetches = 1,
  81. };