Преглед изворни кода

add missing hyp functions to the doc + some code cleaning

Andra Hugo пре 11 година
родитељ
комит
93ed656614

+ 1 - 0
Makefile.am

@@ -75,6 +75,7 @@ versinclude_HEADERS = 				\
 	include/starpu_bound.h			\
 	include/starpu_scheduler.h		\
 	include/starpu_sched_ctx.h		\
+	include/starpu_sched_ctx_hypervisor.h	\
 	include/starpu_top.h			\
 	include/starpu_deprecated_api.h         \
 	include/starpu_hash.h			\

+ 98 - 51
doc/doxygen/chapters/api/scheduling_context_hypervisor.doxy

@@ -15,16 +15,26 @@ This structure contains all the methods that implement a hypervisor resizing pol
         Indicates the name of the policy, if there is not a custom policy, the policy corresponding to this name will be used by the hypervisor
 \var sc_hypervisor_policy::custom
         Indicates whether the policy is custom or not
+\var sc_hypervisor_policy::size_ctxs
+	Distribute workers to contexts even at the begining of the program
+\var sc_hypervisor_policy::resize_ctxs
+	Require explicit resizing
 \var sc_hypervisor_policy::handle_idle_cycle
         It is called whenever the indicated worker executes another idle cycle in sched_ctx
 \var sc_hypervisor_policy::handle_pushed_task
         It is called whenever a task is pushed on the worker’s queue corresponding to the context sched_ctx
 \var sc_hypervisor_policy::handle_poped_task
         It is called whenever a task is poped from the worker’s queue corresponding to the context sched_ctx
+\var sc_hypervisor_policy::handle_poped_task
+	The hypervisor takes a decision when another task was poped from this worker in this ctx
 \var sc_hypervisor_policy::handle_idle_end
         It is called whenever a task is executed on the indicated worker and context after a long period of idle time
 \var sc_hypervisor_policy::handle_post_exec_hook
         It is called whenever a tag task has just been executed. The table of resize requests is provided as well as the tag
+\var sc_hypervisor_policy::handle_submitted_job
+	The hypervisor takes a decision when a job was submitted in this ctx
+\var sc_hypervisor_policy::end_ctx
+	The hypervisor takes a decision when a certain ctx was deleted
 
 \struct sc_hypervisor_policy_config
 \ingroup API_Scheduling_Context_Hypervisor
@@ -41,10 +51,18 @@ can be used to construct new resize strategies.
         Indicates the priority of each worker in the context
 \var sc_hypervisor_policy_config::max_idle
         Indicates the maximum idle time accepted before a resize is triggered
+\var sc_hypervisor_policy_config::min_working
+	Indicates that underneath this limit the priority of the worker is reduced
 \var sc_hypervisor_policy_config::fixed_workers
         Indicates which workers can be moved and which ones are fixed
 \var sc_hypervisor_policy_config:: new_workers_max_idle
         Indicates the maximum idle time accepted before a resize is triggered for the workers that just arrived in the new context
+\var sc_hypervisor_policy_config::empty_ctx_max_idle
+         Indicates that above this context we allow removing all workers
+\var sc_hypervisor_policy_config::ispeed_w_sample
+         Indicates the sample used to compute the instant speed per worker
+\var sc_hypervisor_policy_config::ispeed_ctx_sample
+        Indicates the sample used to compute the instant speed per ctxs
 
 \struct sc_hypervisor_wrapper
 \ingroup API_Scheduling_Context_Hypervisor
@@ -102,9 +120,8 @@ Number of tasks of this kind
 \var sc_hypervisor_policy_task_pool::next
 Other task kinds
 
-@name Managing the hypervisor
+\fn void *sc_hypervisor_init(struct sc_hypervisor_policy *policy)
 \ingroup API_Scheduling_Context_Hypervisor
-
 There is a single hypervisor that is in charge of resizing contexts
 and the resizing strategy is chosen at the initialization of the
 hypervisor. A single resize can be done at a time.
@@ -114,9 +131,7 @@ performance counters to StarPU. By incrementing them, StarPU can help
 the hypervisor in the resizing decision making process. TODO maybe
 they should be hidden to the user
 
-\fn struct starpu_sched_ctx_performance_counters *sc_hypervisor_init(struct sc_hypervisor_policy *policy)
-\ingroup API_Scheduling_Context_Hypervisor
-Initializes the hypervisor to use the strategy provided as parameter
+This function initializes the hypervisor to use the strategy provided as parameter
 and creates the performance counters (see starpu_sched_ctx_performance_counters).
 These performance counters represent actually some callbacks that will
 be used by the contexts to notify the information needed by the
@@ -133,50 +148,88 @@ no synchronization between this function and starpu_shutdown(). Thus,
 this should be called after starpu_shutdown(), because the performance
 counters will still need allocated callback functions.
 
-@name Registering Scheduling Contexts to the hypervisor
-\ingroup API_Scheduling_Context_Hypervisor
-
-Scheduling Contexts that have to be resized by the hypervisor must be
-first registered to the hypervisor. Whenever we want to exclude
-contexts from the resizing process we have to unregister them from the
-hypervisor.
-
 \fn void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
 \ingroup API_Scheduling_Context_Hypervisor
-Register the context to the hypervisor, and indicate the number of
+Scheduling Contexts that have to be resized by the hypervisor must be
+first registered to the hypervisor. 
+This function registers the context to the hypervisor, and indicate the number of
 flops the context will execute (needed for Gflops rate based strategy
 see \ref ResizingStrategies or any other custom strategy needing it, for
 the others we can pass 0.0)
 
 \fn void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
 \ingroup API_Scheduling_Context_Hypervisor
-Unregister the context from the hypervisor.
+Whenever we want to exclude
+contexts from the resizing process we have to unregister them from the
+hypervisor.
+
+\fn void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag)
+\ingroup API_Scheduling_Context_Hypervisor
+Requires resizing the context \p sched_ctx whenever a task tagged with the id \p task_tag
+finished executing 
 
-@name Users’ Input In The Resizing Process
-\anchor UsersInputInTheResizingProcess
+\fn void sc_hypervisor_resize_ctxs(int *sched_ctxs, int nsched_ctxs , int *workers, int nworkers)
 \ingroup API_Scheduling_Context_Hypervisor
+Requires reconsidering the distribution of ressources over the indicated scheduling contexts 
 
+\fn void sc_hypervisor_stop_resize(unsigned sched_ctx)
+\ingroup API_Scheduling_Context_Hypervisor
 The user can totally forbid the resizing of a certain context or can
 then change his mind and allow it (in this case the resizing is
 managed by the hypervisor, that can forbid it or allow it)
 
-\fn void sc_hypervisor_stop_resize(unsigned sched_ctx)
-\ingroup API_Scheduling_Context_Hypervisor
-Forbid resizing of a context
-
 \fn void sc_hypervisor_start_resize(unsigned sched_ctx)
 \ingroup API_Scheduling_Context_Hypervisor
 Allow resizing of a context. The user can then provide information to
 the hypervisor concerning the conditions of resizing.
 
-\fn void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag)
+\fn char *sc_hypervisor_get_policy();
 \ingroup API_Scheduling_Context_Hypervisor
-Requires resizing the context \p sched_ctx whenever a task tagged with the id \p task_tag
-finished executing 
+Returns the name of the resizing policy the hypervisor uses
 
-\fn void sc_hypervisor_resize_ctxs(int *sched_ctxs, int nsched_ctxs , int *workers, int nworkers)
+\fn void sc_hypervisor_add_workers_to_sched_ctx(int* workers_to_add, unsigned nworkers_to_add, unsigned sched_ctx)
 \ingroup API_Scheduling_Context_Hypervisor
-Requires reconsidering the distribution of ressources over the indicated scheduling contexts 
+Ask the hypervisor to add workers to a sched_ctx 
+
+\fn void sc_hypervisor_remove_workers_from_sched_ctx(int* workers_to_remove, unsigned nworkers_to_remove, unsigned sched_ctx, unsigned now)
+\ingroup API_Scheduling_Context_Hypervisor
+Ask the hypervisor to remove workers from a sched_ctx 
+
+\fn void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now)
+\ingroup API_Scheduling_Context_Hypervisor
+Moves workers from one context to another
+   
+\fn void sc_hypervisor_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
+\ingroup API_Scheduling_Context_Hypervisor
+Ask the hypervisor to chose a distribution of workers in the required contexts
+   
+\fn unsigned sc_hypervisor_get_size_req(unsigned **sched_ctxs, int* nsched_ctxs, int **workers, int *nworkers)
+\ingroup API_Scheduling_Context_Hypervisor
+Check if there are pending demands of resizing
+
+\fn void sc_hypervisor_save_size_req(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
+\ingroup API_Scheduling_Context_Hypervisor
+Save a demand of resizing
+
+\fn void sc_hypervisor_free_size_req(void)
+\ingroup API_Scheduling_Context_Hypervisor
+Clear the list of pending demands of resizing
+
+\fn unsigned sc_hypervisor_can_resize(unsigned sched_ctx)
+\ingroup API_Scheduling_Context_Hypervisor
+Check out if a context can be resized
+
+\fn void sc_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size)
+\ingroup API_Scheduling_Context_Hypervisor
+Indicate the types of tasks a context will execute in order to better decide the sizing of ctxs
+
+\fn void sc_hypervisor_update_diff_total_flops(unsigned sched_ctx, double diff_total_flops)
+\ingroup API_Scheduling_Context_Hypervisor
+Change dynamically the total number of flops of a context, move the deadline of the finishing time of the context
+
+\fn void sc_hypervisor_update_diff_elapsed_flops(unsigned sched_ctx, double diff_task_flops)
+\ingroup API_Scheduling_Context_Hypervisor
+Change dynamically the number of the elapsed flops in a context, modify the past in order to better compute the speed 
 
 \fn void sc_hypervisor_ctl(unsigned sched_ctx, ...)
 \ingroup API_Scheduling_Context_Hypervisor
@@ -250,36 +303,33 @@ This macro is used when calling sc_hypervisor_ctl() and must be
 followed by 1 argument (int) indicating the tag an executed task
 should have such that this configuration should be taken into account.
 
-@name Defining a new hypervisor policy
-\ingroup API_Scheduling_Context_Hypervisor
 
-While Scheduling Context Hypervisor Plugin comes with a variety of
-resizing policies (see \ref ResizingStrategies), it may sometimes be
-desirable to implement custom policies to address specific problems.
-The API described below allows users to write their own resizing policy.
+\def SC_HYPERVISOR_ISPEED_W_SAMPLE
+\ingroup API_Scheduling_Context_Hypervisor
+This macro is used when calling sc_hypervisor_ctl() and must be
+followed by 1 argument, a double, that indicates the number of flops
+needed to be executed before computing the speed of a worker
 
-Here an example of how to define a new policy
+\def SC_HYPERVISOR_ISPEED_CTX_SAMPLE
+\ingroup API_Scheduling_Context_Hypervisor
+This macro is used when calling sc_hypervisor_ctl() and must be
+followed by 1 argument, a double, that indicates the number of flops
+needed to be executed before computing the speed of a context
 
-\code{.c}
-struct sc_hypervisor_policy dummy_policy =
-{
-       .handle_poped_task = dummy_handle_poped_task,
-       .handle_pushed_task = dummy_handle_pushed_task,
-       .handle_idle_cycle = dummy_handle_idle_cycle,
-       .handle_idle_end = dummy_handle_idle_end,
-       .handle_post_exec_hook = dummy_handle_post_exec_hook,
-       .custom = 1,
-       .name = "dummy"
-};
-\endcode
 
-\fn void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int *workers_to_move, unsigned nworkers_to_move, unsigned now);
+\def SC_HYPERVISOR_NULL
 \ingroup API_Scheduling_Context_Hypervisor
-    Moves workers from one context to another
+This macro is used when calling sc_hypervisor_ctl() and must be
+followed by 1 arguments
+
 
 \fn struct sc_hypervisor_policy_config *sc_hypervisor_get_config(unsigned sched_ctx);
 \ingroup API_Scheduling_Context_Hypervisor
-    Returns the configuration structure of a context
+Returns the configuration structure of a context
+
+\fn void sc_hypervisor_set_config(unsigned sched_ctx, void *config);
+\ingroup API_Scheduling_Context_Hypervisor
+Set a certain configuration to a contexts
 
 \fn int *sc_hypervisor_get_sched_ctxs();
 \ingroup API_Scheduling_Context_Hypervisor
@@ -297,8 +347,5 @@ struct sc_hypervisor_policy dummy_policy =
 \ingroup API_Scheduling_Context_Hypervisor
     Returns the flops of a context elapsed from the last resize
 
-\fn char *sc_hypervisor_get_policy();
-\ingroup API_Scheduling_Context_Hypervisor
-    Returns the name of the resizing policy the hypervisor uses
 
 */

+ 1 - 1
doc/doxygen/chapters/api/scheduling_contexts.doxy

@@ -203,7 +203,7 @@ Return the worker collection managed by the indicated context
 @name Scheduling Context Link with Hypervisor
 \ingroup API_Scheduling_Contexts
 
-\fn void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, struct starpu_sched_ctx_performance_counters *perf_counters)
+\fn void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, void *perf_counters)
 \ingroup API_Scheduling_Contexts
 Indicates to starpu the pointer to the performance counter
 

+ 23 - 0
doc/doxygen/chapters/scheduling_context_hypervisor.doxy

@@ -192,4 +192,27 @@ The <b>Throughput </b> strategy focuses on maximizing the throughput of the reso
 and resizes the contexts such that the machine is running at its maximum efficiency
 (maximum instant speed of the workers).
 
+\section  Defining a new hypervisor policy
+
+While Scheduling Context Hypervisor Plugin comes with a variety of
+resizing policies (see \ref ResizingStrategies), it may sometimes be
+desirable to implement custom policies to address specific problems.
+The API described below allows users to write their own resizing policy.
+
+Here an example of how to define a new policy
+
+\code{.c}
+struct sc_hypervisor_policy dummy_policy =
+{
+       .handle_poped_task = dummy_handle_poped_task,
+       .handle_pushed_task = dummy_handle_pushed_task,
+       .handle_idle_cycle = dummy_handle_idle_cycle,
+       .handle_idle_end = dummy_handle_idle_end,
+       .handle_post_exec_hook = dummy_handle_post_exec_hook,
+       .custom = 1,
+       .name = "dummy"
+};
+\endcode
+
+
 */

+ 4 - 20
include/starpu_sched_ctx.h

@@ -91,32 +91,16 @@ void starpu_sched_ctx_delete_worker_collection(unsigned sched_ctx_id);
 
 struct starpu_worker_collection *starpu_sched_ctx_get_worker_collection(unsigned sched_ctx_id);
 
-struct starpu_sched_ctx_performance_counters
-{
-	void (*notify_idle_cycle)(unsigned sched_ctx_id, int worker, double idle_time);
-	void (*notify_idle_end)(unsigned sched_ctx_id, int worker);
-	void (*notify_pushed_task)(unsigned sched_ctx_id, int worker);
-	void (*notify_poped_task)(unsigned sched_ctx_id, int worker, struct starpu_task *task, size_t data_size, uint32_t footprint);
-	void (*notify_post_exec_hook)(unsigned sched_ctx_id, int taskid);
-	void (*notify_submitted_job)(struct starpu_task *task, uint32_t footprint, size_t data_size);
-	void (*notify_delete_context)(unsigned sched_ctx);
-};
-
-#ifdef STARPU_USE_SC_HYPERVISOR
-void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, struct starpu_sched_ctx_performance_counters *perf_counters);
-void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id);
-#endif //STARPU_USE_SC_HYPERVISOR
-
-void starpu_sched_ctx_notify_hypervisor_exists(void);
-
-unsigned starpu_sched_ctx_check_if_hypervisor_exists(void);
-
 void starpu_sched_ctx_set_policy_data(unsigned sched_ctx_id, void *policy_data);
 
 void *starpu_sched_ctx_get_policy_data(unsigned sched_ctx_id);
 
 void *starpu_sched_ctx_exec_parallel_code(void* (*func)(void*), void *param, unsigned sched_ctx_id);
 
+#ifdef STARPU_USE_SC_HYPERVISOR
+void starpu_sched_ctx_call_pushed_task_cb(int workerid, unsigned sched_ctx_id);
+#endif //STARPU_USE_SC_HYPERVISOR
+
 #ifdef __cplusplus
 }
 #endif

+ 50 - 0
include/starpu_sched_ctx_hypervisor.h

@@ -0,0 +1,50 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2010 - 2012  INRIA
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#ifndef __STARPU_SCHED_CTX_HYPERVISOR_H__
+#define __STARPU_SCHED_CTX_HYPERVISOR_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+struct starpu_sched_ctx_performance_counters
+{
+	void (*notify_idle_cycle)(unsigned sched_ctx_id, int worker, double idle_time);
+	void (*notify_idle_end)(unsigned sched_ctx_id, int worker);
+	void (*notify_pushed_task)(unsigned sched_ctx_id, int worker);
+	void (*notify_poped_task)(unsigned sched_ctx_id, int worker, struct starpu_task *task, size_t data_size, uint32_t footprint);
+	void (*notify_post_exec_hook)(unsigned sched_ctx_id, int taskid);
+	void (*notify_submitted_job)(struct starpu_task *task, uint32_t footprint, size_t data_size);
+	void (*notify_delete_context)(unsigned sched_ctx);
+};
+
+#ifdef STARPU_USE_SC_HYPERVISOR
+void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, void* perf_counters);
+#endif //STARPU_USE_SC_HYPERVISOR
+
+void starpu_sched_ctx_notify_hypervisor_exists(void);
+
+unsigned starpu_sched_ctx_check_if_hypervisor_exists(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STARPU_SCHED_CTX_HYPERVISOR_H__ */

+ 2 - 2
sc_hypervisor/examples/app_driven_test/app_driven_test.c

@@ -138,8 +138,8 @@ int main()
 
 	/* let starpu know which performance counters should use 
 	   to inform the hypervisor how the application and the resources are executing */
-	starpu_sched_ctx_set_perf_counters(sched_ctx1, (struct starpu_sched_ctx_performance_counters*)perf_counters);
-	starpu_sched_ctx_set_perf_counters(sched_ctx2, (struct starpu_sched_ctx_performance_counters*)perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx1, perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx2, perf_counters);
 
 	/* register the contexts that should be managed by the hypervisor
 	   and indicate an approximate amount of workload if known;

+ 2 - 2
sc_hypervisor/examples/lp_test/lp_resize_test.c

@@ -99,8 +99,8 @@ int main()
 
 	/* let starpu know which performance counters should use 
 	   to inform the hypervisor how the application and the resources are executing */
-	starpu_sched_ctx_set_perf_counters(sched_ctx1, (struct starpu_sched_ctx_performance_counters*)perf_counters);
-	starpu_sched_ctx_set_perf_counters(sched_ctx2, (struct starpu_sched_ctx_performance_counters*)perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx1, perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx2, perf_counters);
 
 	double flops1 = NTASKS*NINCR*1000000000.0;
 	double flops2 = NTASKS*NINCR*1000000000.0;

+ 2 - 2
sc_hypervisor/examples/lp_test/lp_test.c

@@ -98,8 +98,8 @@ int main()
 
 	/* let starpu know which performance counters should use 
 	   to inform the hypervisor how the application and the resources are executing */
-	starpu_sched_ctx_set_perf_counters(sched_ctx1, (struct starpu_sched_ctx_performance_counters*)perf_counters);
-	starpu_sched_ctx_set_perf_counters(sched_ctx2, (struct starpu_sched_ctx_performance_counters*)perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx1, perf_counters);
+	starpu_sched_ctx_set_perf_counters(sched_ctx2, perf_counters);
 
 	double flops1 = NTASKS*NINCR*1000000000.0;
 	double flops2 = NTASKS*NINCR*1000000000.0;

+ 1 - 1
sc_hypervisor/examples/sched_ctx_utils/sched_ctx_utils.c

@@ -241,7 +241,7 @@ void construct_contexts(void (*bench)(float*, unsigned, unsigned))
 	struct sc_hypervisor_policy policy;
 	policy.custom = 0;
 	policy.name = "idle";
-	struct starpu_sched_ctx_performance_counters *perf_counters = sc_hypervisor_init(&policy);
+	void *perf_counters = sc_hypervisor_init(&policy);
 	int nworkers1 = cpu1 + gpu + gpu1;
 	int nworkers2 = cpu2 + gpu + gpu2;
 	unsigned n_all_gpus = gpu + gpu1 + gpu2;

+ 2 - 8
sc_hypervisor/include/sc_hypervisor.h

@@ -18,6 +18,7 @@
 #define SC_HYPERVISOR_H
 
 #include <starpu.h>
+#include <starpu_sched_ctx_hypervisor.h>
 #include <sc_hypervisor_config.h>
 #include <sc_hypervisor_monitoring.h>
 #include <math.h>
@@ -30,13 +31,6 @@ extern "C"
 /* synchronise the hypervisor when several workers try to update its information */
 starpu_pthread_mutex_t act_hypervisor_mutex;
 
-
-/* Forward declaration of an internal data structure
- * FIXME: Remove when no longer exposed.  */
-/* the resizing is not done instantly, a request is kept and executed 
-   when available */
-struct resize_request_entry;
-
 /* platform of resizing contexts */
 struct sc_hypervisor_policy
 {
@@ -75,7 +69,7 @@ struct sc_hypervisor_policy
 };
 
 /* start the hypervisor indicating the resizing policy to user */
-struct starpu_sched_ctx_performance_counters *sc_hypervisor_init(struct sc_hypervisor_policy *policy);
+void* sc_hypervisor_init(struct sc_hypervisor_policy *policy);
 
 /* shutdown the hypervisor */
 void sc_hypervisor_shutdown(void);

+ 3 - 7
sc_hypervisor/include/sc_hypervisor_config.h

@@ -35,10 +35,9 @@ extern "C"
 #define SC_HYPERVISOR_MIN_TASKS -8
 #define SC_HYPERVISOR_NEW_WORKERS_MAX_IDLE -9
 #define SC_HYPERVISOR_TIME_TO_APPLY -10
-#define SC_HYPERVISOR_EMPTY_CTX_MAX_IDLE -11
-#define SC_HYPERVISOR_NULL -12
-#define	SC_HYPERVISOR_ISPEED_W_SAMPLE -13
-#define SC_HYPERVISOR_ISPEED_CTX_SAMPLE -14
+#define SC_HYPERVISOR_NULL -11
+#define	SC_HYPERVISOR_ISPEED_W_SAMPLE -12
+#define SC_HYPERVISOR_ISPEED_CTX_SAMPLE -13
 
 
 #define MAX_IDLE_TIME 5000000000
@@ -72,9 +71,6 @@ struct sc_hypervisor_policy_config
 	/* max idle for the workers that will be added during the resizing process*/
 	double new_workers_max_idle;
 
-	/* above this context we allow removing all workers */
-	double empty_ctx_max_idle[STARPU_NMAXWORKERS];
-
 	/* sample used to compute the instant speed per worker*/
 	double ispeed_w_sample[STARPU_NMAXWORKERS];
 

+ 0 - 13
sc_hypervisor/src/sc_config.c

@@ -31,7 +31,6 @@ static struct sc_hypervisor_policy_config* _create_config(void)
 		config->priority[i] = -1;
 		config->fixed_workers[i] = -1;
 		config->max_idle[i] = -1.0;
-		config->empty_ctx_max_idle[i] = -1.0;
 		config->min_working[i] = -1.0;
 		config->ispeed_w_sample[i] = 0.0;
 	}
@@ -52,7 +51,6 @@ static void _update_config(struct sc_hypervisor_policy_config *old, struct sc_hy
 		old->priority[i] = new->priority[i] != -1 ? new->priority[i] : old->priority[i];
 		old->fixed_workers[i] = new->fixed_workers[i] != -1 ? new->fixed_workers[i] : old->fixed_workers[i];
 		old->max_idle[i] = new->max_idle[i] != -1.0 ? new->max_idle[i] : old->max_idle[i];
-		old->empty_ctx_max_idle[i] = new->empty_ctx_max_idle[i] != -1.0 ? new->empty_ctx_max_idle[i] : old->empty_ctx_max_idle[i];
 		old->min_working[i] = new->min_working[i] != -1.0 ? new->min_working[i] : old->min_working[i];
 	}
 }
@@ -85,7 +83,6 @@ void _add_config(unsigned sched_ctx)
 		config->priority[i] = 0;
 		config->fixed_workers[i] = 0;
 		config->max_idle[i] = MAX_IDLE_TIME;
-		config->empty_ctx_max_idle[i] = MAX_IDLE_TIME;
 		config->min_working[i] = MIN_WORKING_TIME;
 	}
 
@@ -131,16 +128,6 @@ static struct sc_hypervisor_policy_config* _ctl(unsigned sched_ctx, va_list varg
 
 			break;
 
-		case SC_HYPERVISOR_EMPTY_CTX_MAX_IDLE:
-			workerids = va_arg(varg_list, int*);
-			nworkers = va_arg(varg_list, int);
-			double empty_ctx_max_idle = va_arg(varg_list, double);
-
-			for(i = 0; i < nworkers; i++)
-				config->empty_ctx_max_idle[workerids[i]] = empty_ctx_max_idle;
-
-			break;
-
 		case SC_HYPERVISOR_MIN_WORKING:
 			workerids = va_arg(varg_list, int*);
 			nworkers = va_arg(varg_list, int);

+ 2 - 2
sc_hypervisor/src/sc_hypervisor.c

@@ -150,7 +150,7 @@ static struct sc_hypervisor_policy *_select_hypervisor_policy(struct sc_hypervis
 
 
 /* initializez the performance counters that starpu will use to retrive hints for resizing */
-struct starpu_sched_ctx_performance_counters* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
+void* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
 {	
 /* Perhaps we have to display some help */
 	display_sched_help_message();
@@ -220,7 +220,7 @@ struct starpu_sched_ctx_performance_counters* sc_hypervisor_init(struct sc_hyper
 
 	starpu_sched_ctx_notify_hypervisor_exists();
 
-	return perf_counters;
+	return (void*)perf_counters;
 }
 
 const char* sc_hypervisor_get_policy()

+ 14 - 0
sc_hypervisor/src/sc_hypervisor_intern.h

@@ -45,6 +45,20 @@ struct resize_request_entry
 	UT_hash_handle hh;
 };
 
+/* structure to indicate when the moving of workers was actually done 
+   (moved workers can be seen in the new ctx ) */
+struct resize_ack
+{
+	/* receiver context */
+	int receiver_sched_ctx;
+	/* list of workers required to be moved */
+	int *moved_workers;
+	/* number of workers required to be moved */
+	int nmoved_workers;
+	/* list of workers that actually got in the receiver ctx */
+	int *acked_workers;
+};
+
 struct configuration_entry
 {
 	/* Key: the tag of tasks concerned by this configuration.  */

+ 2 - 2
src/core/sched_ctx.c

@@ -508,10 +508,10 @@ unsigned starpu_sched_ctx_create_with_custom_policy(struct starpu_sched_policy *
 }
 
 #ifdef STARPU_USE_SC_HYPERVISOR
-void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, struct starpu_sched_ctx_performance_counters *perf_counters)
+void starpu_sched_ctx_set_perf_counters(unsigned sched_ctx_id, void* perf_counters)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	sched_ctx->perf_counters = perf_counters;
+	sched_ctx->perf_counters = (struct starpu_sched_ctx_performance_counters *)perf_counters;
 	return;
 }
 #endif

+ 1 - 0
src/core/sched_ctx.h

@@ -19,6 +19,7 @@
 
 #include <starpu.h>
 #include <starpu_sched_ctx.h>
+#include <starpu_sched_ctx_hypervisor.h>
 #include <starpu_scheduler.h>
 #include <common/config.h>
 #include <common/barrier_counter.h>