modular_parallel_random.c 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_parallel_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_COMBINED_WORKERS |
  26. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  27. STARPU_SCHED_SIMPLE_FIFOS_BELOW |
  28. STARPU_SCHED_SIMPLE_IMPL, sched_ctx_id);
  29. }
  30. static void deinitialize_parallel_random_fifo_center_policy(unsigned sched_ctx_id)
  31. {
  32. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  33. starpu_sched_tree_destroy(tree);
  34. }
  35. struct starpu_sched_policy _starpu_sched_modular_parallel_random_policy =
  36. {
  37. .init_sched = initialize_parallel_random_fifo_center_policy,
  38. .deinit_sched = deinitialize_parallel_random_fifo_center_policy,
  39. .add_workers = starpu_sched_tree_add_workers,
  40. .remove_workers = starpu_sched_tree_remove_workers,
  41. .push_task = starpu_sched_tree_push_task,
  42. .pop_task = starpu_sched_tree_pop_task,
  43. .pre_exec_hook = NULL,
  44. .post_exec_hook = NULL,
  45. .pop_every_task = NULL,
  46. .policy_name = "modular-prandom",
  47. .policy_description = "prandom modular policy",
  48. .worker_type = STARPU_WORKER_LIST,
  49. };
  50. /* Random scheduler with a priority queue for its scheduling window */
  51. static void initialize_parallel_random_prio_center_policy(unsigned sched_ctx_id)
  52. {
  53. starpu_sched_component_initialize_simple_scheduler((starpu_sched_component_create_t) starpu_sched_component_random_create, NULL,
  54. STARPU_SCHED_SIMPLE_DECIDE_WORKERS |
  55. STARPU_SCHED_SIMPLE_COMBINED_WORKERS |
  56. STARPU_SCHED_SIMPLE_FIFO_ABOVE |
  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_parallel_random_prio_center_policy(unsigned sched_ctx_id)
  62. {
  63. struct starpu_sched_tree *tree = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  64. starpu_sched_tree_destroy(tree);
  65. }
  66. struct starpu_sched_policy _starpu_sched_modular_parallel_random_prio_policy =
  67. {
  68. .init_sched = initialize_parallel_random_prio_center_policy,
  69. .deinit_sched = deinitialize_parallel_random_prio_center_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 = NULL,
  75. .post_exec_hook = NULL,
  76. .pop_every_task = NULL,
  77. .policy_name = "modular-prandom-prio",
  78. .policy_description = "prandom-prio modular policy",
  79. .worker_type = STARPU_WORKER_LIST,
  80. .prefetches = 1,
  81. };