StarPU Handbook
sc_hypervisor_policy.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2010-2014 Inria
4  * Copyright (C) 2012-2013,2015,2017 CNRS
5  * Copyright (C) 2012-2013 Université de Bordeaux
6  *
7  * StarPU is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * StarPU is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
17  */
18 
19 #ifndef SC_HYPERVISOR_POLICY_H
20 #define SC_HYPERVISOR_POLICY_H
21 
22 #include <sc_hypervisor.h>
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 
30 #define HYPERVISOR_REDIM_SAMPLE 0.02
31 #define HYPERVISOR_START_REDIM_SAMPLE 0.1
32 #define SC_NOTHING 0
33 #define SC_IDLE 1
34 #define SC_SPEED 2
35 
37 {
38  unsigned ncpus;
39  unsigned ncuda;
40  unsigned nw;
41 };
42 
44 {
45  struct starpu_codelet *cl;
46  uint32_t footprint;
47  unsigned sched_ctx_id;
48  unsigned long n;
49  size_t data_size;
51 };
52 
53 /* add task information to a task wrapper linked list */
54 void sc_hypervisor_policy_add_task_to_pool(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, struct sc_hypervisor_policy_task_pool **task_pools, size_t data_size);
55 
56 /* remove task information from a task wrapper linked list */
57 void sc_hypervisor_policy_remove_task_from_pool(struct starpu_task *task, uint32_t footprint, struct sc_hypervisor_policy_task_pool **task_pools);
58 
59 /* clone a task wrapper linked list */
60 struct sc_hypervisor_policy_task_pool* sc_hypervisor_policy_clone_task_pool(struct sc_hypervisor_policy_task_pool *tp);
61 
62 /* get the execution time of the submitted tasks out of starpu's calibration files */
63 void sc_hypervisor_get_tasks_times(int nw, int nt, double times[nw][nt], int *workers, unsigned size_ctxs, struct sc_hypervisor_policy_task_pool *task_pools);
64 
65 /* find the context with the lowest priority in order to move some workers */
66 unsigned sc_hypervisor_find_lowest_prio_sched_ctx(unsigned req_sched_ctx, int nworkers_to_move);
67 
68 /* find the first most idle workers of a context*/
69 int* sc_hypervisor_get_idlest_workers(unsigned sched_ctx, int *nworkers, enum starpu_worker_archtype arch);
70 
71 /* find the first most idle workers in a list */
72 int* sc_hypervisor_get_idlest_workers_in_list(int *start, int *workers, int nall_workers, int *nworkers, enum starpu_worker_archtype arch);
73 
74 /* find workers that can be moved from a context (if the constraints of min, max, etc allow this) */
75 int sc_hypervisor_get_movable_nworkers(struct sc_hypervisor_policy_config *config, unsigned sched_ctx, enum starpu_worker_archtype arch);
76 
77 /* compute how many workers should be moved from this context */
78 int sc_hypervisor_compute_nworkers_to_move(unsigned req_sched_ctx);
79 
80 /* check the policy's constraints in order to resize */
81 unsigned sc_hypervisor_policy_resize(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, unsigned force_resize, unsigned now);
82 
83 /* check the policy's constraints in order to resize and find a context willing the resources */
84 unsigned sc_hypervisor_policy_resize_to_unknown_receiver(unsigned sender_sched_ctx, unsigned now);
85 
86 /* compute the speed of a context */
87 double sc_hypervisor_get_ctx_speed(struct sc_hypervisor_wrapper* sc_w);
88 
89 /* get the time of execution of the slowest context */
90 double sc_hypervisor_get_slowest_ctx_exec_time(void);
91 
92 /* get the time of execution of the fastest context */
93 double sc_hypervisor_get_fastest_ctx_exec_time(void);
94 
95 /* compute the speed of a workers in a context */
96 double sc_hypervisor_get_speed_per_worker(struct sc_hypervisor_wrapper *sc_w, unsigned worker);
97 
98 /* compute the speed of a type of worker in a context */
99 double sc_hypervisor_get_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_w, enum starpu_worker_archtype arch);
100 
101 /* compute the speed of a type of worker in a context depending on its history */
102 double sc_hypervisor_get_ref_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_w, enum starpu_worker_archtype arch);
103 
104 /* compute the average speed of a type of worker in all ctxs from the begining of appl */
105 double sc_hypervisor_get_avg_speed(enum starpu_worker_archtype arch);
106 
107 /* verify if we need to consider the max in the lp */
108 void sc_hypervisor_check_if_consider_max(struct types_of_workers *tw);
109 
110 /* get the list of workers grouped by type */
111 void sc_hypervisor_group_workers_by_type(struct types_of_workers *tw, int *total_nw);
112 
113 /* get what type of worker corresponds to a certain index of types of workers */
114 enum starpu_worker_archtype sc_hypervisor_get_arch_for_index(unsigned w, struct types_of_workers *tw);
115 
116 /* get the index of types of workers corresponding to the type of workers indicated */
117 unsigned sc_hypervisor_get_index_for_arch(enum starpu_worker_archtype arch, struct types_of_workers *tw);
118 
119 /* check if we trigger resizing or not */
120 unsigned sc_hypervisor_criteria_fulfilled(unsigned sched_ctx, int worker);
121 
122 /* check if worker was idle long enough */
123 unsigned sc_hypervisor_check_idle(unsigned sched_ctx, int worker);
124 
125 /* check if there is a speed gap btw ctxs */
126 unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
127 
128 /* check if there is a speed gap btw ctxs on one level */
129 unsigned sc_hypervisor_check_speed_gap_btw_ctxs_on_level(int level, int *workers_in, int nworkers_in, unsigned father_sched_ctx_id, unsigned **sched_ctxs, int *nsched_ctxs);
130 
131 /* check what triggers resizing (idle, speed, etc.)*/
132 unsigned sc_hypervisor_get_resize_criteria();
133 
134 /* load information concerning the type of workers into a types_of_workers struct */
135 struct types_of_workers* sc_hypervisor_get_types_of_workers(int *workers, unsigned nworkers);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif
struct sc_hypervisor_policy_task_pool * next
Definition: sc_hypervisor_policy.h:50
Definition: starpu_task.h:89
Definition: sc_hypervisor_monitoring.h:43
size_t data_size
Definition: sc_hypervisor_policy.h:49
Definition: sc_hypervisor_policy.h:43
starpu_worker_archtype
Definition: starpu_worker.h:31
unsigned sched_ctx_id
Definition: sc_hypervisor_policy.h:47
unsigned long n
Definition: sc_hypervisor_policy.h:48
Definition: starpu_task.h:129
struct starpu_codelet * cl
Definition: sc_hypervisor_policy.h:45
Definition: sc_hypervisor_policy.h:36
uint32_t footprint
Definition: sc_hypervisor_policy.h:46
Definition: sc_hypervisor_config.h:48