sc_hypervisor_intern.h 2.8 KB

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