sc_hypervisor_config.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), 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. #ifndef SC_HYPERVISOR_CONFIG_H
  17. #define SC_HYPERVISOR_CONFIG_H
  18. #include <sc_hypervisor.h>
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. /**
  24. @ingroup API_SC_Hypervisor
  25. @{
  26. */
  27. /**
  28. This macro is used when calling sc_hypervisor_ctl() and must be
  29. followed by 3 arguments: an array of int for the workerids to apply
  30. the condition, an int to indicate the size of the array, and a
  31. double value indicating the maximum idle time allowed for a worker
  32. before the resizing process should be triggered
  33. */
  34. #define SC_HYPERVISOR_MAX_IDLE -1
  35. #define SC_HYPERVISOR_MIN_WORKING -2
  36. /**
  37. This macro is used when calling sc_hypervisor_ctl() and must be
  38. followed by 3 arguments: an array of int for the workerids to apply
  39. the condition, an int to indicate the size of the array, and an int
  40. value indicating the priority of the workers previously mentioned.
  41. The workers with the smallest priority are moved the first.
  42. */
  43. #define SC_HYPERVISOR_PRIORITY -3
  44. /**
  45. This macro is used when calling sc_hypervisor_ctl() and must be
  46. followed by 1 argument(int) indicating the minimum number of
  47. workers a context should have, underneath this limit the context
  48. cannot execute.
  49. */
  50. #define SC_HYPERVISOR_MIN_WORKERS -4
  51. /**
  52. This macro is used when calling sc_hypervisor_ctl() and must be
  53. followed by 1 argument(int) indicating the maximum number of
  54. workers a context should have, above this limit the context would
  55. not be able to scale
  56. */
  57. #define SC_HYPERVISOR_MAX_WORKERS -5
  58. /**
  59. This macro is used when calling sc_hypervisor_ctl() and must be
  60. followed by 1 argument(int) indicating the granularity of the
  61. resizing process (the number of workers should be moved from the
  62. context once it is resized) This parameter is ignore for the Gflops
  63. rate based strategy (see \ref ResizingStrategies), the number of
  64. workers that have to be moved is calculated by the strategy.
  65. */
  66. #define SC_HYPERVISOR_GRANULARITY -6
  67. /**
  68. This macro is used when calling sc_hypervisor_ctl() and must be
  69. followed by 2 arguments: an array of int for the workerids to apply
  70. the condition and an int to indicate the size of the array. These
  71. workers are not allowed to be moved from the context.
  72. */
  73. #define SC_HYPERVISOR_FIXED_WORKERS -7
  74. /**
  75. This macro is used when calling sc_hypervisor_ctl() and must be
  76. followed by 1 argument (int) that indicated the minimum number of
  77. tasks that have to be executed before the context could be resized.
  78. This parameter is ignored for the Application Driven strategy (see
  79. \ref ResizingStrategies) where the user indicates exactly when the
  80. resize should be done.
  81. */
  82. #define SC_HYPERVISOR_MIN_TASKS -8
  83. /**
  84. This macro is used when calling sc_hypervisor_ctl() and must be
  85. followed by 1 argument, a double value indicating the maximum idle
  86. time allowed for workers that have just been moved from other
  87. contexts in the current context.
  88. */
  89. #define SC_HYPERVISOR_NEW_WORKERS_MAX_IDLE -9
  90. /**
  91. This macro is used when calling sc_hypervisor_ctl() and must be
  92. followed by 1 argument (int) indicating the tag an executed task
  93. should have such that this configuration should be taken into
  94. account.
  95. */
  96. #define SC_HYPERVISOR_TIME_TO_APPLY -10
  97. /**
  98. This macro is used when calling sc_hypervisor_ctl() and must be
  99. followed by 1 argument
  100. */
  101. #define SC_HYPERVISOR_NULL -11
  102. /**
  103. This macro is used when calling sc_hypervisor_ctl() and must be
  104. followed by 1 argument, a double, that indicates the number of
  105. flops needed to be executed before computing the speed of a worker
  106. */
  107. #define SC_HYPERVISOR_ISPEED_W_SAMPLE -12
  108. /**
  109. This macro is used when calling sc_hypervisor_ctl() and must be
  110. followed by 1 argument, a double, that indicates the number of
  111. flops needed to be executed before computing the speed of a context
  112. */
  113. #define SC_HYPERVISOR_ISPEED_CTX_SAMPLE -13
  114. #define SC_HYPERVISOR_TIME_SAMPLE -14
  115. #define MAX_IDLE_TIME 5000000000
  116. #define MIN_WORKING_TIME 500
  117. /**
  118. Methods that implement a hypervisor resizing policy.
  119. */
  120. struct sc_hypervisor_policy_config
  121. {
  122. /**
  123. Indicate the minimum number of workers needed by the context
  124. */
  125. int min_nworkers;
  126. /**
  127. Indicate the maximum number of workers needed by the context
  128. */
  129. int max_nworkers;
  130. /**
  131. Indicate the workers granularity of the context
  132. */
  133. int granularity;
  134. /**
  135. Indicate the priority of each worker to stay in the context
  136. the smaller the priority the faster it will be moved to
  137. another context
  138. */
  139. int priority[STARPU_NMAXWORKERS];
  140. /**
  141. Indicate the maximum idle time accepted before a resize is
  142. triggered
  143. above this limit the priority of the worker is reduced
  144. */
  145. double max_idle[STARPU_NMAXWORKERS];
  146. /**
  147. Indicate that underneath this limit the priority of the
  148. worker is reduced
  149. */
  150. double min_working[STARPU_NMAXWORKERS];
  151. /**
  152. Indicate which workers can be moved and which ones are
  153. fixed
  154. */
  155. int fixed_workers[STARPU_NMAXWORKERS];
  156. /**
  157. Indicate the maximum idle time accepted before a resize is
  158. triggered for the workers that just arrived in the new
  159. context
  160. */
  161. double new_workers_max_idle;
  162. /**
  163. Indicate the sample used to compute the instant speed per
  164. worker
  165. */
  166. double ispeed_w_sample[STARPU_NMAXWORKERS];
  167. /**
  168. Indicate the sample used to compute the instant speed per
  169. ctxs
  170. */
  171. double ispeed_ctx_sample;
  172. /**
  173. Indicate the sample used to compute the instant speed per
  174. ctx (in seconds)
  175. */
  176. double time_sample;
  177. };
  178. /**
  179. Specify the configuration for a context
  180. */
  181. void sc_hypervisor_set_config(unsigned sched_ctx, void *config);
  182. /**
  183. Return the configuration of a context
  184. */
  185. struct sc_hypervisor_policy_config *sc_hypervisor_get_config(unsigned sched_ctx);
  186. /**
  187. Specify different parameters for the configuration of a context.
  188. The list must be zero-terminated
  189. */
  190. void sc_hypervisor_ctl(unsigned sched_ctx, ...);
  191. /** @} */
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif