modular_heft_prio.c 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2014,2015,2017 CNRS
  4. * Copyright (C) 2013-2015,2017 Inria
  5. * Copyright (C) 2013-2015,2017,2018 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 <float.h>
  22. #include <limits.h>
  23. /* The scheduling strategy look like this :
  24. *
  25. * |
  26. * window_component
  27. * |
  28. * mct_component <--push-- perfmodel_select_component --push--> eager_component
  29. * | | | |
  30. * prio prio prio |
  31. * | | | |
  32. * eager eager eager |
  33. * | | | |
  34. * >--------------------------------------------------------------<
  35. * | |
  36. * best_impl_component best_impl_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_heft_prio_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_MEMNODES |
  54. STARPU_SCHED_SIMPLE_PERFMODEL |
  55. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  56. STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO |
  57. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  58. STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO |
  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. };