sc_hypervisor.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_H
  17. #define SC_HYPERVISOR_H
  18. #include <starpu.h>
  19. #include <sc_hypervisor_config.h>
  20. #include <sc_hypervisor_monitoring.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /* synchronise the hypervisor when several workers try to update its information */
  26. starpu_pthread_mutex_t act_hypervisor_mutex;
  27. /* Forward declaration of an internal data structure
  28. * FIXME: Remove when no longer exposed. */
  29. /* the resizing is not done instantly, a request is kept and executed
  30. when available */
  31. struct resize_request_entry;
  32. /* platform of resizing contexts */
  33. struct sc_hypervisor_policy
  34. {
  35. /* name of the strategy */
  36. const char* name;
  37. /* indicate if it is a policiy create by the user or not */
  38. unsigned custom;
  39. /* if knwing the future the hypervisor can find the good
  40. distribution of workers on contexts even at the begining of the program */
  41. void (*size_ctxs)(int *sched_ctxs, int nsched_ctxs , int *workers, int nworkers);
  42. /* the hypervisor takes a decision when the worker was idle for another cyle in this ctx */
  43. void (*handle_idle_cycle)(unsigned sched_ctx, int worker);
  44. /* the hypervisor takes a decision when another task was pushed on this worker in this ctx */
  45. void (*handle_pushed_task)(unsigned sched_ctx, int worker);
  46. /* the hypervisor takes a decision when another task was poped from this worker in this ctx */
  47. void (*handle_poped_task)(unsigned sched_ctx, int worker,struct starpu_task *task, uint32_t footprint);
  48. /* the hypervisor takes a decision when the worker stoped being idle in this ctx */
  49. void (*handle_idle_end)(unsigned sched_ctx, int worker);
  50. /* the hypervisor takes a decision when a certain task finished executing in this ctx */
  51. void (*handle_post_exec_hook)(unsigned sched_ctx, int task_tag);
  52. /* the hypervisor takes a decision when a job was submitted in this ctx */
  53. void (*handle_submitted_job)(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint);
  54. /* the hypervisor takes a decision when a certain ctx was deleted */
  55. void (*end_ctx)(unsigned sched_ctx);
  56. };
  57. /* start the hypervisor indicating the resizing policy to user */
  58. struct starpu_sched_ctx_performance_counters *sc_hypervisor_init(struct sc_hypervisor_policy *policy);
  59. /* shutdown the hypervisor */
  60. void sc_hypervisor_shutdown(void);
  61. /* only registered contexts are resized by the hypervisor */
  62. void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops);
  63. /* remove a worker from the hypervisor's list */
  64. void sc_hypervisor_unregister_ctx(unsigned sched_ctx);
  65. /* submit a requirement of resizing when a task taged with task_tag is executed */
  66. void sc_hypervisor_resize(unsigned sched_ctx, int task_tag);
  67. /* don't allow the hypervisor to resize a context */
  68. void sc_hypervisor_stop_resize(unsigned sched_ctx);
  69. /* allow the hypervisor to resize a context */
  70. void sc_hypervisor_start_resize(unsigned sched_ctx);
  71. /* check out the current policy of the hypervisor */
  72. const char *sc_hypervisor_get_policy();
  73. /* ask the hypervisor to add workers to a sched_ctx */
  74. void sc_hypervisor_add_workers_to_sched_ctx(int* workers_to_add, unsigned nworkers_to_add, unsigned sched_ctx);
  75. /* ask the hypervisor to remove workers from a sched_ctx */
  76. void sc_hypervisor_remove_workers_from_sched_ctx(int* workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx, unsigned now);
  77. /* ask the hypervisor to move workers from one context to another */
  78. void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now);
  79. /* ask the hypervisor to chose a distribution of workers in the required contexts */
  80. void sc_hypervisor_size_ctxs(int *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
  81. /* check if there are pending demands of resizing */
  82. unsigned sc_hypervisor_get_size_req(int **sched_ctxs, int* nsched_ctxs, int **workers, int *nworkers);
  83. /* save a demand of resizing */
  84. void sc_hypervisor_save_size_req(int *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
  85. /* clear the list of pending demands of resizing */
  86. void sc_hypervisor_free_size_req(void);
  87. /* check out if a context can be resized */
  88. unsigned sc_hypervisor_can_resize(unsigned sched_ctx);
  89. /* indicate the types of tasks a context will execute in order to better decide the sizing of ctxs */
  90. void sc_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif