Pārlūkot izejas kodu

src/core: new functions _starpu_task_wait_for_all_and_return_nb_waited_tasks(void) and _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned) which wait for tasks and return the number of tasks that have been waited for

Nathalie Furmento 9 gadi atpakaļ
vecāks
revīzija
2151a200c2
2 mainītis faili ar 21 papildinājumiem un 7 dzēšanām
  1. 17 6
      src/core/task.c
  2. 4 1
      src/core/task.h

+ 17 - 6
src/core/task.c

@@ -821,7 +821,7 @@ void starpu_codelet_display_stats(struct starpu_codelet *cl)
  * regenerable is not considered finished until it was explicitely set as
  * non-regenerale anymore (eg. from a callback).
  */
-int starpu_task_wait_for_all(void)
+int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void)
 {
 	unsigned nsched_ctxs = _starpu_get_nsched_ctxs();
 	unsigned sched_ctx_id = nsched_ctxs == 1 ? 0 : starpu_sched_ctx_get_context();
@@ -840,8 +840,7 @@ int starpu_task_wait_for_all(void)
 		if(config->topology.nsched_ctxs == 1)
 		{
 			_starpu_sched_do_schedule(0);
-			starpu_task_wait_for_all_in_ctx(0);
-			return 0;
+			return _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(0);
 		}
 		else
 		{
@@ -867,19 +866,31 @@ int starpu_task_wait_for_all(void)
 	{
 		_starpu_sched_do_schedule(sched_ctx_id);
 		_STARPU_DEBUG("Waiting for tasks submitted to context %u\n", sched_ctx_id);
-		return starpu_task_wait_for_all_in_ctx(sched_ctx_id);
+		return _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(sched_ctx_id);
 	}
 }
 
-int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx)
+int starpu_task_wait_for_all(void)
+{
+	_starpu_task_wait_for_all_and_return_nb_waited_tasks();
+	return 0;
+}
+
+int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx)
 {
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_START();
-	_starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
+	int ret = _starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_END();
 #ifdef HAVE_AYUDAME_H
 	/* TODO: improve Temanejo into knowing about contexts ... */
 	if (AYU_event) AYU_event(AYU_BARRIER, 0, NULL);
 #endif
+	return ret;
+}
+
+int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx)
+{
+	_starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(sched_ctx);
 	return 0;
 }
 

+ 4 - 1
src/core/task.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2013, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2013, 2015, 2016  CNRS
  * Copyright (C) 2011, 2014 INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -127,4 +127,7 @@ static inline char *_starpu_task_get_cpu_name_nth_implementation(struct starpu_c
 void _starpu_watchdog_init(void);
 void _starpu_watchdog_shutdown(void);
 
+int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void);
+int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx);
+
 #endif // __CORE_TASK_H__