hierarchical_heft.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013 Simon Archipoff
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu_sched_component.h>
  17. #include <core/workers.h>
  18. static struct starpu_sched_component_composed_recipe * recipe_for_worker(enum starpu_worker_archtype a STARPU_ATTRIBUTE_UNUSED)
  19. {
  20. struct starpu_sched_component_composed_recipe * r = starpu_sched_component_composed_recipe_create();
  21. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_best_implementation_create, NULL);
  22. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_fifo_create, NULL);
  23. return r;
  24. }
  25. static void initialize_heft_center_policy(unsigned sched_ctx_id)
  26. {
  27. struct starpu_sched_component_specs specs;
  28. memset(&specs,0,sizeof(specs));
  29. struct starpu_heft_data heft_data =
  30. {
  31. .alpha = 1.0,
  32. .beta = 2.0,
  33. .gamma = 0.0,
  34. .idle_power = 0.0,
  35. .no_perf_model_component_create = starpu_sched_component_random_create,
  36. .arg_no_perf_model = NULL,
  37. .calibrating_component_create = starpu_sched_component_random_create,
  38. .arg_calibrating_component = NULL,
  39. };
  40. struct starpu_sched_component_composed_recipe * r = starpu_sched_component_composed_recipe_create();
  41. starpu_sched_component_composed_recipe_add(r,(struct starpu_sched_component * (*)(void*))starpu_sched_component_heft_create,&heft_data);
  42. specs.hwloc_machine_composed_sched_component = r;
  43. r = starpu_sched_component_composed_recipe_create();
  44. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_best_implementation_create, NULL);
  45. starpu_sched_component_composed_recipe_add(r, starpu_sched_component_fifo_create ,NULL);
  46. specs.hwloc_component_composed_sched_component = r;
  47. specs.worker_composed_sched_component = recipe_for_worker;
  48. struct starpu_sched_tree *t = starpu_sched_component_make_scheduler(sched_ctx_id, specs);
  49. starpu_sched_component_composed_recipe_destroy(specs.hwloc_machine_composed_sched_component);
  50. starpu_sched_tree_update_workers(t);
  51. starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
  52. }
  53. static void deinitialize_heft_center_policy(unsigned sched_ctx_id)
  54. {
  55. struct starpu_sched_tree *t = (struct starpu_sched_tree*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
  56. starpu_sched_tree_destroy(t);
  57. }
  58. struct starpu_sched_policy _starpu_sched_tree_heft_hierarchical_policy =
  59. {
  60. .init_sched = initialize_heft_center_policy,
  61. .deinit_sched = deinitialize_heft_center_policy,
  62. .add_workers = starpu_sched_tree_add_workers,
  63. .remove_workers = starpu_sched_tree_remove_workers,
  64. .push_task = starpu_sched_tree_push_task,
  65. .pop_task = starpu_sched_tree_pop_task,
  66. .pre_exec_hook = NULL,
  67. .post_exec_hook = NULL,
  68. .pop_every_task = NULL,
  69. .policy_name = "tree-heft-hierarchical",
  70. .policy_description = "hierarchical heft tree policy",
  71. .worker_type = STARPU_WORKER_LIST,
  72. };