Quellcode durchsuchen

add some missing relax_on calls

Olivier Aumage vor 8 Jahren
Ursprung
Commit
684ce2448c

+ 1 - 0
include/starpu_sched_ctx.h

@@ -134,6 +134,7 @@ void starpu_sched_ctx_list_task_counters_decrement(unsigned sched_ctx_id, int wo
 void starpu_sched_ctx_list_task_counters_reset(unsigned sched_ctx_id, int workerid);
 
 void starpu_sched_ctx_list_task_counters_increment_all(struct starpu_task *task, unsigned sched_ctx_id);
+void starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(struct starpu_task *task, unsigned sched_ctx_id);
 
 void starpu_sched_ctx_list_task_counters_decrement_all(struct starpu_task *task, unsigned sched_ctx_id);
 void starpu_sched_ctx_list_task_counters_decrement_all_ctx_locked(struct starpu_task *task, unsigned sched_ctx_id);

+ 20 - 0
src/core/sched_ctx.c

@@ -2412,6 +2412,26 @@ void starpu_sched_ctx_list_task_counters_reset(unsigned sched_ctx_id, int worker
 		_starpu_sched_ctx_list_pop_all_event(worker->sched_ctx_list, sched_ctx_id);
 }
 
+void starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(struct starpu_task *task, unsigned sched_ctx_id)
+{
+	/* TODO: add proper, but light-enough locking to sched_ctx counters */
+
+	/* Note that with 1 ctx we will default to the global context,
+	   hence our counters are useless */
+	if (_starpu_get_nsched_ctxs() > 1)
+	{
+		struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
+		struct starpu_sched_ctx_iterator it;
+
+		workers->init_iterator_for_parallel_tasks(workers, &it, task);
+		while(workers->has_next(workers, &it))
+		{
+			int worker = workers->get_next(workers, &it);
+			starpu_sched_ctx_list_task_counters_increment(sched_ctx_id, worker);
+		}
+	}
+}
+
 void starpu_sched_ctx_list_task_counters_increment_all(struct starpu_task *task, unsigned sched_ctx_id)
 {
 	/* TODO: add proper, but light-enough locking to sched_ctx counters */

+ 8 - 1
src/sched_policies/eager_central_policy.c

@@ -132,7 +132,14 @@ static int push_task_eager_policy(struct starpu_task *task)
 	}
 #endif
 
-	starpu_sched_ctx_list_task_counters_increment_all(task, sched_ctx_id);
+	if (_starpu_get_nsched_ctxs() > 1)
+	{
+		_starpu_worker_relax_on();
+		_starpu_sched_ctx_lock_write(sched_ctx_id);
+		_starpu_worker_relax_off();
+		starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(task, sched_ctx_id);
+		_starpu_sched_ctx_unlock_write(sched_ctx_id);
+	}
 
 	return 0;
 }

+ 9 - 1
src/sched_policies/eager_central_priority_policy.c

@@ -186,7 +186,15 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	}
 #endif
 
-	starpu_sched_ctx_list_task_counters_increment_all(task, sched_ctx_id);
+	if (_starpu_get_nsched_ctxs() > 1)
+	{
+		_starpu_worker_relax_on();
+		_starpu_sched_ctx_lock_write(sched_ctx_id);
+		_starpu_worker_relax_off();
+		starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(task, sched_ctx_id);
+		_starpu_sched_ctx_unlock_write(sched_ctx_id);
+	}
+
 
 	return 0;
 }