sched_ctx_hypervisor_intern.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 <sched_ctx_hypervisor.h>
  17. #include <common/uthash.h>
  18. struct size_request
  19. {
  20. int *workers;
  21. int nworkers;
  22. int *sched_ctxs;
  23. int nsched_ctxs;
  24. };
  25. /* Entry in the resize request hash table. */
  26. struct resize_request_entry
  27. {
  28. /* Key: the tag of tasks concerned by this resize request. */
  29. uint32_t task_tag;
  30. /* Value: identifier of the scheduling context needing to be resized.
  31. * The value doesn't matter since the hash table is used only to test
  32. * membership of a task tag. */
  33. unsigned sched_ctx;
  34. /* Bookkeeping. */
  35. UT_hash_handle hh;
  36. };
  37. struct configuration_entry
  38. {
  39. /* Key: the tag of tasks concerned by this configuration. */
  40. uint32_t task_tag;
  41. /* Value: configuration of the scheduling context. */
  42. struct sched_ctx_hypervisor_policy_config *configuration;
  43. /* Bookkeeping. */
  44. UT_hash_handle hh;
  45. };
  46. struct sched_ctx_hypervisor
  47. {
  48. struct sched_ctx_hypervisor_wrapper sched_ctx_w[STARPU_NMAX_SCHED_CTXS];
  49. int sched_ctxs[STARPU_NMAX_SCHED_CTXS];
  50. unsigned nsched_ctxs;
  51. unsigned resize[STARPU_NMAX_SCHED_CTXS];
  52. unsigned allow_remove[STARPU_NMAX_SCHED_CTXS];
  53. int min_tasks;
  54. struct sched_ctx_hypervisor_policy policy;
  55. struct configuration_entry *configurations[STARPU_NMAX_SCHED_CTXS];
  56. /* Set of pending resize requests for any context/tag pair. */
  57. struct resize_request_entry *resize_requests[STARPU_NMAX_SCHED_CTXS];
  58. starpu_pthread_mutex_t conf_mut[STARPU_NMAX_SCHED_CTXS];
  59. starpu_pthread_mutex_t resize_mut[STARPU_NMAX_SCHED_CTXS];
  60. struct size_request *sr;
  61. int check_min_tasks[STARPU_NMAX_SCHED_CTXS];
  62. /* time when the hypervisor started */
  63. double start_executing_time;
  64. };
  65. struct sched_ctx_hypervisor_adjustment
  66. {
  67. int workerids[STARPU_NMAXWORKERS];
  68. int nworkers;
  69. };
  70. struct sched_ctx_hypervisor hypervisor;
  71. void _add_config(unsigned sched_ctx);
  72. void _remove_config(unsigned sched_ctx);