Procházet zdrojové kódy

Add data_trace tool

Joris Pablo před 11 roky
rodič
revize
699b59b945

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 356873 - 0
doc/doxygen/chapters/data_trace.eps


binární
doc/doxygen/chapters/data_trace.pdf


binární
doc/doxygen/chapters/data_trace.png


+ 13 - 0
doc/doxygen/chapters/performance_feedback.doxy

@@ -582,6 +582,19 @@ Computation took (in ms)
 Synthetic GFlops : 44.21
 \endverbatim
 
+\section DataTrace Data trace and tasks length
+It is possible to get statistics about tasks length and data size by using :
+\verbatim
+$starpu_fxt_data_trace filename
+\endverbatim
+Where filename is the FxT trace file. This will create 2 files : <c>data_total.txt</c> which
+shows each task length and total data size and <c>data_trace.gp</c> which can be plotted to 
+get a .eps image of these results. On the image, each point represents a task.
+
+\image html data_trace.png
+\image latex data_trace.eps "" width=\textwidth
+
+
 \internal
 TODO: data transfer stats are similar to the ones displayed when
 setting STARPU_BUS_STATS

+ 1 - 0
include/starpu_fxt.h

@@ -65,6 +65,7 @@ void starpu_fxt_options_init(struct starpu_fxt_options *options);
 void starpu_fxt_generate_trace(struct starpu_fxt_options *options);
 void starpu_fxt_start_profiling(void);
 void starpu_fxt_stop_profiling(void);
+void starpu_fxt_write_data_trace(char *filename_in);
 
 #ifdef __cplusplus
 }

+ 2 - 0
src/common/fxt.h

@@ -135,6 +135,8 @@
 
 #define _STARPU_FUT_MEMORY_FULL			0x5152
 
+#define _STARPU_FUT_DATA_LOAD 0x5153
+
 #ifdef STARPU_USE_FXT
 #include <fxt/fxt.h>
 #include <fxt/fut.h>

+ 103 - 0
src/debug/traces/starpu_fxt.c

@@ -1889,4 +1889,107 @@ void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
 
 	options->nworkers = nworkers;
 }
+
+static FILE *out_data_total_trace_file;
+
+struct parse_task
+{
+	unsigned exec_time;
+	unsigned data_total;
+};
+
+static struct parse_task tasks[STARPU_NMAXWORKERS];
+
+#define NANO_SEC_TO_MILI_SEC 0.000001
+
+static void write_task(struct parse_task pt)
+{
+	double time = pt.exec_time * NANO_SEC_TO_MILI_SEC;
+	fprintf(out_data_total_trace_file, "%lf %d\n", time, pt.data_total);
+}
+
+
+void starpu_fxt_write_data_trace(char *filename_in)
+{
+	int fd_in;
+	fd_in = open(filename_in, O_RDONLY);
+	if (fd_in < 0)
+	{
+	        perror("open failed :");
+	        exit(-1);
+	}
+
+	static fxt_t fut;
+	fut = fxt_fdopen(fd_in);
+	if (!fut)
+	{
+	        perror("fxt_fdopen :");
+	        exit(-1);
+	}
+
+	fxt_blockev_t block;
+	block = fxt_blockev_enter(fut);
+
+	out_data_total_trace_file = fopen("data_total.txt", "w+");
+	if(!out_data_total_trace_file)
+        {
+                perror("open failed :");
+                exit(-1);
+        }
+
+	struct fxt_ev_64 ev;
+	while(1)
+	{
+		int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
+		if (ret != FXT_EV_OK)
+		{
+			break;
+		}
+		
+		unsigned workerid;
+
+		switch (ev.code)
+		{
+		case _STARPU_FUT_WORKER_INIT_START:
+			register_worker_id(ev.param[4], ev.param[1]);
+			break;
+			
+		case _STARPU_FUT_START_CODELET_BODY:
+			workerid = find_worker_id(ev.param[2]);
+			tasks[workerid].exec_time = ev.time;
+			break;
+			
+		case _STARPU_FUT_END_CODELET_BODY:
+			workerid = find_worker_id(ev.param[4]);
+			tasks[workerid].exec_time = ev.time - tasks[workerid].exec_time;
+			write_task(tasks[workerid]);
+			break;
+
+		case _STARPU_FUT_DATA_LOAD:
+			workerid = ev.param[0];
+			tasks[workerid].data_total = ev.param[1];
+			break;
+			
+		default:
+#ifdef STARPU_VERBOSE
+			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-options->file_offset));
+#endif
+			break;
+		}
+	}
+	
+	if (close(fd_in))
+	{
+	        perror("close failed :");
+	        exit(-1);
+	}
+	
+	if(fclose(out_data_total_trace_file))
+	{
+		perror("close failed :");
+		exit(-1);
+	}
+
+}
 #endif // STARPU_USE_FXT

+ 11 - 0
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -346,6 +346,17 @@ static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
 		starpu_prefetch_task_input_on_node(task, memory_node);
 	}
 
+	unsigned i;
+
+#ifdef STARPU_USE_FXT
+	unsigned total_size = 0;
+	for (i = 0; i < task->cl->nbuffers; i++)
+	{
+		total_size += _starpu_data_get_size(task->handles[i]);
+	}
+	FUT_DO_PROBE2(_STARPU_FUT_DATA_LOAD, best_workerid, total_size);
+#endif
+
 #ifdef HAVE_AYUDAME_H
 	if (AYU_event)
 	{

+ 8 - 2
tools/Makefile.am

@@ -73,11 +73,13 @@ endif
 if STARPU_USE_FXT
 bin_PROGRAMS += 			\
 	starpu_fxt_tool			\
-	starpu_fxt_stats
+	starpu_fxt_stats		\
+	starpu_fxt_data_trace
 
 STARPU_TOOLS += 			\
 	starpu_fxt_tool			\
-	starpu_fxt_stats
+	starpu_fxt_stats		\
+	starpu_fxt_data_trace
 
 starpu_fxt_tool_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(FXT_CFLAGS)
 starpu_fxt_tool_LDADD = $(FXT_LIBS)
@@ -86,6 +88,10 @@ starpu_fxt_tool_LDFLAGS = $(FXT_LDFLAGS)
 starpu_fxt_stats_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(FXT_CFLAGS)
 starpu_fxt_stats_LDADD = $(FXT_LIBS)
 starpu_fxt_stats_LDFLAGS = $(FXT_LDFLAGS)
+
+starpu_fxt_data_trace_CPPFLAGS = $(AM_CFLAGS) $(AM_CPPFLAGS) $(FXT_CFLAGS)
+starpu_fxt_data_trace_LDADD = $(FXT_LIBS)
+starpu_fxt_data_trace_LDFLAGS = $(FXT_LDFLAGS)
 endif
 
 bin_PROGRAMS += 			\

+ 44 - 0
tools/starpu_fxt_data_trace.c

@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <config.h>
+#include <starpu.h>
+
+#define PROGNAME "starpu_fxt_data_trace"
+
+static void usage(char *progname)
+{
+	fprintf(stderr, "Usage : %s <filename>\n", progname);
+	exit(77);
+}
+
+static void write_plt(){
+	FILE *plt = fopen("data_trace.gp", "w+");
+	if(!plt){
+		fprintf(stderr, "Error while creating data_trace.plt");
+		exit(-1);
+	}
+
+	fprintf(plt, "#!/usr/bin/gnuplot -persist\n\n");
+	fprintf(plt, "set term postscript eps enhanced color\n");
+	fprintf(plt, "set output \"data_trace.eps\"\n");
+	fprintf(plt, "set title \"Data trace\"\n");
+	fprintf(plt, "set logscale x\n");
+	fprintf(plt, "set logscale y\n");
+	fprintf(plt, "set xlabel \"tasks size (ms)\"\n");
+	fprintf(plt, "set ylabel \"data size (B)\"\n");
+	fprintf(plt, "plot \"data_total.txt\" using 1:2 with dots lw 1\n");
+	if(fclose(plt)){
+		perror("close failed :");
+		exit(-1);
+	}
+}
+
+int main(int argc, char **argv)
+{
+	if(argc != 2)
+	{
+		usage(argv[0]);
+	}
+	starpu_fxt_write_data_trace(argv[1]);
+	write_plt();
+	return 0;
+}