Procházet zdrojové kódy

update and reenable remaining modular policies

Olivier Aumage před 8 roky
rodič
revize
396e9cc76b
2 změnil soubory, kde provedl 21 přidání a 7 odebrání
  1. 3 7
      src/core/sched_policy.c
  2. 18 0
      src/sched_policies/component_heft.c

+ 3 - 7
src/core/sched_policy.c

@@ -52,11 +52,6 @@ int starpu_get_prefetch_flag(void)
 
 static struct starpu_sched_policy *predefined_policies[] =
 {
-#if 0
-	&_starpu_sched_modular_heft_policy,
-	&_starpu_sched_modular_heft_prio_policy,
-	&_starpu_sched_modular_heft2_policy,
-#else
 	&_starpu_sched_modular_eager_policy,
 	&_starpu_sched_modular_eager_prefetching_policy,
 	&_starpu_sched_modular_prio_policy,
@@ -66,6 +61,9 @@ static struct starpu_sched_policy *predefined_policies[] =
 	&_starpu_sched_modular_random_prefetching_policy,
 	&_starpu_sched_modular_random_prio_prefetching_policy,
 	&_starpu_sched_modular_ws_policy,
+	&_starpu_sched_modular_heft_policy,
+	&_starpu_sched_modular_heft_prio_policy,
+	&_starpu_sched_modular_heft2_policy,
 	&_starpu_sched_eager_policy,
 	&_starpu_sched_prio_policy,
 	&_starpu_sched_random_policy,
@@ -80,8 +78,6 @@ static struct starpu_sched_policy *predefined_policies[] =
 	&_starpu_sched_dmda_sorted_policy,
 	&_starpu_sched_dmda_sorted_decision_policy,
 	&_starpu_sched_graph_test_policy,
-#warning TODO: update sched policies with new synchro scheme
-#endif
 	NULL
 };
 

+ 18 - 0
src/sched_policies/component_heft.c

@@ -46,7 +46,12 @@ static int heft_progress_one(struct starpu_sched_component *component)
 	struct starpu_task * (tasks[NTASKS]);
 	unsigned ntasks;
 
+	const int relaxed_state = _starpu_worker_get_observation_safe_state();
+	if (!relaxed_state)
+		_starpu_worker_enter_section_safe_for_observation();
 	STARPU_PTHREAD_MUTEX_LOCK(mutex);
+	if (!relaxed_state)
+		_starpu_worker_leave_section_safe_for_observation();
 	/* Try to look at NTASKS from the queue */
 	for (ntasks = 0; ntasks < NTASKS; ntasks++)
 	{
@@ -116,7 +121,11 @@ static int heft_progress_one(struct starpu_sched_component *component)
 		int best_icomponent = -1;
 
 		/* Push back the other tasks */
+		if (!relaxed_state)
+			_starpu_worker_enter_section_safe_for_observation();
 		STARPU_PTHREAD_MUTEX_LOCK(mutex);
+		if (!relaxed_state)
+			_starpu_worker_leave_section_safe_for_observation();
 		for (n = ntasks - 1; n < ntasks; n--)
 			if ((int) n != best_task)
 				_starpu_prio_deque_push_back_task(prio, tasks[n]);
@@ -161,7 +170,11 @@ static int heft_progress_one(struct starpu_sched_component *component)
 		if (ret)
 		{
 			/* Could not push to child actually, push that one back too */
+			if (!relaxed_state)
+				_starpu_worker_enter_section_safe_for_observation();
 			STARPU_PTHREAD_MUTEX_LOCK(mutex);
+			if (!relaxed_state)
+				_starpu_worker_leave_section_safe_for_observation();
 			_starpu_prio_deque_push_back_task(prio, tasks[best_task]);
 			STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
 			return 1;
@@ -186,7 +199,12 @@ static int heft_push_task(struct starpu_sched_component * component, struct star
 	struct _starpu_prio_deque * prio = &data->prio;
 	starpu_pthread_mutex_t * mutex = &data->mutex;
 
+	const int relaxed_state = _starpu_worker_get_observation_safe_state();
+	if (!relaxed_state)
+		_starpu_worker_enter_section_safe_for_observation();
 	STARPU_PTHREAD_MUTEX_LOCK(mutex);
+	if (!relaxed_state)
+		_starpu_worker_leave_section_safe_for_observation();
 	_starpu_prio_deque_push_task(prio,task);
 	STARPU_PTHREAD_MUTEX_UNLOCK(mutex);