瀏覽代碼

Add starpu_fxt_autostart_profiling to be able to avoid autostart.

Samuel Thibault 9 年之前
父節點
當前提交
18670a9934

+ 1 - 0
ChangeLog

@@ -196,6 +196,7 @@ Small features:
   * Add STARPU_CODELET_SIMGRID_EXECUTE flag.
   * Add STARPU_CODELET_SIMGRID_EXECUTE flag.
   * Add STARPU_CL_ARGS flag to starpu_task_insert() and
   * Add STARPU_CL_ARGS flag to starpu_task_insert() and
     starpu_mpi_task_insert() functions call
     starpu_mpi_task_insert() functions call
+  * Add starpu_fxt_autostart_profiling to be able to avoid autostart.
 
 
 Changes:
 Changes:
   * Data interfaces (variable, vector, matrix and block) now define
   * Data interfaces (variable, vector, matrix and block) now define

+ 24 - 0
doc/doxygen/chapters/13offline_performance_tools.doxy

@@ -230,6 +230,30 @@ will also produce a <c>trace.html</c> file which can be viewed in a
 javascript-enabled web browser. It shows the flow of tasks between the
 javascript-enabled web browser. It shows the flow of tasks between the
 components of the modular scheduler.
 components of the modular scheduler.
 
 
+\subsection Limiting the scope of the trace
+
+For computing statistics, it is useful to limit the trace to a given portion of
+the time of the whole execution. This can be achieved by calling
+
+\verbatim
+starpu_fxt_autostart_profiling(0);
+\endverbatim
+
+before calling starpu_init, to prevent tracing from starting immediately. Then
+
+\verbatim
+starpu_fxt_start_profiling();
+\endverbatim
+
+and 
+
+\verbatim
+starpu_fxt_stop_profiling();
+\endverbatim
+
+can be used around the portion of code to be traced. This will show up as marks
+in the trace, and states of workers will only show up for that portion.
+
 \section PerformanceOfCodelets Performance Of Codelets
 \section PerformanceOfCodelets Performance Of Codelets
 
 
 The performance model of codelets (see \ref PerformanceModelExample)
 The performance model of codelets (see \ref PerformanceModelExample)

+ 6 - 0
doc/doxygen/chapters/api/fxt_support.doxy

@@ -77,6 +77,12 @@ starpu_shutdown(). starpu_fxt_stop_profiling() can however be used to
 stop it earlier. starpu_fxt_start_profiling() can then be called to
 stop it earlier. starpu_fxt_start_profiling() can then be called to
 start recording it again, etc.
 start recording it again, etc.
 
 
+\fn void starpu_fxt_autostart_profiling(int autostart)
+\ingroup API_FxT_Support
+Determines whether profiling should be started by starpu_init, or only when
+starpu_fxt_start_profiling is called. \e autostart should be 1 to do so, or 0 to
+prevent it.
+
 \fn void starpu_fxt_write_data_trace(char *filename_in)
 \fn void starpu_fxt_write_data_trace(char *filename_in)
 \ingroup API_FxT_Support
 \ingroup API_FxT_Support
 todo
 todo

+ 5 - 0
examples/mult/xgemm.c

@@ -30,6 +30,7 @@
 #include <math.h>
 #include <math.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <starpu.h>
 #include <starpu.h>
+#include <starpu_fxt.h>
 
 
 #include <common/blas.h>
 #include <common/blas.h>
 
 
@@ -318,6 +319,7 @@ int main(int argc, char **argv)
 	niter /= 10;
 	niter /= 10;
 #endif
 #endif
 
 
+	starpu_fxt_autostart_profiling(0);
 	ret = starpu_init(NULL);
 	ret = starpu_init(NULL);
 	if (ret == -ENODEV)
 	if (ret == -ENODEV)
 		return 77;
 		return 77;
@@ -331,6 +333,8 @@ int main(int argc, char **argv)
 	if (bound)
 	if (bound)
 		starpu_bound_start(0, 0);
 		starpu_bound_start(0, 0);
 
 
+	sleep(1);
+	starpu_fxt_start_profiling();
 	start = starpu_timing_now();
 	start = starpu_timing_now();
 
 
 	unsigned x, y, iter;
 	unsigned x, y, iter;
@@ -364,6 +368,7 @@ int main(int argc, char **argv)
 
 
 
 
 	end = starpu_timing_now();
 	end = starpu_timing_now();
+	starpu_fxt_stop_profiling();
 
 
 	if (bound)
 	if (bound)
 		starpu_bound_stop();
 		starpu_bound_stop();

+ 2 - 1
include/starpu_fxt.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010-2011, 2013, 2015  Université de Bordeaux
+ * Copyright (C) 2010-2011, 2013, 2015-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2014  CNRS
  * Copyright (C) 2010, 2011, 2013, 2014  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -66,6 +66,7 @@ struct starpu_fxt_options
 
 
 void starpu_fxt_options_init(struct starpu_fxt_options *options);
 void starpu_fxt_options_init(struct starpu_fxt_options *options);
 void starpu_fxt_generate_trace(struct starpu_fxt_options *options);
 void starpu_fxt_generate_trace(struct starpu_fxt_options *options);
+void starpu_fxt_autostart_profiling(int autostart);
 void starpu_fxt_start_profiling(void);
 void starpu_fxt_start_profiling(void);
 void starpu_fxt_stop_profiling(void);
 void starpu_fxt_stop_profiling(void);
 void starpu_fxt_write_data_trace(char *filename_in);
 void starpu_fxt_write_data_trace(char *filename_in);

+ 11 - 5
src/common/fxt.c

@@ -42,6 +42,8 @@ static int _starpu_written = 0;
 
 
 static int _starpu_id;
 static int _starpu_id;
 
 
+static unsigned int initial_key_mask = FUT_KEYMASKALL;
+
 #ifdef STARPU_SIMGRID
 #ifdef STARPU_SIMGRID
 /* Give virtual time to FxT */
 /* Give virtual time to FxT */
 uint64_t fut_getstamp(void)
 uint64_t fut_getstamp(void)
@@ -107,6 +109,14 @@ void starpu_profiling_set_id(int new_id)
 #endif
 #endif
 }
 }
 
 
+void starpu_fxt_autostart_profiling(int autostart)
+{
+	if (autostart)
+		initial_key_mask = FUT_KEYMASKALL;
+	else
+		initial_key_mask = FUT_KEYMASK0;
+}
+
 void starpu_fxt_start_profiling()
 void starpu_fxt_start_profiling()
 {
 {
 	unsigned threadid = _starpu_gettid();
 	unsigned threadid = _starpu_gettid();
@@ -148,16 +158,12 @@ void _starpu_fxt_init_profiling(unsigned trace_buffer_size)
 
 
 	atexit(_starpu_stop_fxt_profiling);
 	atexit(_starpu_stop_fxt_profiling);
 
 
-	unsigned int key_mask = FUT_KEYMASKALL;
-
-	if (fut_setup(trace_buffer_size / sizeof(unsigned long), key_mask, threadid) < 0)
+	if (fut_setup(trace_buffer_size / sizeof(unsigned long), initial_key_mask, threadid) < 0)
 	{
 	{
 		perror("fut_setup");
 		perror("fut_setup");
 		STARPU_ABORT();
 		STARPU_ABORT();
 	}
 	}
 
 
-	fut_keychange(FUT_ENABLE, key_mask, threadid);
-
 	return;
 	return;
 }
 }
 
 

+ 16 - 2
src/debug/traces/starpu_fxt.c

@@ -51,6 +51,8 @@ static unsigned mic_index = 0;
 static unsigned scc_index = 0;
 static unsigned scc_index = 0;
 static unsigned other_index = 0;
 static unsigned other_index = 0;
 
 
+static unsigned long fut_keymask;
+
 /*
 /*
  * Paje trace file tools
  * Paje trace file tools
  */
  */
@@ -527,6 +529,8 @@ static void memnode_set_state(double time, const char *prefix, unsigned int memn
 
 
 static void worker_set_state(double time, const char *prefix, long unsigned int workerid, const char *name)
 static void worker_set_state(double time, const char *prefix, long unsigned int workerid, const char *name)
 {
 {
+	if (fut_keymask == FUT_KEYMASK0)
+		return;
 #ifdef STARPU_HAVE_POTI
 #ifdef STARPU_HAVE_POTI
 	char container[STARPU_POTI_STR_LEN];
 	char container[STARPU_POTI_STR_LEN];
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
@@ -538,6 +542,8 @@ static void worker_set_state(double time, const char *prefix, long unsigned int
 
 
 static void worker_push_state(double time, const char *prefix, long unsigned int workerid, const char *name)
 static void worker_push_state(double time, const char *prefix, long unsigned int workerid, const char *name)
 {
 {
+	if (fut_keymask == FUT_KEYMASK0)
+		return;
 #ifdef STARPU_HAVE_POTI
 #ifdef STARPU_HAVE_POTI
 	char container[STARPU_POTI_STR_LEN];
 	char container[STARPU_POTI_STR_LEN];
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
@@ -549,6 +555,8 @@ static void worker_push_state(double time, const char *prefix, long unsigned int
 
 
 static void worker_pop_state(double time, const char *prefix, long unsigned int workerid)
 static void worker_pop_state(double time, const char *prefix, long unsigned int workerid)
 {
 {
+	if (fut_keymask == FUT_KEYMASK0)
+		return;
 #ifdef STARPU_HAVE_POTI
 #ifdef STARPU_HAVE_POTI
 	char container[STARPU_POTI_STR_LEN];
 	char container[STARPU_POTI_STR_LEN];
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
 	worker_container_alias(container, STARPU_POTI_STR_LEN, prefix, workerid);
@@ -2900,12 +2908,18 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 				handle_hypervisor_end(&ev, options);
 				handle_hypervisor_end(&ev, options);
 				break;
 				break;
 
 
-			/* We can safely ignore FUT internal events */
 			case FUT_SETUP_CODE:
 			case FUT_SETUP_CODE:
+				fut_keymask = ev.param[0];
+				break;
+
+			case FUT_KEYCHANGE_CODE:
+				fut_keymask = ev.param[0];
+				break;
+
+			/* We can safely ignore FUT internal events */
 			case FUT_CALIBRATE0_CODE:
 			case FUT_CALIBRATE0_CODE:
 			case FUT_CALIBRATE1_CODE:
 			case FUT_CALIBRATE1_CODE:
 			case FUT_CALIBRATE2_CODE:
 			case FUT_CALIBRATE2_CODE:
-			case FUT_KEYCHANGE_CODE:
 			case FUT_NEW_LWP_CODE:
 			case FUT_NEW_LWP_CODE:
 			case FUT_GCC_INSTRUMENT_ENTRY_CODE:
 			case FUT_GCC_INSTRUMENT_ENTRY_CODE:
 				break;
 				break;