|
@@ -20,13 +20,14 @@
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
#ifdef STARPU_HAVE_GLPK_H
|
|
|
-static void _try_resizing(void)
|
|
|
+static void _try_resizing(int *sched_ctxs, int nsched_ctxs)
|
|
|
{
|
|
|
/* for vite */
|
|
|
starpu_trace_user_event(2);
|
|
|
+ int ns = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : nsched_ctxs;
|
|
|
+ sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
|
|
|
|
|
|
- int nsched_ctxs = sc_hypervisor_get_nsched_ctxs();
|
|
|
- double nworkers[nsched_ctxs][2];
|
|
|
+ double nworkers_per_ctx[ns][2];
|
|
|
int nw = 1;
|
|
|
#ifdef STARPU_USE_CUDA
|
|
|
int ncuda = starpu_worker_get_count_by_type(STARPU_CUDA_WORKER);
|
|
@@ -40,7 +41,7 @@ static void _try_resizing(void)
|
|
|
struct timeval end_time;
|
|
|
gettimeofday(&start_time, NULL);
|
|
|
|
|
|
- double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(nsched_ctxs, nw, nworkers, total_nw);
|
|
|
+ double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(ns, nw, nworkers_per_ctx, total_nw);
|
|
|
gettimeofday(&end_time, NULL);
|
|
|
|
|
|
long diff_s = end_time.tv_sec - start_time.tv_sec;
|
|
@@ -50,13 +51,14 @@ static void _try_resizing(void)
|
|
|
|
|
|
if(vmax != 0.0)
|
|
|
{
|
|
|
- int nworkers_rounded[nsched_ctxs][nw];
|
|
|
- sc_hypervisor_lp_round_double_to_int(nsched_ctxs, nw, nworkers, nworkers_rounded);
|
|
|
- sc_hypervisor_lp_redistribute_resources_in_ctxs(nsched_ctxs, nw, nworkers_rounded, nworkers);
|
|
|
+ int nworkers_per_ctx_rounded[nsched_ctxs][nw];
|
|
|
+ sc_hypervisor_lp_round_double_to_int(ns, nw, nworkers_per_ctx, nworkers_per_ctx_rounded);
|
|
|
+ sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, nw, nworkers_per_ctx_rounded, nworkers_per_ctx, sched_ctxs);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-static void feft_lp_handle_poped_task(unsigned sched_ctx, int worker, struct starpu_task *task, uint32_t footprint)
|
|
|
+
|
|
|
+static void feft_lp_handle_poped_task(__attribute__((unused))unsigned sched_ctx, __attribute__((unused))int worker,
|
|
|
+ __attribute__((unused))struct starpu_task *task, __attribute__((unused))uint32_t footprint)
|
|
|
{
|
|
|
int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
|
|
|
if(ret != EBUSY)
|
|
@@ -66,27 +68,27 @@ static void feft_lp_handle_poped_task(unsigned sched_ctx, int worker, struct sta
|
|
|
{
|
|
|
if(sc_hypervisor_check_speed_gap_btw_ctxs())
|
|
|
{
|
|
|
- _try_resizing();
|
|
|
+ _try_resizing(NULL, -1);
|
|
|
}
|
|
|
}
|
|
|
starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-static void feft_lp_size_ctxs(int *sched_ctxs, int ns, int *workers, int nworkers)
|
|
|
+static void feft_lp_size_ctxs(int *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
|
|
|
{
|
|
|
- int nsched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : ns;
|
|
|
+ int ns = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : nsched_ctxs;
|
|
|
int nw = 1;
|
|
|
#ifdef STARPU_USE_CUDA
|
|
|
int ncuda = starpu_worker_get_count_by_type(STARPU_CUDA_WORKER);
|
|
|
nw = ncuda != 0 ? 2 : 1;
|
|
|
#endif
|
|
|
- double nworkers_per_type[nsched_ctxs][nw];
|
|
|
+ double nworkers_per_type[ns][nw];
|
|
|
int total_nw[nw];
|
|
|
sc_hypervisor_group_workers_by_type(workers, nworkers, nw, total_nw);
|
|
|
|
|
|
starpu_pthread_mutex_lock(&act_hypervisor_mutex);
|
|
|
- double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(nsched_ctxs, nw, nworkers_per_type, total_nw);
|
|
|
+ double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(ns, nw, nworkers_per_type, total_nw);
|
|
|
if(vmax != 0.0)
|
|
|
{
|
|
|
// printf("********size\n");
|
|
@@ -100,8 +102,8 @@ static void feft_lp_size_ctxs(int *sched_ctxs, int ns, int *workers, int nworker
|
|
|
/* printf("ctx %d/worker type %d: n = %lf \n", i, 1, nworkers_per_type[i][1]); */
|
|
|
/* #endif */
|
|
|
/* } */
|
|
|
- int nworkers_per_type_rounded[nsched_ctxs][nw];
|
|
|
- sc_hypervisor_lp_round_double_to_int(nsched_ctxs, nw, nworkers_per_type, nworkers_per_type_rounded);
|
|
|
+ int nworkers_per_type_rounded[ns][nw];
|
|
|
+ sc_hypervisor_lp_round_double_to_int(ns, nw, nworkers_per_type, nworkers_per_type_rounded);
|
|
|
/* for( i = 0; i < nsched_ctxs; i++) */
|
|
|
/* { */
|
|
|
/* printf("ctx %d/worker type %d: n = %d \n", i, 0, nworkers_per_type_rounded[i][0]); */
|
|
@@ -125,14 +127,14 @@ static void feft_lp_size_ctxs(int *sched_ctxs, int ns, int *workers, int nworker
|
|
|
}
|
|
|
}
|
|
|
if(has_workers)
|
|
|
- sc_hypervisor_lp_redistribute_resources_in_ctxs(nsched_ctxs, nw, nworkers_per_type_rounded, nworkers_per_type);
|
|
|
+ sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, nw, nworkers_per_type_rounded, nworkers_per_type, current_sched_ctxs);
|
|
|
else
|
|
|
- sc_hypervisor_lp_distribute_resources_in_ctxs(sched_ctxs, nsched_ctxs, nw, nworkers_per_type_rounded, nworkers_per_type, workers, nworkers);
|
|
|
+ sc_hypervisor_lp_distribute_resources_in_ctxs(sched_ctxs, ns, nw, nworkers_per_type_rounded, nworkers_per_type, workers, nworkers);
|
|
|
}
|
|
|
starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
|
|
|
}
|
|
|
|
|
|
-static feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
|
|
|
+static void feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
|
|
|
{
|
|
|
int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
|
|
|
if(ret != EBUSY)
|
|
@@ -143,7 +145,7 @@ static feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
|
|
|
|
|
|
if(sc_hypervisor_check_idle(sched_ctx, worker))
|
|
|
{
|
|
|
- _try_resizing();
|
|
|
+ _try_resizing(NULL, -1);
|
|
|
// sc_hypervisor_move_workers(sched_ctx, 3 - sched_ctx, &worker, 1, 1);
|
|
|
}
|
|
|
}
|
|
@@ -151,8 +153,33 @@ static feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void feft_lp_resize_ctxs(int *sched_ctxs, int nsched_ctxs ,
|
|
|
+ __attribute__((unused))int *workers, __attribute__((unused))int nworkers)
|
|
|
+{
|
|
|
+ int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
|
|
|
+ if(ret != EBUSY)
|
|
|
+ {
|
|
|
+ struct sc_hypervisor_wrapper* sc_w = NULL;
|
|
|
+ int s = 0;
|
|
|
+ for(s = 0; s < nsched_ctxs; s++)
|
|
|
+ {
|
|
|
+ sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
|
|
|
+
|
|
|
+ if((sc_w->submitted_flops + (0.1*sc_w->total_flops)) < sc_w->total_flops)
|
|
|
+ {
|
|
|
+ starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _try_resizing(sched_ctxs, nsched_ctxs);
|
|
|
+ starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
struct sc_hypervisor_policy feft_lp_policy = {
|
|
|
.size_ctxs = feft_lp_size_ctxs,
|
|
|
+ .resize_ctxs = feft_lp_resize_ctxs,
|
|
|
.handle_poped_task = feft_lp_handle_poped_task,
|
|
|
.handle_pushed_task = NULL,
|
|
|
.handle_idle_cycle = feft_lp_handle_idle_cycle, //NULL,
|