|
@@ -170,88 +170,12 @@ static void teft_lp_handle_submitted_job(struct starpu_codelet *cl, unsigned sch
|
|
{
|
|
{
|
|
/* count the tasks of the same type */
|
|
/* count the tasks of the same type */
|
|
starpu_pthread_mutex_lock(&mutex);
|
|
starpu_pthread_mutex_lock(&mutex);
|
|
- struct sc_hypervisor_policy_task_pool *tp = NULL;
|
|
|
|
-
|
|
|
|
- for (tp = task_pools; tp; tp = tp->next)
|
|
|
|
- {
|
|
|
|
- if (tp && tp->cl == cl && tp->footprint == footprint && tp->sched_ctx_id == sched_ctx)
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!tp)
|
|
|
|
- {
|
|
|
|
- tp = (struct sc_hypervisor_policy_task_pool *) malloc(sizeof(struct sc_hypervisor_policy_task_pool));
|
|
|
|
- tp->cl = cl;
|
|
|
|
- tp->footprint = footprint;
|
|
|
|
- tp->sched_ctx_id = sched_ctx;
|
|
|
|
- tp->n = 0;
|
|
|
|
- tp->next = task_pools;
|
|
|
|
- task_pools = tp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* One more task of this kind */
|
|
|
|
- tp->n++;
|
|
|
|
|
|
+ sc_hypervisor_policy_add_task_to_pool(cl, sched_ctx, footprint, task_pools);
|
|
starpu_pthread_mutex_unlock(&mutex);
|
|
starpu_pthread_mutex_unlock(&mutex);
|
|
|
|
|
|
size_if_required();
|
|
size_if_required();
|
|
}
|
|
}
|
|
|
|
|
|
-static void _remove_task_from_pool(struct starpu_task *task, uint32_t footprint)
|
|
|
|
-{
|
|
|
|
- /* count the tasks of the same type */
|
|
|
|
- struct sc_hypervisor_policy_task_pool *tp = NULL;
|
|
|
|
-
|
|
|
|
- for (tp = task_pools; tp; tp = tp->next)
|
|
|
|
- {
|
|
|
|
- if (tp && tp->cl == task->cl && tp->footprint == footprint && tp->sched_ctx_id == task->sched_ctx)
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (tp)
|
|
|
|
- {
|
|
|
|
- if(tp->n > 1)
|
|
|
|
- tp->n--;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if(tp == task_pools)
|
|
|
|
- {
|
|
|
|
- struct sc_hypervisor_policy_task_pool *next_tp = NULL;
|
|
|
|
- if(task_pools->next)
|
|
|
|
- next_tp = task_pools->next;
|
|
|
|
-
|
|
|
|
- free(tp);
|
|
|
|
- tp = NULL;
|
|
|
|
-
|
|
|
|
- if(next_tp)
|
|
|
|
- task_pools = next_tp;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- struct sc_hypervisor_policy_task_pool *prev_tp = NULL;
|
|
|
|
- for (prev_tp = task_pools; prev_tp; prev_tp = prev_tp->next)
|
|
|
|
- {
|
|
|
|
- if (prev_tp->next == tp)
|
|
|
|
- prev_tp->next = tp->next;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- free(tp);
|
|
|
|
- tp = NULL;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static struct sc_hypervisor_policy_task_pool* _clone_linked_list(struct sc_hypervisor_policy_task_pool *tp)
|
|
|
|
-{
|
|
|
|
- if(tp == NULL) return NULL;
|
|
|
|
-
|
|
|
|
- struct sc_hypervisor_policy_task_pool *tmp_tp = (struct sc_hypervisor_policy_task_pool*)malloc(sizeof(struct sc_hypervisor_policy_task_pool));
|
|
|
|
- memcpy(tmp_tp, tp, sizeof(struct sc_hypervisor_policy_task_pool));
|
|
|
|
- tmp_tp->next = _clone_linked_list(tp->next);
|
|
|
|
- return tmp_tp;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static void _get_tasks_times(int nw, int nt, double times[nw][nt], int *workers, unsigned size_ctxs)
|
|
static void _get_tasks_times(int nw, int nt, double times[nw][nt], int *workers, unsigned size_ctxs)
|
|
{
|
|
{
|
|
struct sc_hypervisor_policy_task_pool *tp;
|
|
struct sc_hypervisor_policy_task_pool *tp;
|
|
@@ -554,7 +478,7 @@ static void teft_lp_handle_poped_task(unsigned sched_ctx, int worker, struct sta
|
|
submitted task will change during the exec */
|
|
submitted task will change during the exec */
|
|
|
|
|
|
struct sc_hypervisor_policy_task_pool *tp = NULL;
|
|
struct sc_hypervisor_policy_task_pool *tp = NULL;
|
|
- struct sc_hypervisor_policy_task_pool *tmp_task_pools = _clone_linked_list(task_pools);
|
|
|
|
|
|
+ struct sc_hypervisor_policy_task_pool *tmp_task_pools = sc_hypervisor_policy_clone_task_pool(task_pools);
|
|
|
|
|
|
for (tp = task_pools; tp; tp = tp->next)
|
|
for (tp = task_pools; tp; tp = tp->next)
|
|
nt++;
|
|
nt++;
|
|
@@ -586,7 +510,7 @@ static void teft_lp_handle_poped_task(unsigned sched_ctx, int worker, struct sta
|
|
}
|
|
}
|
|
/* too expensive to take this mutex and correct value of the number of tasks is not compulsory */
|
|
/* too expensive to take this mutex and correct value of the number of tasks is not compulsory */
|
|
// starpu_pthread_mutex_lock(&mutex);
|
|
// starpu_pthread_mutex_lock(&mutex);
|
|
- _remove_task_from_pool(task, footprint);
|
|
|
|
|
|
+ sc_hypervisor_policy_remove_task_from_pool(task, footprint, task_pools);
|
|
// starpu_pthread_mutex_unlock(&mutex);
|
|
// starpu_pthread_mutex_unlock(&mutex);
|
|
|
|
|
|
}
|
|
}
|