Browse Source

Add starpu_sched_task_break callable from external schedulers instead of _STARPU_TASK_BREAK_ON

Samuel Thibault 7 years ago
parent
commit
daceb77c56

+ 7 - 0
doc/doxygen/chapters/api/scheduling_policy.doxy

@@ -266,4 +266,11 @@ started and we know how long it will take.
 The scheduling policies indicates if the worker may pop tasks from the list of other workers
 The scheduling policies indicates if the worker may pop tasks from the list of other workers
 or if there is a central list with task for all the workers
 or if there is a central list with task for all the workers
 
 
+\fn void starpu_sched_break(struct starpu_task *task)
+\ingroup API_Scheduling_Policy
+This should be called just after a scheduling decision for task \p task was
+made. It will raise SIGTRAP if the ::STARPU_TASK_BREAK_ON_SCHED environment
+variable was used, which thus breakpoints inside a debugger, thus allowing to
+inspect why that scheduling decision was made.
+
 */
 */

+ 2 - 0
include/starpu_scheduler.h

@@ -101,6 +101,8 @@ void starpu_task_notify_ready_soon_register(starpu_notify_ready_soon_func f, voi
 
 
 void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id);
 void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id);
 
 
+void starpu_sched_task_break(struct starpu_task *task);
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 6 - 1
src/core/sched_policy.c

@@ -2,7 +2,7 @@
  *
  *
  * Copyright (C) 2011-2017                                Inria
  * Copyright (C) 2011-2017                                Inria
  * Copyright (C) 2013                                     Simon Archipoff
  * Copyright (C) 2013                                     Simon Archipoff
- * Copyright (C) 2008-2017                                Université de Bordeaux
+ * Copyright (C) 2008-2018                                Université de Bordeaux
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2016                                     Uppsala University
  * Copyright (C) 2016                                     Uppsala University
@@ -1163,3 +1163,8 @@ void _starpu_print_idle_time()
 		fclose(f);
 		fclose(f);
 	}
 	}
 }
 }
+
+void starpu_sched_task_break(struct starpu_task *task)
+{
+	_STARPU_TASK_BREAK_ON(task, sched);
+}

+ 1 - 1
src/sched_policies/component_heft.c

@@ -166,7 +166,7 @@ static int heft_progress_one(struct starpu_sched_component *component)
 			return 1;
 			return 1;
 		}
 		}
 
 
-		_STARPU_TASK_BREAK_ON(tasks[best_task], sched);
+		starpu_sched_task_break(tasks[best_task]);
 		int ret = starpu_sched_component_push_task(component, best_component, tasks[best_task]);
 		int ret = starpu_sched_component_push_task(component, best_component, tasks[best_task]);
 
 
 		if (ret)
 		if (ret)

+ 1 - 1
src/sched_policies/component_mct.c

@@ -117,7 +117,7 @@ static int mct_push_task(struct starpu_sched_component * component, struct starp
 		return 1;
 		return 1;
 	}
 	}
 
 
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	int ret = starpu_sched_component_push_task(component, best_component, task);
 	int ret = starpu_sched_component_push_task(component, best_component, task);
 
 
 	/* I can now exit the critical section: Pushing the task below ensures that its execution
 	/* I can now exit the critical section: Pushing the task below ensures that its execution

+ 1 - 1
src/sched_policies/component_random.c

@@ -94,7 +94,7 @@ static int random_push_task(struct starpu_sched_component * component, struct st
 		return 1;
 		return 1;
 	}
 	}
 
 
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	int ret_val = starpu_sched_component_push_task(component,select,task);
 	int ret_val = starpu_sched_component_push_task(component,select,task);
 	return ret_val;
 	return ret_val;
 }
 }

+ 2 - 2
src/sched_policies/component_work_stealing.c

@@ -69,7 +69,7 @@ static struct starpu_task *  steal_task_round_robin(struct starpu_sched_componen
 		STARPU_COMPONENT_MUTEX_UNLOCK(wsd->mutexes[i]);
 		STARPU_COMPONENT_MUTEX_UNLOCK(wsd->mutexes[i]);
 		if(task)
 		if(task)
 		{
 		{
-			_STARPU_TASK_BREAK_ON(task, sched);
+			starpu_sched_task_break(task);
 			break;
 			break;
 		}
 		}
 
 
@@ -236,7 +236,7 @@ static int push_task(struct starpu_sched_component * component, struct starpu_ta
 	unsigned i = wsd->last_push_child;
 	unsigned i = wsd->last_push_child;
 	i = (i+1)%component->nchildren;
 	i = (i+1)%component->nchildren;
 	STARPU_COMPONENT_MUTEX_LOCK(wsd->mutexes[i]);
 	STARPU_COMPONENT_MUTEX_LOCK(wsd->mutexes[i]);
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	ret = _starpu_prio_deque_push_task(wsd->fifos[i], task);
 	ret = _starpu_prio_deque_push_task(wsd->fifos[i], task);
 	STARPU_COMPONENT_MUTEX_UNLOCK(wsd->mutexes[i]);
 	STARPU_COMPONENT_MUTEX_UNLOCK(wsd->mutexes[i]);
 
 

+ 2 - 2
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -626,7 +626,7 @@ static int _dm_push_task(struct starpu_task *task, unsigned prio, unsigned sched
 
 
 	starpu_task_set_implementation(task, best_impl);
 	starpu_task_set_implementation(task, best_impl);
 
 
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	/* we should now have the best worker in variable "best" */
 	/* we should now have the best worker in variable "best" */
 	return push_task_on_best_worker(task, best,
 	return push_task_on_best_worker(task, best,
 					model_best, transfer_model_best, prio, sched_ctx_id);
 					model_best, transfer_model_best, prio, sched_ctx_id);
@@ -939,7 +939,7 @@ static double _dmda_push_task(struct starpu_task *task, unsigned prio, unsigned
 	//_STARPU_DEBUG("Scheduler dmda: kernel (%u)\n", best_impl);
 	//_STARPU_DEBUG("Scheduler dmda: kernel (%u)\n", best_impl);
 	starpu_task_set_implementation(task, selected_impl);
 	starpu_task_set_implementation(task, selected_impl);
 
 
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	if(!simulate)
 	if(!simulate)
 	{
 	{
 		/* we should now have the best worker in variable "best" */
 		/* we should now have the best worker in variable "best" */

+ 1 - 1
src/sched_policies/parallel_heft.c

@@ -485,7 +485,7 @@ static int _parallel_heft_push_task(struct starpu_task *task, unsigned prio, uns
 	//_STARPU_DEBUG("Scheduler parallel heft: kernel (%u)\n", nimpl_best);
 	//_STARPU_DEBUG("Scheduler parallel heft: kernel (%u)\n", nimpl_best);
 	starpu_task_set_implementation(task, nimpl_best);
 	starpu_task_set_implementation(task, nimpl_best);
 	/* we should now have the best workerid in variable "best" */
 	/* we should now have the best workerid in variable "best" */
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	return push_task_on_best_worker(task, best, best_exp_end, prio, sched_ctx_id);
 	return push_task_on_best_worker(task, best, best_exp_end, prio, sched_ctx_id);
 }
 }
 
 

+ 1 - 1
src/sched_policies/random_policy.c

@@ -82,7 +82,7 @@ static int _random_push_task(struct starpu_task *task, unsigned prio)
 		alpha += worker_alpha;
 		alpha += worker_alpha;
 	}
 	}
 	STARPU_AYU_ADDTOTASKQUEUE(starpu_task_get_job_id(task), selected);
 	STARPU_AYU_ADDTOTASKQUEUE(starpu_task_get_job_id(task), selected);
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	return starpu_push_local_task(selected, task, prio);
 	return starpu_push_local_task(selected, task, prio);
 }
 }
 
 

+ 2 - 2
src/sched_policies/work_stealing_policy.c

@@ -584,7 +584,7 @@ static struct starpu_task *ws_pop_task(unsigned sched_ctx_id)
 	if (task)
 	if (task)
 	{
 	{
 		_STARPU_TRACE_WORK_STEALING(workerid, victim);
 		_STARPU_TRACE_WORK_STEALING(workerid, victim);
-		_STARPU_TASK_BREAK_ON(task, sched);
+		starpu_sched_task_break(task);
 		starpu_sched_ctx_list_task_counters_decrement(sched_ctx_id, victim);
 		starpu_sched_ctx_list_task_counters_decrement(sched_ctx_id, victim);
 		record_data_locality(task, workerid);
 		record_data_locality(task, workerid);
 		record_worker_locality(ws, task, workerid, sched_ctx_id);
 		record_worker_locality(ws, task, workerid, sched_ctx_id);
@@ -652,7 +652,7 @@ int ws_push_task(struct starpu_task *task)
 		workerid = select_worker(ws, task, sched_ctx_id);
 		workerid = select_worker(ws, task, sched_ctx_id);
 	_starpu_worker_lock(workerid);
 	_starpu_worker_lock(workerid);
 	STARPU_AYU_ADDTOTASKQUEUE(starpu_task_get_job_id(task), workerid);
 	STARPU_AYU_ADDTOTASKQUEUE(starpu_task_get_job_id(task), workerid);
-	_STARPU_TASK_BREAK_ON(task, sched);
+	starpu_sched_task_break(task);
 	record_data_locality(task, workerid);
 	record_data_locality(task, workerid);
 	STARPU_ASSERT_MSG(ws->per_worker[workerid].running, "workerid=%d, ws=%p\n", workerid, ws);
 	STARPU_ASSERT_MSG(ws->per_worker[workerid].running, "workerid=%d, ws=%p\n", workerid, ws);
 	_starpu_prio_deque_push_task(&ws->per_worker[workerid].queue, task);
 	_starpu_prio_deque_push_task(&ws->per_worker[workerid].queue, task);