Browse Source

Functions starpu_task_wait_for_all_in_ctx() and starpu_task_wait_for_all() return the number of tasks that have been waited for.

Nathalie Furmento 9 years ago
parent
commit
b406c91669
4 changed files with 24 additions and 15 deletions
  1. 3 0
      ChangeLog
  2. 8 6
      doc/doxygen/chapters/api/codelet_and_tasks.doxy
  3. 3 1
      src/common/barrier_counter.c
  4. 10 8
      src/core/task.c

+ 3 - 0
ChangeLog

@@ -209,6 +209,9 @@ Small changes:
     STARPU_NMICDEVS, the number of devices and the number of cores.
     STARPU_NMICDEVS, the number of devices and the number of cores.
     STARPU_NMIC will be the number of devices, and STARPU_NMICCORES
     STARPU_NMIC will be the number of devices, and STARPU_NMICCORES
     will be the number of cores per device.
     will be the number of cores per device.
+  * Functions starpu_task_wait_for_all_in_ctx() and
+    starpu_task_wait_for_all() return the number of tasks that have
+    been waited for.
 
 
 StarPU 1.1.5 (svn revision xxx)
 StarPU 1.1.5 (svn revision xxx)
 ==============================================
 ==============================================

+ 8 - 6
doc/doxygen/chapters/api/codelet_and_tasks.doxy

@@ -1,7 +1,7 @@
 /*
 /*
  * This file is part of the StarPU Handbook.
  * This file is part of the StarPU Handbook.
  * Copyright (C) 2009--2011  Universit@'e de Bordeaux
  * Copyright (C) 2009--2011  Universit@'e de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011, 2012 INRIA
  * Copyright (C) 2011, 2012 INRIA
  * See the file version.doxy for copying conditions.
  * See the file version.doxy for copying conditions.
  */
  */
@@ -806,14 +806,16 @@ created automatically by StarPU.
 
 
 \fn int starpu_task_wait_for_all(void)
 \fn int starpu_task_wait_for_all(void)
 \ingroup API_Codelet_And_Tasks
 \ingroup API_Codelet_And_Tasks
-This function blocks until all the tasks that were submitted
-(to the current context or the global one if there aren't any) are
-terminated. It does not destroy these tasks.
+This function blocks until all the tasks that were submitted (to the
+current context or the global one if there aren't any) are terminated.
+It does not destroy these tasks. It returns the number of tasks that
+have been waited for.
 
 
 \fn int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id)
 \fn int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id)
 \ingroup API_Codelet_And_Tasks
 \ingroup API_Codelet_And_Tasks
-This function waits until all the tasks that were already
-submitted to the context \p sched_ctx_id have been executed
+This function waits until all the tasks
+that were already submitted to the context \p sched_ctx_id have been
+executed. It returns the number of tasks that have been waited for.
 
 
 \fn int starpu_task_wait_for_n_submitted(unsigned n)
 \fn int starpu_task_wait_for_n_submitted(unsigned n)
 \ingroup API_Codelet_And_Tasks
 \ingroup API_Codelet_And_Tasks

+ 3 - 1
src/common/barrier_counter.c

@@ -36,13 +36,15 @@ int _starpu_barrier_counter_destroy(struct _starpu_barrier_counter *barrier_c)
 int _starpu_barrier_counter_wait_for_empty_counter(struct _starpu_barrier_counter *barrier_c)
 int _starpu_barrier_counter_wait_for_empty_counter(struct _starpu_barrier_counter *barrier_c)
 {
 {
 	struct _starpu_barrier *barrier = &barrier_c->barrier;
 	struct _starpu_barrier *barrier = &barrier_c->barrier;
+	int ret;
 	STARPU_PTHREAD_MUTEX_LOCK(&barrier->mutex);
 	STARPU_PTHREAD_MUTEX_LOCK(&barrier->mutex);
 
 
+	ret = barrier->reached_start;
 	while (barrier->reached_start > 0)
 	while (barrier->reached_start > 0)
 		STARPU_PTHREAD_COND_WAIT(&barrier->cond, &barrier->mutex);
 		STARPU_PTHREAD_COND_WAIT(&barrier->cond, &barrier->mutex);
 
 
 	STARPU_PTHREAD_MUTEX_UNLOCK(&barrier->mutex);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&barrier->mutex);
-	return 0;
+	return ret;
 }
 }
 
 
 int _starpu_barrier_counter_wait_until_counter_reaches_down_to_n(struct _starpu_barrier_counter *barrier_c, unsigned n)
 int _starpu_barrier_counter_wait_until_counter_reaches_down_to_n(struct _starpu_barrier_counter *barrier_c, unsigned n)

+ 10 - 8
src/core/task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011, 2014  INRIA
  * Copyright (C) 2011, 2014  INRIA
  *
  *
@@ -840,11 +840,12 @@ int starpu_task_wait_for_all(void)
 		if(config->topology.nsched_ctxs == 1)
 		if(config->topology.nsched_ctxs == 1)
 		{
 		{
 			_starpu_sched_do_schedule(0);
 			_starpu_sched_do_schedule(0);
-			starpu_task_wait_for_all_in_ctx(0);
+			return starpu_task_wait_for_all_in_ctx(0);
 		}
 		}
 		else
 		else
 		{
 		{
 			int s;
 			int s;
+			int ret = 0;
 			for(s = 0; s < STARPU_NMAX_SCHED_CTXS; s++)
 			for(s = 0; s < STARPU_NMAX_SCHED_CTXS; s++)
 			{
 			{
 				if(config->sched_ctxs[s].id != STARPU_NMAX_SCHED_CTXS)
 				if(config->sched_ctxs[s].id != STARPU_NMAX_SCHED_CTXS)
@@ -856,12 +857,11 @@ int starpu_task_wait_for_all(void)
 			{
 			{
 				if(config->sched_ctxs[s].id != STARPU_NMAX_SCHED_CTXS)
 				if(config->sched_ctxs[s].id != STARPU_NMAX_SCHED_CTXS)
 				{
 				{
-					starpu_task_wait_for_all_in_ctx(config->sched_ctxs[s].id);
+					ret += starpu_task_wait_for_all_in_ctx(config->sched_ctxs[s].id);
 				}
 				}
 			}
 			}
+			return ret;
 		}
 		}
-
-		return 0;
 	}
 	}
 	else
 	else
 	{
 	{
@@ -873,14 +873,16 @@ int starpu_task_wait_for_all(void)
 
 
 int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx)
 int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx)
 {
 {
+	int ret;
+
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_START();
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_START();
-	_starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
+	ret = _starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_END();
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_END();
 #ifdef HAVE_AYUDAME_H
 #ifdef HAVE_AYUDAME_H
 	/* TODO: improve Temanejo into knowing about contexts ... */
 	/* TODO: improve Temanejo into knowing about contexts ... */
 	if (AYU_event) AYU_event(AYU_BARRIER, 0, NULL);
 	if (AYU_event) AYU_event(AYU_BARRIER, 0, NULL);
 #endif
 #endif
-	return 0;
+	return ret;
 }
 }
 
 
 /*
 /*
@@ -1183,7 +1185,7 @@ static void *watchdog_func(void *arg)
 	timeout = ((float) atoll(timeout_env)) / 1000000;
 	timeout = ((float) atoll(timeout_env)) / 1000000;
 #endif
 #endif
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
-	
+
 	STARPU_PTHREAD_MUTEX_LOCK(&config->submitted_mutex);
 	STARPU_PTHREAD_MUTEX_LOCK(&config->submitted_mutex);
 	while (_starpu_machine_is_running())
 	while (_starpu_machine_is_running())
 	{
 	{