Procházet zdrojové kódy

Document why we need to keep the sched condition mutex all along between pop and block

Samuel Thibault před 13 roky
rodič
revize
675ac17ac9

+ 4 - 0
src/drivers/cpu/driver_cpu.c

@@ -157,6 +157,10 @@ int _starpu_cpu_driver_run_once(struct starpu_driver *d)
 	_starpu_datawizard_progress(memnode, 1);
 	_STARPU_TRACE_END_PROGRESS(memnode);
 
+	/* Note: we need to keep the sched condition mutex all along the path
+	 * from popping a task from the scheduler to blocking. Otherwise the
+	 * driver may go block just after the scheduler got a new task to be
+	 * executed, and thus hanging. */
 	_STARPU_PTHREAD_MUTEX_LOCK(cpu_worker->sched_mutex);
 
         struct _starpu_job *j;

+ 4 - 0
src/drivers/cuda/driver_cuda.c

@@ -352,6 +352,10 @@ int _starpu_cuda_driver_run_once(struct starpu_driver *d)
 	_starpu_datawizard_progress(memnode, 1);
 	_STARPU_TRACE_END_PROGRESS(memnode);
 
+	/* Note: we need to keep the sched condition mutex all along the path
+	 * from popping a task from the scheduler to blocking. Otherwise the
+	 * driver may go block just after the scheduler got a new task to be
+	 * executed, and thus hanging. */
 	_STARPU_PTHREAD_MUTEX_LOCK(args->sched_mutex);
 
 	struct starpu_task *task = _starpu_pop_task(args);

+ 4 - 0
src/drivers/opencl/driver_opencl.c

@@ -487,6 +487,10 @@ int _starpu_opencl_driver_run_once(struct starpu_driver *d)
 	_starpu_datawizard_progress(memnode, 1);
 	_STARPU_TRACE_END_PROGRESS(memnode);
 
+	/* Note: we need to keep the sched condition mutex all along the path
+	 * from popping a task from the scheduler to blocking. Otherwise the
+	 * driver may go block just after the scheduler got a new task to be
+	 * executed, and thus hanging. */
 	_STARPU_PTHREAD_MUTEX_LOCK(args->sched_mutex);
 
 	task = _starpu_pop_task(args);