Kaynağa Gözat

Modified the drivers to update sleeping time when profiling

Mehdi Juhoor 15 yıl önce
ebeveyn
işleme
c0f5d8f457

+ 22 - 8
src/drivers/cpu/driver_cpu.c

@@ -163,6 +163,9 @@ void *_starpu_cpu_worker(void *arg)
 	struct starpu_sched_policy_s *policy = _starpu_get_sched_policy();
 	struct starpu_jobq_s *queue = policy->starpu_get_local_queue(policy);
 
+	int profiling;
+	int64_t start_time, end_time;
+
 	while (_starpu_machine_is_running())
 	{
 		STARPU_TRACE_START_PROGRESS(memnode);
@@ -179,16 +182,27 @@ void *_starpu_cpu_worker(void *arg)
 		/* otherwise ask a task to the scheduler */
 		if (!j)
 			j = _starpu_pop_task();
-
-                if (j == NULL) {
-			if (_starpu_worker_can_block(memnode))
-				PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
-			_starpu_jobq_unlock(queue);
- 			continue;
-		};
+		
+		profiling = starpu_profiling_status_get();
+		
+                if (j == NULL) 
+		  {
+		    if (_starpu_worker_can_block(memnode)) {
+
+		      start_time = (int64_t)_starpu_timing_now();
+		      PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
+		      end_time = (int64_t)_starpu_timing_now();
+
+		      if(profiling){		
+			_starpu_worker_update_profiling_info(cpu_arg->workerid, 0, end_time - start_time, 0);
+		      }   
+		    }
+		    _starpu_jobq_unlock(queue);
+		    continue;
+		  };
 		
 		_starpu_jobq_unlock(queue);
-
+		
 		/* can a cpu perform that task ? */
 		if (!STARPU_CPU_MAY_PERFORM(j)) 
 		{

+ 21 - 7
src/drivers/cuda/driver_cuda.c

@@ -247,6 +247,9 @@ void *_starpu_cuda_worker(void *arg)
 	struct starpu_sched_policy_s *policy = _starpu_get_sched_policy();
 	struct starpu_jobq_s *queue = policy->starpu_get_local_queue(policy);
 	
+	int profiling;
+	int64_t start_time, end_time;
+
 	while (_starpu_machine_is_running())
 	{
 		STARPU_TRACE_START_PROGRESS(memnode);
@@ -263,13 +266,24 @@ void *_starpu_cuda_worker(void *arg)
 		/* otherwise ask a task to the scheduler */
 		if (!j)
 			j = _starpu_pop_task();
-
-		if (j == NULL) {
-			if (_starpu_worker_can_block(memnode))
-				PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
-			_starpu_jobq_unlock(queue);
-			continue;
-		}
+	       
+		profiling = starpu_profiling_status_get();
+	
+                if (j == NULL) 
+		  {
+		    if (_starpu_worker_can_block(memnode)) {
+
+		      start_time = (int64_t)_starpu_timing_now();
+		      PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
+		      end_time = (int64_t)_starpu_timing_now();
+
+		      if(profiling){		
+			_starpu_worker_update_profiling_info(args->workerid, 0, end_time - start_time, 0);
+		      }   
+		    }
+		    _starpu_jobq_unlock(queue);
+		    continue;
+		  };
 
 		_starpu_jobq_unlock(queue);
 

+ 23 - 8
src/drivers/opencl/driver_opencl.c

@@ -1,3 +1,4 @@
+
 /*
  * StarPU
  * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
@@ -233,6 +234,9 @@ void *_starpu_opencl_worker(void *arg)
 	struct starpu_sched_policy_s *policy = _starpu_get_sched_policy();
 	struct starpu_jobq_s *queue = policy->starpu_get_local_queue(policy);
 
+	int profiling;
+	int64_t start_time, end_time;
+
 	while (_starpu_machine_is_running())
 	{
 		STARPU_TRACE_START_PROGRESS(memnode);
@@ -249,16 +253,27 @@ void *_starpu_opencl_worker(void *arg)
 		/* otherwise ask a task to the scheduler */
 		if (!j)
 			j = _starpu_pop_task();
-
-		if (j == NULL) {
-			if (_starpu_worker_can_block(memnode))
-				PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
-			_starpu_jobq_unlock(queue);
-			continue;
-		}
+		
+ 		profiling = starpu_profiling_status_get();
+		
+                if (j == NULL) 
+		  {
+		    if (_starpu_worker_can_block(memnode)) {
+
+		      start_time = (int64_t)_starpu_timing_now();
+		      PTHREAD_COND_WAIT(&queue->activity_cond, &queue->activity_mutex);
+		      end_time = (int64_t)_starpu_timing_now();
+
+		      if(profiling){		
+			_starpu_worker_update_profiling_info(args->workerid, 0, end_time - start_time, 0);
+		      }   
+		    }
+		    _starpu_jobq_unlock(queue);
+		    continue;
+		  };
 
 		_starpu_jobq_unlock(queue);
-
+	       
 		/* can OpenCL do that task ? */
 		if (!STARPU_OPENCL_MAY_PERFORM(j))
 		{