StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
sc_hypervisor.h
Go to the documentation of this file.
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
17 #ifndef SC_HYPERVISOR_H
18 #define SC_HYPERVISOR_H
19
20 #include <starpu.h>
21 #include <starpu_sched_ctx_hypervisor.h>
22 #include <sc_hypervisor_config.h>
23 #include <sc_hypervisor_monitoring.h>
24 #include <math.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 /* synchronise the hypervisor when several workers try to update its information */
32 starpu_pthread_mutex_t act_hypervisor_mutex;
33
34 /* platform of resizing contexts */
35 struct sc_hypervisor_policy
36 {
37 /* name of the strategy */
38 const char* name;
39
40 /* indicate if it is a policiy create by the user or not */
41 unsigned custom;
42
43 /* Distribute workers to contexts even at the begining of the program */
44 void (*size_ctxs)(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int nworkers);
45
46 /* Require explicit resizing */
47 void (*resize_ctxs)(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int nworkers);
48
49 /* the hypervisor takes a decision when the worker was idle for another cyle in this ctx */
50 void (*handle_idle_cycle)(unsigned sched_ctx, int worker);
51
52 /* the hypervisor takes a decision when another task was pushed on this worker in this ctx */
53 void (*handle_pushed_task)(unsigned sched_ctx, int worker);
54
55 /* the hypervisor takes a decision when another task was poped from this worker in this ctx */
56 void (*handle_poped_task)(unsigned sched_ctx, int worker,struct starpu_task *task, uint32_t footprint);
57
58 /* the hypervisor takes a decision when the worker stoped being idle in this ctx */
59 void (*handle_idle_end)(unsigned sched_ctx, int worker);
60
61 /* the hypervisor takes a decision when a certain task finished executing in this ctx */
62 void (*handle_post_exec_hook)(unsigned sched_ctx, int task_tag);
63
64 /* the hypervisor takes a decision when a job was submitted in this ctx */
65 void (*handle_submitted_job)(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size);
66
67 /* the hypervisor takes a decision when a certain ctx was deleted */
68 void (*end_ctx)(unsigned sched_ctx);
69 };
70
71 /* start the hypervisor indicating the resizing policy to user */
72 void* sc_hypervisor_init(struct sc_hypervisor_policy *policy);
73
74 /* shutdown the hypervisor */
75 void sc_hypervisor_shutdown(void);
76
77 /* only registered contexts are resized by the hypervisor */
78 void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops);
79
80 /* remove a worker from the hypervisor's list */
81 void sc_hypervisor_unregister_ctx(unsigned sched_ctx);
82
83 /* submit a requirement of resizing when a task taged with task_tag is executed */
84 void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag);
85
86 /* reevaluate the distribution of the resources and eventually resize if needed */
87 void sc_hypervisor_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int nworkers);
88
89 /* don't allow the hypervisor to resize a context */
90 void sc_hypervisor_stop_resize(unsigned sched_ctx);
91
92 /* allow the hypervisor to resize a context */
93 void sc_hypervisor_start_resize(unsigned sched_ctx);
94
95 /* check out the current policy of the hypervisor */
96 const char *sc_hypervisor_get_policy();
97
98 /* ask the hypervisor to add workers to a sched_ctx */
99 void sc_hypervisor_add_workers_to_sched_ctx(int* workers_to_add, unsigned nworkers_to_add, unsigned sched_ctx);
100
101 /* ask the hypervisor to remove workers from a sched_ctx */
102 void sc_hypervisor_remove_workers_from_sched_ctx(int* workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx, unsigned now);
103
104 /* ask the hypervisor to move workers from one context to another */
105 void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now);
106
107 /* ask the hypervisor to chose a distribution of workers in the required contexts */
108 void sc_hypervisor_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
109
110 /* check if there are pending demands of resizing */
111 unsigned sc_hypervisor_get_size_req(unsigned **sched_ctxs, int* nsched_ctxs, int **workers, int *nworkers);
112
113 /* save a demand of resizing */
114 void sc_hypervisor_save_size_req(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers);
115
116 /* clear the list of pending demands of resizing */
117 void sc_hypervisor_free_size_req(void);
118
119 /* check out if a context can be resized */
120 unsigned sc_hypervisor_can_resize(unsigned sched_ctx);
121
122 /* indicate the types of tasks a context will execute in order to better decide the sizing of ctxs */
123 void sc_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size);
124
125 /* change dynamically the total number of flops of a context, move the deadline of the finishing time of the context */
126 void sc_hypervisor_update_diff_total_flops(unsigned sched_ctx, double diff_total_flops);
127
128 /* change dynamically the number of the elapsed flops in a context, modify the past in order to better compute the speed */
129 void sc_hypervisor_update_diff_elapsed_flops(unsigned sched_ctx, double diff_task_flops);
130
131 /* updates the min and max workers needed by each context */
132 void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs);
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif
sc_hypervisor_policy::handle_poped_task
void(* handle_poped_task)(unsigned sched_ctx, int worker, struct starpu_task *task, uint32_t footprint)
Definition: sc_hypervisor.h:56
starpu_codelet
Definition: starpu_task.h:73
sc_hypervisor_unregister_ctx
void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
sc_hypervisor_stop_resize
void sc_hypervisor_stop_resize(unsigned sched_ctx)
sc_hypervisor_policy::resize_ctxs
void(* resize_ctxs)(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
Definition: sc_hypervisor.h:47
sc_hypervisor_set_type_of_task
void sc_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size)
sc_hypervisor_policy::end_ctx
void(* end_ctx)(unsigned sched_ctx)
Definition: sc_hypervisor.h:68
sc_hypervisor_policy::handle_post_exec_hook
void(* handle_post_exec_hook)(unsigned sched_ctx, int task_tag)
Definition: sc_hypervisor.h:62
sc_hypervisor_shutdown
void sc_hypervisor_shutdown(void)
sc_hypervisor_monitoring.h
sc_hypervisor_can_resize
unsigned sc_hypervisor_can_resize(unsigned sched_ctx)
sc_hypervisor_size_ctxs
void sc_hypervisor_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
sc_hypervisor_update_diff_total_flops
void sc_hypervisor_update_diff_total_flops(unsigned sched_ctx, double diff_total_flops)
sc_hypervisor_get_policy
const char * sc_hypervisor_get_policy()
sc_hypervisor_policy::size_ctxs
void(* size_ctxs)(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
Definition: sc_hypervisor.h:44
sc_hypervisor_free_size_req
void sc_hypervisor_free_size_req(void)
sc_hypervisor_policy::handle_idle_end
void(* handle_idle_end)(unsigned sched_ctx, int worker)
Definition: sc_hypervisor.h:59
starpu_task
Definition: starpu_task.h:104
sc_hypervisor_policy
Definition: sc_hypervisor.h:35
sc_hypervisor_init
void * sc_hypervisor_init(struct sc_hypervisor_policy *policy)
sc_hypervisor_move_workers
void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now)
sc_hypervisor_remove_workers_from_sched_ctx
void sc_hypervisor_remove_workers_from_sched_ctx(int *workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx, unsigned now)
sc_hypervisor_policy::handle_idle_cycle
void(* handle_idle_cycle)(unsigned sched_ctx, int worker)
Definition: sc_hypervisor.h:50
sc_hypervisor_policy::handle_submitted_job
void(* handle_submitted_job)(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size)
Definition: sc_hypervisor.h:65
sc_hypervisor_policy::custom
unsigned custom
Definition: sc_hypervisor.h:41
sc_hypervisor_get_size_req
unsigned sc_hypervisor_get_size_req(unsigned **sched_ctxs, int *nsched_ctxs, int **workers, int *nworkers)
starpu_task::sched_ctx
unsigned sched_ctx
Definition: starpu_task.h:161
sc_hypervisor_policy::name
const char * name
Definition: sc_hypervisor.h:38
sc_hypervisor_post_resize_request
void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag)
sc_hypervisor_save_size_req
void sc_hypervisor_save_size_req(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
sc_hypervisor_add_workers_to_sched_ctx
void sc_hypervisor_add_workers_to_sched_ctx(int *workers_to_add, unsigned nworkers_to_add, unsigned sched_ctx)
sc_hypervisor_register_ctx
void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
sc_hypervisor_policy::handle_pushed_task
void(* handle_pushed_task)(unsigned sched_ctx, int worker)
Definition: sc_hypervisor.h:53
starpu.h
starpu_sched_ctx_hypervisor.h
sc_hypervisor_config.h
sc_hypervisor_update_diff_elapsed_flops
void sc_hypervisor_update_diff_elapsed_flops(unsigned sched_ctx, double diff_task_flops)
sc_hypervisor_start_resize
void sc_hypervisor_start_resize(unsigned sched_ctx)