hierarchical_heft.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013 Simon Archipoff
  4. * Copyright (C) 2013,2015 Inria
  5. * Copyright (C) 2014,2016 CNRS
  6. * Copyright (C) 2014 Université de Bordeaux
  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 <core/workers.h>
  21. static struct starpu_sched_component_composed_recipe * recipe_for_worker(enum starpu_worker_archtype a STARPU_ATTRIBUTE_UNUSED)
  22. {
  23. struct starpu_sched_component_composed_recipe * r = starpu_sched_component_composed_recipe_create();
  24. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_best_implementation_create, NULL);
  25. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_fifo_create, NULL);
  26. return r;
  27. }
  28. static void initialize_heft_center_policy(unsigned sched_ctx_id)
  29. {
  30. struct starpu_sched_component_specs specs;
  31. memset(&specs,0,sizeof(specs));
  32. struct starpu_heft_data heft_data =
  33. {
  34. .alpha = 1.0,
  35. .beta = 2.0,
  36. .gamma = 0.0,
  37. .idle_power = 0.0,
  38. .no_perf_model_component_create = starpu_sched_component_random_create,
  39. .arg_no_perf_model = NULL,
  40. .calibrating_component_create = starpu_sched_component_random_create,
  41. .arg_calibrating_component = NULL,
  42. };
  43. struct starpu_sched_component_composed_recipe * r = starpu_sched_component_composed_recipe_create();
  44. starpu_sched_component_composed_recipe_add(r,(struct starpu_sched_component * (*)(void*))starpu_sched_component_heft_create,&heft_data);
  45. specs.hwloc_machine_composed_sched_component = r;
  46. r = starpu_sched_component_composed_recipe_create();
  47. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_best_implementation_create, NULL);
  48. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_fifo_create ,NULL);
  49. specs.hwloc_component_composed_sched_component = r;
  50. specs.worker_composed_sched_component = recipe_for_worker;
  51. struct starpu_sched_tree *t = starpu_sched_component_make_scheduler(sched_ctx_id, specs);
  52. starpu_sched_component_composed_recipe_destroy(specs.hwloc_machine_composed_sched_component);
  53. starpu_sched_tree_update_workers(t);
  54. starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
  55. }
  56. static void deinitialize_heft_center_policy(unsigned sched_ctx_id)
  57. {
  58. struct starpu_sched_tree *t = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  59. starpu_sched_tree_destroy(t);
  60. }
  61. struct starpu_sched_policy _starpu_sched_tree_heft_hierarchical_policy =
  62. {
  63. .init_sched = initialize_heft_center_policy,
  64. .deinit_sched = deinitialize_heft_center_policy,
  65. .add_workers = starpu_sched_tree_add_workers,
  66. .remove_workers = starpu_sched_tree_remove_workers,
  67. .push_task = starpu_sched_tree_push_task,
  68. .pop_task = starpu_sched_tree_pop_task,
  69. .pre_exec_hook = NULL,
  70. .post_exec_hook = NULL,
  71. .pop_every_task = NULL,
  72. .policy_name = "tree-heft-hierarchical",
  73. .policy_description = "hierarchical heft tree policy",
  74. .worker_type = STARPU_WORKER_LIST,
  75. };