modular_random.c 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 <limits.h>
  20. /* Random scheduler with a fifo queue for its scheduling window */
  21. static void initialize_random_fifo_center_policy(unsigned sched_ctx_id)
  22. {
  23. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_random_create, NULL,
  24. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  25. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  26. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  27. }
  28. static void deinitialize_random_fifo_center_policy(unsigned sched_ctx_id)
  29. {
  30. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  31. starpu_sched_tree_destroy(tree);
  32. }
  33. struct starpu_sched_policy _starpu_sched_modular_random_policy =
  34. {
  35. .init_sched = initialize_random_fifo_center_policy,
  36. .deinit_sched = deinitialize_random_fifo_center_policy,
  37. .add_workers = starpu_sched_tree_add_workers,
  38. .remove_workers = starpu_sched_tree_remove_workers,
  39. .push_task = starpu_sched_tree_push_task,
  40. .pop_task = starpu_sched_tree_pop_task,
  41. .pre_exec_hook = NULL,
  42. .post_exec_hook = NULL,
  43. .pop_every_task = NULL,
  44. .policy_name = "modular-random",
  45. .policy_description = "random modular policy",
  46. .worker_type = STARPU_WORKER_LIST,
  47. };
  48. /* Random scheduler with a priority queue for its scheduling window */
  49. static void initialize_random_prio_center_policy(unsigned sched_ctx_id)
  50. {
  51. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_random_create, NULL,
  52. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  53. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  54. STARPU_SCHED_SIMPLE_FIFO_ABOVE_PRIO |
  55. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  56. }
  57. static void deinitialize_random_prio_center_policy(unsigned sched_ctx_id)
  58. {
  59. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  60. starpu_sched_tree_destroy(tree);
  61. }
  62. struct starpu_sched_policy _starpu_sched_modular_random_prio_policy =
  63. {
  64. .init_sched = initialize_random_prio_center_policy,
  65. .deinit_sched = deinitialize_random_prio_center_policy,
  66. .add_workers = starpu_sched_tree_add_workers,
  67. .remove_workers = starpu_sched_tree_remove_workers,
  68. .push_task = starpu_sched_tree_push_task,
  69. .pop_task = starpu_sched_tree_pop_task,
  70. .pre_exec_hook = NULL,
  71. .post_exec_hook = NULL,
  72. .pop_every_task = NULL,
  73. .policy_name = "modular-random-prio",
  74. .policy_description = "random-prio modular policy",
  75. .worker_type = STARPU_WORKER_LIST,
  76. };