Browse Source

core: replace STARPU_ENABLE_STATS with an envvar

This allows to enable some statistics without re-building.
Samuel Pitoiset 9 years ago
parent
commit
aa11fd4af0

+ 0 - 11
configure.ac

@@ -1613,17 +1613,6 @@ if  test x$enable_model_debug = xyes; then
 	AC_DEFINE(STARPU_MODEL_DEBUG, [1], [enable performance model debug])
 	AC_DEFINE(STARPU_MODEL_DEBUG, [1], [enable performance model debug])
 fi
 fi
 
 
-AC_MSG_CHECKING(whether statistics should be generated)
-AC_ARG_ENABLE(stats, [AS_HELP_STRING([--enable-stats],
-			[enable statistics])],
-			enable_stats=$enableval, enable_stats=no)
-AC_MSG_RESULT($enable_stats)
-AC_SUBST(STATS, $enable_stats)
-AC_SUBST(STARPU_ENABLE_STATS, $enable_stats)
-if test x$enable_stats = xyes; then
-        AC_DEFINE(STARPU_ENABLE_STATS, [1], [enable statistics])
-fi
-
 AC_MSG_CHECKING(whether memory stats should be displayed)
 AC_MSG_CHECKING(whether memory stats should be displayed)
 AC_ARG_ENABLE(memory-stats, [AS_HELP_STRING([--enable-memory-stats],
 AC_ARG_ENABLE(memory-stats, [AS_HELP_STRING([--enable-memory-stats],
 			     [enable memory stats])],
 			     [enable memory stats])],

+ 2 - 2
doc/doxygen/chapters/13offline_performance_tools.doxy

@@ -556,8 +556,8 @@ Node #3
 \section DataStatistics Data Statistics
 \section DataStatistics Data Statistics
 
 
 Different data statistics can be displayed at the end of the execution
 Different data statistics can be displayed at the end of the execution
-of the application. To enable them, you need to pass the option
-\ref enable-stats "--enable-stats" when calling <c>configure</c>. When calling
+of the application. To enable them, you need to define the environment
+variable \ref STARPU_ENABLE_STATS. When calling
 starpu_shutdown() various statistics will be displayed,
 starpu_shutdown() various statistics will be displayed,
 execution, MSI cache statistics, allocation cache statistics, and data
 execution, MSI cache statistics, allocation cache statistics, and data
 transfer statistics. The display can be disabled by setting the
 transfer statistics. The display can be disabled by setting the

+ 7 - 0
doc/doxygen/chapters/40environment_variables.doxy

@@ -705,6 +705,13 @@ When set to <c>1</c>, this variable indicates that StarPU should automatically
 generate a Paje trace when starpu_shutdown() is called.
 generate a Paje trace when starpu_shutdown() is called.
 </dd>
 </dd>
 
 
+<dt>STARPU_ENABLE_STATS</dt>
+<dd>
+\anchor STARPU_ENABLE_STATS
+\addindex __env__STARPU_ENABLE_STATS
+When defined, enable gathering various data statistics (\ref DataStatistics).
+</dd>
+
 <dt>STARPU_MEMORY_STATS</dt>
 <dt>STARPU_MEMORY_STATS</dt>
 <dd>
 <dd>
 \anchor STARPU_MEMORY_STATS
 \anchor STARPU_MEMORY_STATS

+ 0 - 8
doc/doxygen/chapters/41configure_options.doxy

@@ -410,14 +410,6 @@ version of ViTE (at least r1430).
 Enable additional trace events which describes locks behaviour.
 Enable additional trace events which describes locks behaviour.
 </dd>
 </dd>
 
 
-<dt>--enable-stats</dt>
-<dd>
-\anchor enable-stats
-\addindex __configure__--enable-stats
-(see ../../src/datawizard/datastats.c)
-Enable gathering of various data statistics (\ref DataStatistics).
-</dd>
-
 <dt>--enable-maxbuffers</dt>
 <dt>--enable-maxbuffers</dt>
 <dd>
 <dd>
 \anchor enable-maxbuffers
 \anchor enable-maxbuffers

+ 5 - 3
src/core/workers.c

@@ -1154,11 +1154,13 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 #ifdef STARPU_MODEL_DEBUG
 #ifdef STARPU_MODEL_DEBUG
 	_STARPU_DISP("Warning: StarPU was configured with --enable-model-debug, which slows down a bit\n");
 	_STARPU_DISP("Warning: StarPU was configured with --enable-model-debug, which slows down a bit\n");
 #endif
 #endif
-#ifdef STARPU_ENABLE_STATS
-	_STARPU_DISP("Warning: StarPU was configured with --enable-stats, which slows down a bit\n");
-#endif
 #endif
 #endif
 
 
+	if (starpu_getenv("STARPU_ENABLE_STATS")) {
+		_STARPU_DISP("Warning: STARPU_ENABLE_STATS is enabled, "
+			     "which slows down a bit\n");
+	}
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	WSADATA wsadata;
 	WSADATA wsadata;
 	WSAStartup(MAKEWORD(1,0), &wsadata);
 	WSAStartup(MAKEWORD(1,0), &wsadata);

+ 29 - 23
src/datawizard/datastats.c

@@ -20,31 +20,38 @@
 #include <datawizard/coherency.h>
 #include <datawizard/coherency.h>
 #include <common/config.h>
 #include <common/config.h>
 
 
-#ifdef STARPU_ENABLE_STATS
+static inline int starpu_enable_stats(void)
+{
+	return !!starpu_getenv("STARPU_ENABLE_STATS");
+}
+
 /* measure the cache hit ratio for each node */
 /* measure the cache hit ratio for each node */
 static unsigned hit_cnt[STARPU_MAXNODES];
 static unsigned hit_cnt[STARPU_MAXNODES];
 static unsigned miss_cnt[STARPU_MAXNODES];
 static unsigned miss_cnt[STARPU_MAXNODES];
-#endif
 
 
 void _starpu_msi_cache_hit(unsigned node STARPU_ATTRIBUTE_UNUSED)
 void _starpu_msi_cache_hit(unsigned node STARPU_ATTRIBUTE_UNUSED)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	STARPU_HG_DISABLE_CHECKING(hit_cnt[node]);
 	STARPU_HG_DISABLE_CHECKING(hit_cnt[node]);
 	hit_cnt[node]++;
 	hit_cnt[node]++;
-#endif
 }
 }
 
 
 void _starpu_msi_cache_miss(unsigned node STARPU_ATTRIBUTE_UNUSED)
 void _starpu_msi_cache_miss(unsigned node STARPU_ATTRIBUTE_UNUSED)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	STARPU_HG_DISABLE_CHECKING(miss_cnt[node]);
 	STARPU_HG_DISABLE_CHECKING(miss_cnt[node]);
 	miss_cnt[node]++;
 	miss_cnt[node]++;
-#endif
 }
 }
 
 
 void _starpu_display_msi_stats(void)
 void _starpu_display_msi_stats(void)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	unsigned node;
 	unsigned node;
 	unsigned total_hit_cnt = 0;
 	unsigned total_hit_cnt = 0;
 	unsigned total_miss_cnt = 0;
 	unsigned total_miss_cnt = 0;
@@ -70,35 +77,35 @@ void _starpu_display_msi_stats(void)
 		}
 		}
 	}
 	}
 	fprintf(stderr, "#---------------------\n");
 	fprintf(stderr, "#---------------------\n");
-#endif
 }
 }
 
 
 /* measure the efficiency of our allocation cache */
 /* measure the efficiency of our allocation cache */
-
-#ifdef STARPU_ENABLE_STATS
 static unsigned alloc_cnt[STARPU_MAXNODES];
 static unsigned alloc_cnt[STARPU_MAXNODES];
 static unsigned alloc_cache_hit_cnt[STARPU_MAXNODES];
 static unsigned alloc_cache_hit_cnt[STARPU_MAXNODES];
-#endif
 
 
 void _starpu_allocation_cache_hit(unsigned node STARPU_ATTRIBUTE_UNUSED)
 void _starpu_allocation_cache_hit(unsigned node STARPU_ATTRIBUTE_UNUSED)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	STARPU_HG_DISABLE_CHECKING(alloc_cache_hit_cnt[node]);
 	STARPU_HG_DISABLE_CHECKING(alloc_cache_hit_cnt[node]);
 	alloc_cache_hit_cnt[node]++;
 	alloc_cache_hit_cnt[node]++;
-#endif
 }
 }
 
 
 void _starpu_data_allocation_inc_stats(unsigned node STARPU_ATTRIBUTE_UNUSED)
 void _starpu_data_allocation_inc_stats(unsigned node STARPU_ATTRIBUTE_UNUSED)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	STARPU_HG_DISABLE_CHECKING(alloc_cnt[node]);
 	STARPU_HG_DISABLE_CHECKING(alloc_cnt[node]);
 	alloc_cnt[node]++;
 	alloc_cnt[node]++;
-#endif
 }
 }
 
 
 void _starpu_display_alloc_cache_stats(void)
 void _starpu_display_alloc_cache_stats(void)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	fprintf(stderr, "\n#---------------------\n");
 	fprintf(stderr, "\n#---------------------\n");
 	fprintf(stderr, "Allocation cache stats:\n");
 	fprintf(stderr, "Allocation cache stats:\n");
 	unsigned node;
 	unsigned node;
@@ -115,20 +122,18 @@ void _starpu_display_alloc_cache_stats(void)
 			fprintf(stderr, "No allocation on node %d\n", node);
 			fprintf(stderr, "No allocation on node %d\n", node);
 	}
 	}
 	fprintf(stderr, "#---------------------\n");
 	fprintf(stderr, "#---------------------\n");
-#endif
 }
 }
 
 
 /* measure the amount of data transfers between each pair of nodes */
 /* measure the amount of data transfers between each pair of nodes */
-#ifdef STARPU_ENABLE_STATS
 static size_t comm_amount[STARPU_MAXNODES][STARPU_MAXNODES];
 static size_t comm_amount[STARPU_MAXNODES][STARPU_MAXNODES];
-#endif /* STARPU_ENABLE_STATS */
 
 
 void _starpu_comm_amounts_inc(unsigned src  STARPU_ATTRIBUTE_UNUSED, unsigned dst  STARPU_ATTRIBUTE_UNUSED, size_t size  STARPU_ATTRIBUTE_UNUSED)
 void _starpu_comm_amounts_inc(unsigned src  STARPU_ATTRIBUTE_UNUSED, unsigned dst  STARPU_ATTRIBUTE_UNUSED, size_t size  STARPU_ATTRIBUTE_UNUSED)
 {
 {
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	STARPU_HG_DISABLE_CHECKING(comm_amount[src][dst]);
 	STARPU_HG_DISABLE_CHECKING(comm_amount[src][dst]);
 	comm_amount[src][dst] += size;
 	comm_amount[src][dst] += size;
-#endif /* STARPU_ENABLE_STATS */
 }
 }
 
 
 void _starpu_display_comm_amounts(void)
 void _starpu_display_comm_amounts(void)
@@ -137,7 +142,9 @@ void _starpu_display_comm_amounts(void)
 #  warning TODO. The information displayed here seems to be similar to the one displayed by starpu_profiling_bus_helper_display_summary()
 #  warning TODO. The information displayed here seems to be similar to the one displayed by starpu_profiling_bus_helper_display_summary()
 #endif
 #endif
 
 
-#ifdef STARPU_ENABLE_STATS
+	if (!starpu_enable_stats())
+		return;
+
 	unsigned src, dst;
 	unsigned src, dst;
 	size_t sum = 0;
 	size_t sum = 0;
 
 
@@ -163,6 +170,5 @@ void _starpu_display_comm_amounts(void)
 					dst, src, ((float)comm_amount[dst][src])/(1024*1024));
 					dst, src, ((float)comm_amount[dst][src])/(1024*1024));
 		}
 		}
 	fprintf(stderr, "#---------------------\n");
 	fprintf(stderr, "#---------------------\n");
-#endif
 }
 }