Explorar el Código

Adapt to watchdog function to avoid waiting too long at the end of the computation, thanks Guillaume Sylvand

Samuel Thibault hace 10 años
padre
commit
183ba157f0
Se han modificado 2 ficheros con 17 adiciones y 1 borrados
  1. 1 0
      AUTHORS
  2. 16 1
      src/core/task.c

+ 1 - 0
AUTHORS

@@ -29,6 +29,7 @@ Marc Sergent <marc.sergent@inria.fr>
 Anthony Simonet <anthony.simonet@etu.u-bordeaux.fr>
 Luka Stanisic <luka.stanisic@imag.fr>
 Ludovic Stordeur <ludovic.stordeur@inria.fr>
+Guillaume Sylvand <guillaume.sylvand@airbus.com>
 François Tessier <francois.tessier@inria.fr>
 Samuel Thibault <samuel.thibault@labri.fr>
 Pierre-André Wacrenier <wacrenier@labri.fr>

+ 16 - 1
src/core/task.c

@@ -1202,7 +1202,22 @@ static void *watchdog_func(void *arg)
 		config->watchdog_ok = 0;
 		STARPU_PTHREAD_MUTEX_UNLOCK(&config->submitted_mutex);
 
-		starpu_sleep(timeout);
+		/* If we do a sleep(timeout), we might have to wait too long at the end of the computation. */
+		/* To avoid that, we do several sleep() of 1s (and check after each if starpu is still running) */
+		float t;
+		for (t = timeout ; t > 1.; t--)
+		{
+			starpu_sleep(1.);
+			if (!_starpu_machine_is_running())
+			{
+				/* Application finished, don't bother finishing the sleep */
+				STARPU_PTHREAD_MUTEX_UNLOCK(&config->submitted_mutex);
+				return NULL;
+			}
+		}
+		/* and one final sleep (of less than 1 s) with the rest (if needed) */
+		if (t > 0.)
+			starpu_sleep(t);
 
 		STARPU_PTHREAD_MUTEX_LOCK(&config->submitted_mutex);
 		if (!config->watchdog_ok && last_nsubmitted