浏览代码

Move the _starpu_block_worker function into src/driver/driver_common/

Cédric Augonnet 15 年之前
父节点
当前提交
0fd8c2d797
共有 3 个文件被更改,包括 29 次插入28 次删除
  1. 0 28
      src/core/workers.c
  2. 27 0
      src/drivers/driver_common/driver_common.c
  3. 2 0
      src/drivers/driver_common/driver_common.h

+ 0 - 28
src/core/workers.c

@@ -618,31 +618,3 @@ void _starpu_worker_set_status(int workerid, starpu_worker_status status)
 {
 	config.workers[workerid].status = status;
 }
-
-/* TODO move in some driver/common/ directory */
-/* Workers may block when there is no work to do at all. We assume that the
- * mutex is hold when that function is called. */
-void _starpu_block_worker(int workerid, pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
-	struct timespec start_time, end_time;
-
-	STARPU_TRACE_WORKER_SLEEP_START
-	config.workers[workerid].status = STATUS_SLEEPING;
-
-	starpu_clock_gettime(&start_time);
-	_starpu_worker_register_sleeping_start_date(workerid, &start_time);
-
-	PTHREAD_COND_WAIT(cond, mutex);
-
-	config.workers[workerid].status = STATUS_UNKNOWN;
-	STARPU_TRACE_WORKER_SLEEP_END
-	starpu_clock_gettime(&end_time);
-
-	int profiling = starpu_profiling_status_get();
-	if (profiling)
-	{
-		struct timespec sleeping_time;
-		starpu_timespec_sub(&end_time, &start_time, &sleeping_time);
-		_starpu_worker_update_profiling_info_sleeping(workerid, &start_time, &end_time);
-	}
-}

+ 27 - 0
src/drivers/driver_common/driver_common.c

@@ -68,3 +68,30 @@ void _starpu_driver_update_job_feedback(starpu_job_t j, struct starpu_worker_s *
 
 	(void)STARPU_ATOMIC_ADD(&worker_args->jobq->total_job_performed, 1);
 }
+
+/* Workers may block when there is no work to do at all. We assume that the
+ * mutex is hold when that function is called. */
+void _starpu_block_worker(int workerid, pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+	struct timespec start_time, end_time;
+
+	STARPU_TRACE_WORKER_SLEEP_START
+	_starpu_worker_set_status(workerid, STATUS_SLEEPING);
+
+	starpu_clock_gettime(&start_time);
+	_starpu_worker_register_sleeping_start_date(workerid, &start_time);
+
+	PTHREAD_COND_WAIT(cond, mutex);
+
+	_starpu_worker_set_status(workerid, STATUS_UNKNOWN);
+	STARPU_TRACE_WORKER_SLEEP_END
+	starpu_clock_gettime(&end_time);
+
+	int profiling = starpu_profiling_status_get();
+	if (profiling)
+	{
+		struct timespec sleeping_time;
+		starpu_timespec_sub(&end_time, &start_time, &sleeping_time);
+		_starpu_worker_update_profiling_info_sleeping(workerid, &start_time, &end_time);
+	}
+}

+ 2 - 0
src/drivers/driver_common/driver_common.h

@@ -30,4 +30,6 @@ void _starpu_driver_update_job_feedback(starpu_job_t j, struct starpu_worker_s *
 		struct timespec *codelet_start, struct timespec *codelet_end,
 		struct timespec *codelet_start_comm, struct timespec *codelet_end_comm);
 
+void _starpu_block_worker(int workerid, pthread_cond_t *cond, pthread_mutex_t *mutex);
+
 #endif // __DRIVER_COMMON_H__