scheduling_context_hypervisor.doxy 5.7 KB

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