sched_ctx_hypervisor.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #include <starpu.h>
  2. #include <pthread.h>
  3. /* ioctl properties*/
  4. #define HYPERVISOR_MAX_IDLE -1
  5. #define HYPERVISOR_MIN_WORKING -2
  6. #define HYPERVISOR_PRIORITY -3
  7. #define HYPERVISOR_MIN_WORKERS -4
  8. #define HYPERVISOR_MAX_WORKERS -5
  9. #define HYPERVISOR_GRANULARITY -6
  10. #define HYPERVISOR_FIXED_WORKERS -7
  11. #define HYPERVISOR_MIN_TASKS -8
  12. #define HYPERVISOR_NEW_WORKERS_MAX_IDLE -9
  13. #define HYPERVISOR_TIME_TO_APPLY -10
  14. #define HYPERVISOR_EMPTY_CTX_MAX_IDLE -11
  15. struct sched_ctx_hypervisor_reply{
  16. int procs[STARPU_NMAXWORKERS];
  17. int nprocs;
  18. };
  19. pthread_mutex_t act_hypervisor_mutex;
  20. #define MAX_IDLE_TIME 5000000000
  21. #define MIN_WORKING_TIME 500
  22. struct policy_config {
  23. /* underneath this limit we cannot resize */
  24. int min_nworkers;
  25. /* above this limit we cannot resize */
  26. int max_nworkers;
  27. /*resize granularity */
  28. int granularity;
  29. /* priority for a worker to stay in this context */
  30. /* the smaller the priority the faster it will be moved */
  31. /* to another context */
  32. int priority[STARPU_NMAXWORKERS];
  33. /* above this limit the priority of the worker is reduced */
  34. double max_idle[STARPU_NMAXWORKERS];
  35. /* underneath this limit the priority of the worker is reduced */
  36. double min_working[STARPU_NMAXWORKERS];
  37. /* workers that will not move */
  38. int fixed_workers[STARPU_NMAXWORKERS];
  39. /* max idle for the workers that will be added during the resizing process*/
  40. double new_workers_max_idle;
  41. /* above this context we allow removing all workers */
  42. double empty_ctx_max_idle[STARPU_NMAXWORKERS];
  43. };
  44. struct starpu_sched_ctx_hypervisor_criteria* sched_ctx_hypervisor_init(int type);
  45. void sched_ctx_hypervisor_shutdown(void);
  46. void sched_ctx_hypervisor_handle_ctx(unsigned sched_ctx, double total_flops);
  47. void sched_ctx_hypervisor_ignore_ctx(unsigned sched_ctx);
  48. unsigned sched_ctx_hypervisor_resize(unsigned sched_ctx, int task_tag);
  49. void sched_ctx_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receier_sched_ctx, int *workers_to_move, unsigned nworkers_to_movex);
  50. void sched_ctx_hypervisor_stop_resize(unsigned sched_ctx);
  51. void sched_ctx_hypervisor_start_resize(unsigned sched_ctx);
  52. void sched_ctx_hypervisor_set_config(unsigned sched_ctx, void *config);
  53. struct policy_config* sched_ctx_hypervisor_get_config(unsigned sched_ctx);
  54. void sched_ctx_hypervisor_ioctl(unsigned sched_ctx, ...);
  55. void sched_ctx_hypervisor_steal_workers(unsigned sched_ctx, int *workers, int nworkers, int task_tag);
  56. int* sched_ctx_hypervisor_get_sched_ctxs();
  57. int sched_ctx_hypervisor_get_nsched_ctxs();
  58. double sched_ctx_hypervisor_get_exp_end(unsigned sched_ctx);
  59. double sched_ctx_hypervisor_get_flops_left_pct(unsigned sched_ctx);
  60. double sched_ctx_hypervisor_get_idle_time(unsigned sched_ctx, int worker);
  61. double sched_ctx_hypervisor_get_bef_res_exp_end(unsigned sched_ctx);
  62. double sched_ctx_hypervisor_get_ctx_velocity(unsigned sched_ctx);
  63. double sched_ctx_hypervisor_get_cpu_velocity(unsigned sched_ctx);
  64. double sched_ctx_hypervisor_get_flops_left(unsigned sched_ctx);
  65. /* hypervisor policies */
  66. #define IDLE_POLICY 1
  67. #define APP_DRIVEN_POLICY 2
  68. #define GFLOPS_RATE_POLICY 3
  69. struct hypervisor_policy {
  70. unsigned (*resize)(unsigned sched_ctx);
  71. };