static int push_task_dummy(struct starpu_task *task) { pthread_mutex_lock(&sched_mutex); starpu_task_list_push_front(&sched_list, task); pthread_cond_signal(&sched_cond); pthread_mutex_unlock(&sched_mutex); }
static int push_task_dummy(struct starpu_task *task) { unsigned sched_ctx_id = task->sched_ctx; struct dummy_sched_data *data = (struct dummy_sched_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id); /* NB: In this simplistic strategy, we assume that the context in which we push task has at least one worker*/ /* lock all workers when pushing tasks on a list where all of them would pop for tasks */ starpu_pthread_mutex_lock(&data->policy_mutex); starpu_task_list_push_front(&data->sched_list, task); starpu_push_task_end(task); starpu_pthread_mutex_unlock(&data->policy_mutex); /*if there are no tasks block */ /* wake people waiting for a task */ unsigned worker = 0; struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id); struct starpu_sched_ctx_iterator it; workers->init_iterator(workers, &it); while(workers->has_next(workers, &it)) { worker = workers->get_next(workers, &it); starpu_pthread_mutex_t *sched_mutex; starpu_pthread_cond_t *sched_cond; starpu_worker_get_sched_condition(worker, &sched_mutex, &sched_cond); starpu_pthread_mutex_lock(sched_mutex); starpu_pthread_cond_signal(sched_cond); starpu_pthread_mutex_unlock(sched_mutex); } return 0; }
int _starpu_repush_task(struct _starpu_job *j) { struct starpu_task *task = j->task; struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(task->sched_ctx); unsigned nworkers = 0; int ret; _STARPU_LOG_IN(); unsigned can_push = _starpu_increment_nready_tasks_of_sched_ctx(task->sched_ctx, task->flops, task); task->status = STARPU_TASK_READY; #ifdef HAVE_AYUDAME_H if (AYU_event) { intptr_t id = -1; AYU_event(AYU_ADDTASKTOQUEUE, j->job_id, &id); } #endif /* if the context does not have any workers save the tasks in a temp list */ if(!sched_ctx->is_initial_sched) { /*if there are workers in the ctx that are not able to execute tasks we consider the ctx empty */ nworkers = _starpu_nworkers_able_to_execute_task(task, sched_ctx); if(nworkers == 0) { STARPU_PTHREAD_MUTEX_LOCK(&sched_ctx->empty_ctx_mutex); starpu_task_list_push_front(&sched_ctx->empty_ctx_tasks, task); STARPU_PTHREAD_MUTEX_UNLOCK(&sched_ctx->empty_ctx_mutex); #ifdef STARPU_USE_SC_HYPERVISOR if(sched_ctx != NULL && sched_ctx->id != 0 && sched_ctx->perf_counters != NULL && sched_ctx->perf_counters->notify_empty_ctx) { _STARPU_TRACE_HYPERVISOR_BEGIN(); sched_ctx->perf_counters->notify_empty_ctx(sched_ctx->id, task); _STARPU_TRACE_HYPERVISOR_END(); } #endif return 0; } } if(!can_push) return 0; /* in case there is no codelet associated to the task (that's a control * task), we directly execute its callback and enforce the * corresponding dependencies */ if (task->cl == NULL || task->cl->where == STARPU_NOWHERE) { if (task->prologue_callback_pop_func) task->prologue_callback_pop_func(task->prologue_callback_pop_arg); if (task->cl && task->cl->specific_nodes) { /* Nothing to do, but we are asked to fetch data on some memory nodes */ _starpu_fetch_nowhere_task_input(j); } else { if (task->cl) __starpu_push_task_output(j); _starpu_handle_job_termination(j); _STARPU_LOG_OUT_TAG("handle_job_termination"); } return 0; } ret = _starpu_push_task_to_workers(task); if (ret == -EAGAIN) /* pushed to empty context, that's fine */ ret = 0; return ret; }