sc_hypervisor_lp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2014 Inria
  4. * Copyright (C) 2012,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_LP_H
  18. #define SC_HYPERVISOR_LP_H
  19. #include <sc_hypervisor.h>
  20. #include <starpu_config.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /**
  26. @defgroup API_SC_Hypervisor_LP Scheduling Context Hypervisor - Linear Programming
  27. @{
  28. */
  29. #ifdef STARPU_HAVE_GLPK_H
  30. #include <glpk.h>
  31. #endif //STARPU_HAVE_GLPK_H
  32. struct sc_hypervisor_policy_task_pool;
  33. struct types_of_workers;
  34. /**
  35. return tmax, and compute in table res the nr of workers needed by each context st the system ends up in the smallest tma
  36. */
  37. double sc_hypervisor_lp_get_nworkers_per_ctx(int nsched_ctxs, int ntypes_of_workers, double res[nsched_ctxs][ntypes_of_workers],
  38. int total_nw[ntypes_of_workers], struct types_of_workers *tw, unsigned *in_sched_ctxs);
  39. /**
  40. return tmax of the system
  41. */
  42. double sc_hypervisor_lp_get_tmax(int nw, int *workers);
  43. /**
  44. the linear programme determins a rational number of ressources for each ctx, we round them depending on the type of ressource
  45. */
  46. void sc_hypervisor_lp_round_double_to_int(int ns, int nw, double res[ns][nw], int res_rounded[ns][nw]);
  47. /**
  48. redistribute the ressource in contexts by assigning the first x available ressources to each one
  49. */
  50. void sc_hypervisor_lp_redistribute_resources_in_ctxs(int ns, int nw, int res_rounded[ns][nw], double res[ns][nw], unsigned *sched_ctxs, struct types_of_workers *tw);
  51. /**
  52. make the first distribution of ressource in contexts by assigning the first x available ressources to each one
  53. */
  54. void sc_hypervisor_lp_distribute_resources_in_ctxs(unsigned* sched_ctxs, int ns, int nw, int res_rounded[ns][nw], double res[ns][nw], int *workers, int nworkers, struct types_of_workers *tw);
  55. /**
  56. make the first distribution of ressource in contexts by assigning the first x available ressources to each one, share not integer no of workers
  57. */
  58. void sc_hypervisor_lp_distribute_floating_no_resources_in_ctxs(unsigned* sched_ctxs, int ns, int nw, double res[ns][nw], int *workers, int nworkers, struct types_of_workers *tw);
  59. /**
  60. place resources in contexts dependig on whether they already have workers or not
  61. */
  62. void sc_hypervisor_lp_place_resources_in_ctx(int ns, int nw, double w_in_s[ns][nw], unsigned *sched_ctxs, int *workers, unsigned do_size, struct types_of_workers *tw);
  63. /**
  64. not used resources are shared between all contexts
  65. */
  66. void sc_hypervisor_lp_share_remaining_resources(int ns, unsigned *sched_ctxs, int nworkers, int *workers);
  67. /**
  68. dichotomy btw t1 & t2
  69. */
  70. double sc_hypervisor_lp_find_tmax(double t1, double t2);
  71. /**
  72. execute the lp trough dichotomy
  73. */
  74. unsigned sc_hypervisor_lp_execute_dichotomy(int ns, int nw, double w_in_s[ns][nw], unsigned solve_lp_integer, void *specific_data,
  75. double tmin, double tmax, double smallest_tmax,
  76. double (*lp_estimated_distrib_func)(int ns, int nw, double draft_w_in_s[ns][nw],
  77. unsigned is_integer, double tmax, void *specifc_data));
  78. #ifdef STARPU_HAVE_GLPK_H
  79. /**
  80. linear program that returns 1/tmax, and computes in table res the
  81. nr of workers needed by each context st the system ends up in the
  82. smallest tmax
  83. */
  84. double sc_hypervisor_lp_simulate_distrib_flops(int nsched_ctxs, int ntypes_of_workers, double speed[nsched_ctxs][ntypes_of_workers],
  85. double flops[nsched_ctxs], double res[nsched_ctxs][ntypes_of_workers], int total_nw[ntypes_of_workers],
  86. unsigned sched_ctxs[nsched_ctxs], double vmax);
  87. /**
  88. linear program that simulates a distribution of tasks that
  89. minimises the execution time of the tasks in the pool
  90. */
  91. double sc_hypervisor_lp_simulate_distrib_tasks(int ns, int nw, int nt, double w_in_s[ns][nw], double tasks[nw][nt],
  92. double times[nw][nt], unsigned is_integer, double tmax, unsigned *in_sched_ctxs,
  93. struct sc_hypervisor_policy_task_pool *tmp_task_pools);
  94. /**
  95. linear program that simulates a distribution of flops over the
  96. workers on particular sample of the execution of the application
  97. such that the entire sample would finish in a minimum amount of
  98. time
  99. */
  100. double sc_hypervisor_lp_simulate_distrib_flops_on_sample(int ns, int nw, double final_w_in_s[ns][nw], unsigned is_integer, double tmax,
  101. double **speed, double flops[ns], double **final_flops_on_w);
  102. #endif // STARPU_HAVE_GLPK_H
  103. /** @} */
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif