sc_hypervisor_config.h 6.5 KB

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