sc_hypervisor_lp.h 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013 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_LP_H
  17. #define SC_HYPERVISOR_LP_H
  18. #include <sc_hypervisor.h>
  19. #include <starpu_config.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. /*
  25. * GNU Linear Programming Kit backend
  26. */
  27. #ifdef STARPU_HAVE_GLPK_H
  28. #include <glpk.h>
  29. #endif //STARPU_HAVE_GLPK_H
  30. struct sc_hypervisor_policy_task_pool;
  31. struct types_of_workers;
  32. /* returns tmax, and computes in table res the nr of workers needed by each context st the system ends up in the smallest tmax*/
  33. double sc_hypervisor_lp_get_nworkers_per_ctx(int nsched_ctxs, int ntypes_of_workers, double res[nsched_ctxs][ntypes_of_workers],
  34. int total_nw[ntypes_of_workers], struct types_of_workers *tw, unsigned *in_sched_ctxs);
  35. /* returns tmax of the system */
  36. double sc_hypervisor_lp_get_tmax(int nw, int *workers);
  37. /* the linear programme determins a rational number of ressources for each ctx, we round them depending on the type of ressource */
  38. void sc_hypervisor_lp_round_double_to_int(int ns, int nw, double res[ns][nw], int res_rounded[ns][nw]);
  39. /* redistribute the ressource in contexts by assigning the first x available ressources to each one */
  40. 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);
  41. /* make the first distribution of ressource in contexts by assigning the first x available ressources to each one */
  42. 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);
  43. /* make the first distribution of ressource in contexts by assigning the first x available ressources to each one, share not integer no of workers */
  44. 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);
  45. /* place resources in contexts dependig on whether they already have workers or not */
  46. 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);
  47. /* not used resources are shared between all contexts */
  48. void sc_hypervisor_lp_share_remaining_resources(int ns, unsigned *sched_ctxs, int nworkers, int *workers);
  49. /* dichotomy btw t1 & t2 */
  50. double sc_hypervisor_lp_find_tmax(double t1, double t2);
  51. /* execute the lp trough dichotomy */
  52. unsigned sc_hypervisor_lp_execute_dichotomy(int ns, int nw, double w_in_s[ns][nw], unsigned solve_lp_integer, void *specific_data,
  53. double tmin, double tmax, double smallest_tmax,
  54. double (*lp_estimated_distrib_func)(int ns, int nw, double draft_w_in_s[ns][nw],
  55. unsigned is_integer, double tmax, void *specifc_data));
  56. #ifdef STARPU_HAVE_GLPK_H
  57. /* linear program that returns 1/tmax, and computes in table res the nr of workers needed by each context st
  58. the system ends up in the smallest tmax*/
  59. double sc_hypervisor_lp_simulate_distrib_flops(int nsched_ctxs, int ntypes_of_workers, double speed[nsched_ctxs][ntypes_of_workers],
  60. double flops[nsched_ctxs], double res[nsched_ctxs][ntypes_of_workers], int total_nw[ntypes_of_workers],
  61. unsigned sched_ctxs[nsched_ctxs], double vmax);
  62. /* linear program that simulates a distribution of tasks that minimises the execution time of the tasks in the pool */
  63. double sc_hypervisor_lp_simulate_distrib_tasks(int ns, int nw, int nt, double w_in_s[ns][nw], double tasks[nw][nt],
  64. double times[nw][nt], unsigned is_integer, double tmax, unsigned *in_sched_ctxs,
  65. struct sc_hypervisor_policy_task_pool *tmp_task_pools);
  66. /* linear program that simulates a distribution of flops over the workers on particular sample of the execution
  67. of the application such that the entire sample would finish in a minimum amount of time */
  68. 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,
  69. double **speed, double flops[ns], double **final_flops_on_w);
  70. #endif // STARPU_HAVE_GLPK_H
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif