modular_random_prefetching.c 3.7 KB

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