sc_hypervisor_intern.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011, 2012 INRIA
  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 <sc_hypervisor.h>
  17. #include <common/uthash.h>
  18. #define SC_VELOCITY_MAX_GAP_DEFAULT 50
  19. #define SC_NOTHING 0
  20. #define SC_IDLE 1
  21. #define SC_SPEED 2
  22. struct size_request
  23. {
  24. int *workers;
  25. int nworkers;
  26. int *sched_ctxs;
  27. int nsched_ctxs;
  28. };
  29. /* Entry in the resize request hash table. */
  30. struct resize_request_entry
  31. {
  32. /* Key: the tag of tasks concerned by this resize request. */
  33. uint32_t task_tag;
  34. /* Value: identifier of the scheduling context needing to be resized.
  35. * The value doesn't matter since the hash table is used only to test
  36. * membership of a task tag. */
  37. unsigned sched_ctx;
  38. /* Bookkeeping. */
  39. UT_hash_handle hh;
  40. };
  41. struct configuration_entry
  42. {
  43. /* Key: the tag of tasks concerned by this configuration. */
  44. uint32_t task_tag;
  45. /* Value: configuration of the scheduling context. */
  46. struct sc_hypervisor_policy_config *configuration;
  47. /* Bookkeeping. */
  48. UT_hash_handle hh;
  49. };
  50. struct sc_hypervisor
  51. {
  52. struct sc_hypervisor_wrapper sched_ctx_w[STARPU_NMAX_SCHED_CTXS];
  53. int sched_ctxs[STARPU_NMAX_SCHED_CTXS];
  54. unsigned nsched_ctxs;
  55. unsigned resize[STARPU_NMAX_SCHED_CTXS];
  56. unsigned allow_remove[STARPU_NMAX_SCHED_CTXS];
  57. int min_tasks;
  58. struct sc_hypervisor_policy policy;
  59. struct configuration_entry *configurations[STARPU_NMAX_SCHED_CTXS];
  60. /* Set of pending resize requests for any context/tag pair. */
  61. struct resize_request_entry *resize_requests[STARPU_NMAX_SCHED_CTXS];
  62. starpu_pthread_mutex_t conf_mut[STARPU_NMAX_SCHED_CTXS];
  63. starpu_pthread_mutex_t resize_mut[STARPU_NMAX_SCHED_CTXS];
  64. struct size_request *sr;
  65. int check_min_tasks[STARPU_NMAX_SCHED_CTXS];
  66. /* time when the hypervisor started */
  67. double start_executing_time;
  68. /* max velocity diff btw ctx before triggering resizing */
  69. double max_velocity_gap;
  70. /* criteria to trigger resizing */
  71. unsigned resize_criteria;
  72. };
  73. struct sc_hypervisor_adjustment
  74. {
  75. int workerids[STARPU_NMAXWORKERS];
  76. int nworkers;
  77. };
  78. struct sc_hypervisor hypervisor;
  79. void _add_config(unsigned sched_ctx);
  80. void _remove_config(unsigned sched_ctx);
  81. double _get_max_velocity_gap();
  82. unsigned _get_resize_criteria();