sc_hypervisor_monitoring.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 - 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_MONITORING_H
  17. #define SC_HYPERVISOR_MONITORING_H
  18. #include <sc_hypervisor.h>
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. /* structure to indicate when the moving of workers was actually done
  24. (moved workers can be seen in the new ctx ) */
  25. struct sc_hypervisor_resize_ack
  26. {
  27. /* receiver context */
  28. int receiver_sched_ctx;
  29. /* list of workers required to be moved */
  30. int *moved_workers;
  31. /* number of workers required to be moved */
  32. int nmoved_workers;
  33. /* list of workers that actually got in the receiver ctx */
  34. int *acked_workers;
  35. };
  36. /* wrapper attached to a sched_ctx storing monitoring information */
  37. struct sc_hypervisor_wrapper
  38. {
  39. /* the sched_ctx it monitors */
  40. unsigned sched_ctx;
  41. /* user configuration meant to limit resizing */
  42. struct sc_hypervisor_policy_config *config;
  43. /* the start time of the resizing sample of the workers of this context*/
  44. double start_time_w[STARPU_NMAXWORKERS];
  45. /* idle time of workers in this context */
  46. double current_idle_time[STARPU_NMAXWORKERS];
  47. /* idle time from the last resize */
  48. double idle_time[STARPU_NMAXWORKERS];
  49. /* time when the idle started */
  50. double idle_start_time[STARPU_NMAXWORKERS];
  51. /* time during which the worker executed tasks */
  52. double exec_time[STARPU_NMAXWORKERS];
  53. /* time when the worker started executing a task */
  54. double exec_start_time[STARPU_NMAXWORKERS];
  55. /* list of workers that will leave this contexts (lazy resizing process) */
  56. int worker_to_be_removed[STARPU_NMAXWORKERS];
  57. /* number of tasks pushed on each worker in this ctx */
  58. int pushed_tasks[STARPU_NMAXWORKERS];
  59. /* number of tasks poped from each worker in this ctx */
  60. int poped_tasks[STARPU_NMAXWORKERS];
  61. /* number of flops the context has to execute */
  62. double total_flops;
  63. /* number of flops executed since the biginning until now */
  64. double total_elapsed_flops[STARPU_NMAXWORKERS];
  65. /* number of flops executed since last resizing */
  66. double elapsed_flops[STARPU_NMAXWORKERS];
  67. /* data quantity executed on each worker in this ctx */
  68. size_t elapsed_data[STARPU_NMAXWORKERS];
  69. /* nr of tasks executed on each worker in this ctx */
  70. int elapsed_tasks[STARPU_NMAXWORKERS];
  71. /* the average speed of the type of workers when they belonged to this context */
  72. /* 0 - cuda 1 - cpu */
  73. double ref_speed[2];
  74. /* number of flops submitted to this ctx */
  75. double submitted_flops;
  76. /* number of flops that still have to be executed in this ctx */
  77. double remaining_flops;
  78. /* the start time of the resizing sample of this context*/
  79. double start_time;
  80. /* the first time a task was pushed to this context*/
  81. double real_start_time;
  82. /* the start time for sample in which the hyp is not allowed to react
  83. bc too expensive */
  84. double hyp_react_start_time;
  85. /* the workers don't leave the current ctx until the receiver ctx
  86. doesn't ack the receive of these workers */
  87. struct sc_hypervisor_resize_ack resize_ack;
  88. /* mutex to protect the ack of workers */
  89. starpu_pthread_mutex_t mutex;
  90. /* boolean indicating if the resizing strategy can see the
  91. flops of all the execution or not */
  92. unsigned total_flops_available;
  93. /* boolean indicating that a context is being sized */
  94. unsigned to_be_sized;
  95. /* boolean indicating if we add the idle of this worker to
  96. the idle of the context */
  97. unsigned compute_idle[STARPU_NMAXWORKERS];
  98. /* boolean indicating if we add the entiere idle of this
  99. worker to the idle of the context or just half*/
  100. unsigned compute_partial_idle[STARPU_NMAXWORKERS];
  101. /* consider the max in the lp */
  102. unsigned consider_max;
  103. };
  104. /* return the wrapper of context that saves its monitoring information */
  105. struct sc_hypervisor_wrapper *sc_hypervisor_get_wrapper(unsigned sched_ctx);
  106. /* get the list of registered contexts */
  107. unsigned *sc_hypervisor_get_sched_ctxs();
  108. /* get the number of registered contexts */
  109. int sc_hypervisor_get_nsched_ctxs();
  110. /* get the number of workers of a certain architecture in a context */
  111. int sc_hypervisor_get_nworkers_ctx(unsigned sched_ctx, enum starpu_worker_archtype arch);
  112. /* get the number of flops executed by a context since last resizing (reset to 0 when a resizing is done)*/
  113. double sc_hypervisor_get_elapsed_flops_per_sched_ctx(struct sc_hypervisor_wrapper *sc_w);
  114. /* get the number of flops executed by a context since the begining */
  115. double sc_hypervisor_get_total_elapsed_flops_per_sched_ctx(struct sc_hypervisor_wrapper* sc_w);
  116. /* compute an average value of the cpu/cuda speed */
  117. double sc_hypervisorsc_hypervisor_get_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_w, enum starpu_worker_archtype arch);
  118. /* compte the actual speed of all workers of a specific type of worker */
  119. double sc_hypervisor_get_speed(struct sc_hypervisor_wrapper *sc_w, enum starpu_worker_archtype arch);
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123. #endif