瀏覽代碼

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

Samuel Thibault 13 年之前
父節點
當前提交
675ac17ac9
共有 3 個文件被更改,包括 12 次插入0 次删除
  1. 4 0
      src/drivers/cpu/driver_cpu.c
  2. 4 0
      src/drivers/cuda/driver_cuda.c
  3. 4 0
      src/drivers/opencl/driver_opencl.c

+ 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);