瀏覽代碼

When starpu_task_wait_for_all() is called, we create a cluster of vertices in
the DAG generated by dot.

Cédric Augonnet 14 年之前
父節點
當前提交
f89f0fc322
共有 5 個文件被更改,包括 39 次插入1 次删除
  1. 6 0
      src/common/fxt.h
  2. 2 0
      src/core/task.c
  3. 21 1
      tools/dag_dot.c
  4. 9 0
      tools/fxt_tool.c
  5. 1 0
      tools/fxt_tool.h

+ 6 - 0
src/common/fxt.h

@@ -96,6 +96,8 @@
 
 #define STARPU_FUT_SET_PROFILING	0x5138
 
+#define STARPU_FUT_TASK_WAIT_FOR_ALL	0x5139
+
 #ifdef STARPU_USE_FXT
 #include <sys/syscall.h> /* pour les définitions de SYS_xxx */
 #include <fxt/fxt.h>
@@ -290,6 +292,9 @@ do {										\
 #define STARPU_TRACE_SET_PROFILING(status)		\
 	FUT_DO_PROBE2(STARPU_FUT_SET_PROFILING, status, syscall(SYS_gettid));
 
+#define STARPU_TRACE_TASK_WAIT_FOR_ALL			\
+	FUT_DO_PROBE0(STARPU_FUT_TASK_WAIT_FOR_ALL)
+
 #else // !STARPU_USE_FXT
 
 #define STARPU_TRACE_NEW_MEM_NODE(nodeid)	do {} while(0);
@@ -333,6 +338,7 @@ do {										\
 #define STARPU_TRACE_END_PROGRESS(memnode)	do {} while(0);
 #define STARPU_TRACE_USER_EVENT(code)		do {} while(0);
 #define STARPU_TRACE_SET_PROFILING(status)	do {} while(0);
+#define STARPU_TRACE_TASK_WAIT_FOR_ALL		do {} while(0);
 
 #endif // STARPU_USE_FXT
 

+ 2 - 0
src/core/task.c

@@ -289,6 +289,8 @@ int starpu_task_wait_for_all(void)
 
 	PTHREAD_MUTEX_LOCK(&submitted_mutex);
 
+	STARPU_TRACE_TASK_WAIT_FOR_ALL;
+
 	while (nsubmitted > 0)
 		PTHREAD_COND_WAIT(&submitted_cond, &submitted_mutex);
 	

+ 21 - 1
tools/dag_dot.c

@@ -21,20 +21,28 @@
 
 static char *out_path = "dag.dot";
 static FILE *out_file;
-
+static unsigned cluster_cnt;
 
 void init_dag_dot(void)
 {
 	/* create a new file */
 	out_file = fopen(out_path, "w+");
+	cluster_cnt = 0;
 
 	fprintf(out_file, "digraph G {\n");
 	fprintf(out_file, "\tcolor=white\n");
 	fprintf(out_file, "\trankdir=LR;\n");
+
+	/* Create a new cluster */
+	fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
+	fprintf(out_file, "\tcolor=black;\n");
 }
 
 void terminate_dat_dot(void)
 {
+	/* Close the last cluster */
+	fprintf(out_file, "}\n");
+	/* Close the graph */
 	fprintf(out_file, "}\n");
 	fclose(out_file);
 }
@@ -61,3 +69,15 @@ void dot_set_task_done(unsigned long job_id, const char *label, const char *colo
 {
 	fprintf(out_file, "\t \"task_%lx\" \[ style=filled, label=\"%s\", color=\"%s\"]\n", job_id, label, color);
 }
+
+void dot_add_sync_point(void)
+{
+	/* Close the previous cluster */
+	fprintf(out_file, "}\n");
+
+	cluster_cnt++;
+
+	/* Create a new cluster */
+	fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
+	fprintf(out_file, "\tcolor=black;\n");
+}

+ 9 - 0
tools/fxt_tool.c

@@ -694,6 +694,11 @@ static void handle_set_profiling(void)
 	fprintf(activity_file, "set_profiling\t%lf\t%d\n", get_event_time_stamp(), status);
 }
 
+static void handle_task_wait_for_all(void)
+{
+	dot_add_sync_point();
+}
+
 static void parse_args(int argc, char **argv)
 {
 	/* We want to support arguments such as "fxt_tool -i trace_*" */
@@ -965,6 +970,10 @@ void parse_new_file(char *filename_in, char *file_prefix, uint64_t file_offset)
 				handle_set_profiling();
 				break;
 
+			case STARPU_FUT_TASK_WAIT_FOR_ALL:
+				handle_task_wait_for_all();
+				break;
+
 			default:
 				fprintf(stderr, "unknown event.. %x at time %llx WITH OFFSET %llx\n",
 					(unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-offset));

+ 1 - 0
tools/fxt_tool.h

@@ -40,6 +40,7 @@ extern void terminate_dat_dot(void);
 extern void add_deps(uint64_t child, uint64_t father);
 extern void dot_set_tag_done(uint64_t tag, const char *color);
 extern void dot_set_task_done(unsigned long job_id, const char *label, const char *color);
+extern void dot_add_sync_point(void);
 
 void set_next_other_worker_color(int workerid);
 void set_next_cpu_worker_color(int workerid);