modular_parallel_random.c 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-2015,2017 Inria
  4. * Copyright (C) 2017 CNRS
  5. * Copyright (C) 2014,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 <limits.h>
  22. /* Random scheduler with a fifo queue for its scheduling window */
  23. static void initialize_parallel_random_fifo_center_policy(unsigned sched_ctx_id)
  24. {
  25. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_random_create, NULL,
  26. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  27. STARPU_SCHED_SIMPLE_COMBINED_WORKERS |
  28. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  29. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  30. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  31. }
  32. static void deinitialize_parallel_random_fifo_center_policy(unsigned sched_ctx_id)
  33. {
  34. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  35. starpu_sched_tree_destroy(tree);
  36. }
  37. struct starpu_sched_policy _starpu_sched_modular_parallel_random_policy =
  38. {
  39. .init_sched = initialize_parallel_random_fifo_center_policy,
  40. .deinit_sched = deinitialize_parallel_random_fifo_center_policy,
  41. .add_workers = starpu_sched_tree_add_workers,
  42. .remove_workers = starpu_sched_tree_remove_workers,
  43. .push_task = starpu_sched_tree_push_task,
  44. .pop_task = starpu_sched_tree_pop_task,
  45. .pre_exec_hook = NULL,
  46. .post_exec_hook = NULL,
  47. .pop_every_task = NULL,
  48. .policy_name = "modular-prandom",
  49. .policy_description = "prandom modular policy",
  50. .worker_type = STARPU_WORKER_LIST,
  51. };
  52. /* Random scheduler with a priority queue for its scheduling window */
  53. static void initialize_parallel_random_prio_center_policy(unsigned sched_ctx_id)
  54. {
  55. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_random_create, NULL,
  56. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  57. STARPU_SCHED_SIMPLE_COMBINED_WORKERS |
  58. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  59. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  60. STARPU_SCHED_SIMPLE_FIFOS_BELOW_PRIO |
  61. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  62. }
  63. static void deinitialize_parallel_random_prio_center_policy(unsigned sched_ctx_id)
  64. {
  65. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  66. starpu_sched_tree_destroy(tree);
  67. }
  68. struct starpu_sched_policy _starpu_sched_modular_parallel_random_prio_policy =
  69. {
  70. .init_sched = initialize_parallel_random_prio_center_policy,
  71. .deinit_sched = deinitialize_parallel_random_prio_center_policy,
  72. .add_workers = starpu_sched_tree_add_workers,
  73. .remove_workers = starpu_sched_tree_remove_workers,
  74. .push_task = starpu_sched_tree_push_task,
  75. .pop_task = starpu_sched_tree_pop_task,
  76. .pre_exec_hook = NULL,
  77. .post_exec_hook = NULL,
  78. .pop_every_task = NULL,
  79. .policy_name = "modular-prandom-prio",
  80. .policy_description = "prandom-prio modular policy",
  81. .worker_type = STARPU_WORKER_LIST,
  82. };