浏览代码

We wake the blocked workers when enabling profiling: this permits to properly
report sleeping time in situations like:

starpu_init; sleep(10s); set_profiling; sleep(3s); get_profiling_info;

In that case, we would expect StarPU to report 3s of sleep, instead of 13s or
0s.

Cédric Augonnet 15 年之前
父节点
当前提交
e0180473f0
共有 2 个文件被更改,包括 15 次插入4 次删除
  1. 9 4
      examples/profiling/profiling.c
  2. 6 0
      src/profiling/profiling.c

+ 9 - 4
examples/profiling/profiling.c

@@ -36,6 +36,10 @@ int main(int argc, char **argv)
 	/* Enable profiling */
 	/* Enable profiling */
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
 
+	/* We should observe at least 500ms in the sleep time reported by every
+	 * worker. */
+	usleep(500000);
+
 	starpu_codelet cl =
 	starpu_codelet cl =
 	{
 	{
 		.where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
 		.where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
@@ -103,14 +107,15 @@ int main(int argc, char **argv)
 		struct starpu_worker_profiling_info worker_info;
 		struct starpu_worker_profiling_info worker_info;
 		starpu_worker_get_profiling_info(worker, &worker_info);
 		starpu_worker_get_profiling_info(worker, &worker_info);
 
 
+		float executing_ratio = ((100.0*worker_info.executing_time)/worker_info.total_time);
+		float sleeping_ratio = ((100.0*worker_info.sleeping_time)/worker_info.total_time);
+
 		char workername[128];
 		char workername[128];
 		starpu_worker_get_name(worker, workername, 128);
 		starpu_worker_get_name(worker, workername, 128);
 		fprintf(stderr, "Worker %s:\n", workername);
 		fprintf(stderr, "Worker %s:\n", workername);
 		fprintf(stderr, "\ttotal time : %ld us\n", worker_info.total_time);
 		fprintf(stderr, "\ttotal time : %ld us\n", worker_info.total_time);
-		fprintf(stderr, "\texec time  : %ld us\n", worker_info.executing_time);
-
-		float overhead = 100.0 - ((100.0*worker_info.executing_time)/worker_info.total_time);
-		fprintf(stderr, "\toverhead : %.2f %%\n", overhead);
+		fprintf(stderr, "\texec time  : %ld us (%.2f %%)\n", worker_info.executing_time, executing_ratio);
+		fprintf(stderr, "\tblocked time  : %ld us (%.2f %%)\n", worker_info.sleeping_time, sleeping_ratio);
 	}
 	}
 
 
 	starpu_shutdown();
 	starpu_shutdown();

+ 6 - 0
src/profiling/profiling.c

@@ -43,6 +43,12 @@ int starpu_profiling_status_set(int status)
 		int worker;
 		int worker;
 		for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
 		for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
 			_starpu_worker_reset_profiling_info(worker);
 			_starpu_worker_reset_profiling_info(worker);
+
+		/* In case there are blocked workers, we wake them up so that
+		 * the sleeping is measured from the time we activate
+		 * profiling, and not when the worker is awoken for the first
+		 * time later on. */
+		starpu_wake_all_blocked_workers();
 	}
 	}
 
 
 	return prev_value;
 	return prev_value;