sc_hypervisor.texi 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. @c -*-texinfo-*-
  2. @c This file is part of the StarPU Handbook.
  3. @c Copyright (C) 2011--2013 Institut National de Recherche en Informatique et Automatique
  4. @c See the file starpu.texi for copying conditions.
  5. @cindex Scheduling Context Hypervisor
  6. @menu
  7. * What is the Hypervisor::
  8. * Start the Hypervisor::
  9. * Interrogate the runtime::
  10. * Trigger the Hypervisor::
  11. * Resizing strategies::
  12. @end menu
  13. @node What is the Hypervisor
  14. @section What is the Hypervisor
  15. StarPU proposes a platform for constructing Scheduling Contexts, for deleting and modifying them dynamically.
  16. A parallel kernel, can thus be isolated into a scheduling context and interferences between several parallel kernels are avoided.
  17. If the user knows exactly how many workers each scheduling context needs, he can assign them to the contexts at their creation time or modify them during the execution of the program.
  18. The Scheduling Context Hypervisor Plugin is available for the users who do not dispose of a regular parallelism, who cannot know in advance the exact size of the context and need to resize the contexts according to the behavior of the parallel kernels.
  19. The Hypervisor receives information from StarPU concerning the execution of the tasks, the efficiency of the resources, etc. and it decides accordingly when and how the contexts can be resized.
  20. Basic strategies of resizing scheduling contexts already exist but a platform for implementing additional custom ones is available.
  21. @node Start the Hypervisor
  22. @section Start the Hypervisor
  23. The Hypervisor must be initialised once at the beging of the application. At this point a resizing policy should be indicated. This strategy depends on the information the application is able to provide to the hypervisor as well
  24. as on the accuracy needed for the resizing procedure. For exemple, the application may be able to provide an estimation of the workload of the contexts. In this situation the hypervisor may decide what resources the contexts need.
  25. However, if no information is provided the hypervisor evaluates the behavior of the resources and of the application and makes a guess about the future.
  26. The hypervisor resizes only the registered contexts.
  27. @node Interrogate the runtime
  28. @section Interrrogate the runtime
  29. The runtime provides the hypervisor with information concerning the behavior of the resources and the application. This is done by using the performance_counters, some callbacks indicating when the resources are idle or not efficient, when the application submits tasks or when it becames to slow.
  30. @node Trigger the Hypervisor
  31. @section Trigger the Hypervisor
  32. The resizing is triggered either when the application requires it or when the initials distribution of resources alters the performance of the application( the application is to slow or the resource are idle for too long time, threashold indicated by the user). When this happens different resizing strategy are applied that target minimising the total execution of the application, the instant speed or the idle time of the resources.
  33. @node Resizing strategies
  34. @section Resizing strategies
  35. The plugin proposes several strategies for resizing the scheduling context.
  36. The @b{Application driven} strategy uses the user's input concerning the moment when he wants to resize the contexts.
  37. Thus, the users tags the task that should trigger the resizing process. We can set directly the corresponding field in the @code{starpu_task} data structure is @code{hypervisor_tag} or
  38. use the macro @code{STARPU_HYPERVISOR_TAG} in @code{starpu_insert_task} function.
  39. @cartouche
  40. @smallexample
  41. task.hypervisor_tag = 2;
  42. @end smallexample
  43. @end cartouche
  44. or
  45. @cartouche
  46. @smallexample
  47. starpu_insert_task(&codelet,
  48. ...,
  49. STARPU_HYPERVISOR_TAG, 2,
  50. 0);
  51. @end smallexample
  52. @end cartouche
  53. Then the user has to indicate that when a task with the specified tag is executed the contexts should resize.
  54. @cartouche
  55. @smallexample
  56. sc_hypervisor_resize(sched_ctx, 2);
  57. @end smallexample
  58. @end cartouche
  59. The user can use the same tag to change the resizing configuration of the contexts if he considers it necessary.
  60. @cartouche
  61. @smallexample
  62. sc_hypervisor_ioctl(sched_ctx,
  63. HYPERVISOR_MIN_WORKERS, 6,
  64. HYPERVISOR_MAX_WORKERS, 12,
  65. HYPERVISOR_TIME_TO_APPLY, 2,
  66. NULL);
  67. @end smallexample
  68. @end cartouche
  69. The @b{Idleness} based strategy resizes the scheduling contexts every time one of their workers stays idle
  70. for a period longer than the one imposed by the user (see @pxref{The user's input in the resizing process})
  71. @cartouche
  72. @smallexample
  73. int workerids[3] = @{1, 3, 10@};
  74. int workerids2[9] = @{0, 2, 4, 5, 6, 7, 8, 9, 11@};
  75. sc_hypervisor_ioctl(sched_ctx_id,
  76. HYPERVISOR_MAX_IDLE, workerids, 3, 10000.0,
  77. HYPERVISOR_MAX_IDLE, workerids2, 9, 50000.0,
  78. NULL);
  79. @end smallexample
  80. @end cartouche
  81. The @b{Gflops rate} based strategy resizes the scheduling contexts such that they all finish at the same time.
  82. The velocity of each of them is considered and once one of them is significantly slower the resizing process is triggered.
  83. In order to do these computations the user has to input the total number of instructions needed to be executed by the
  84. parallel kernels and the number of instruction to be executed by each task.
  85. The number of flops to be executed by a context are passed as parameter when they are registered to the hypervisor,
  86. (@code{sc_hypervisor_register_ctx(sched_ctx_id, flops)}) and the one to be executed by each task are passed when the task is submitted.
  87. The corresponding field in the @code{starpu_task} data structure is @code{flops} and
  88. the corresponding macro in @code{starpu_insert_task} function is @code{STARPU_FLOPS}. When the task is executed
  89. the resizing process is triggered.
  90. @cartouche
  91. @smallexample
  92. task.flops = 100;
  93. @end smallexample
  94. @end cartouche
  95. or
  96. @cartouche
  97. @smallexample
  98. starpu_insert_task(&codelet,
  99. ...,
  100. STARPU_FLOPS, (double) 100,
  101. 0);
  102. @end smallexample
  103. @end cartouche