Browse Source

memory statistics: revert the behaviour of STARPU_MEMORY_STATS. By default, statistics are displayed when calling starou_shutdown(), to disable them set STARPU_MEMORY_STATS to 0

Nathalie Furmento 12 years ago
parent
commit
bc86dcc308
4 changed files with 28 additions and 13 deletions
  1. 4 3
      doc/chapters/configuration.texi
  2. 18 4
      doc/chapters/perf-feedback.texi
  3. 3 3
      src/core/workers.c
  4. 3 3
      src/datawizard/memalloc.c

+ 4 - 3
doc/chapters/configuration.texi

@@ -542,8 +542,9 @@ generate a Paje trace when @code{starpu_shutdown()} is called.
 @end defvr
 
 @defvr {Environment variable} STARPU_MEMORY_STATS
-Display memory statistics on data which have not been unregistered at the end of the execution
-(@pxref{Memory feedback}).
+When set to 0, disable the display of memory statistics on data which
+have not been unregistered at the end of the execution (@pxref{Memory
+feedback}).
 @end defvr
 
 @defvr {Environment variable} STARPU_BUS_STATS
@@ -559,6 +560,6 @@ consumption (@pxref{Power-based scheduling}).
 @end defvr
 
 @defvr {Environment variable} STARPU_STATS
-When defined and set 0, data statistics will not be displayed at the
+When set to 0, data statistics will not be displayed at the
 end of the execution of an application (@pxref{Data statistics}).
 @end defvr

+ 18 - 4
doc/chapters/perf-feedback.texi

@@ -444,16 +444,30 @@ It is possible to enable memory statistics. To do so, you need to pass the optio
 possible to call the function @code{starpu_display_memory_stats()} to
 display statistics about the current data handles registered within StarPU.
 
-Moreover, when setting the environment variable @code{STARPU_MEMORY_STATS}, statistics will be displayed at the end
-of the execution on data handles which have not been cleared out.
+Moreover, statistics will be displayed at the end of the execution on
+data handles which have not been cleared out. This can be disabled by
+setting the environment variable @code{STARPU_MEMORY_STATS} to 0.
 
 For example, if you do not unregister data at the end of the complex
 example, you will get something similar to:
 
 @example
+$ STARPU_MEMORY_STATS=0 ./examples/interface/complex
+Complex[0] = 45.00 + 12.00 i
+Complex[0] = 78.00 + 78.00 i
+Complex[0] = 45.00 + 12.00 i
+Complex[0] = 45.00 + 12.00 i
+@end example
+
+@example
 $ STARPU_MEMORY_STATS=1 ./examples/interface/complex
-...
-Memory status :
+Complex[0] = 45.00 + 12.00 i
+Complex[0] = 78.00 + 78.00 i
+Complex[0] = 45.00 + 12.00 i
+Complex[0] = 45.00 + 12.00 i
+
+#---------------------
+Memory stats:
 #-------
 Data on Node #3
 #-----

+ 3 - 3
src/core/workers.c

@@ -891,10 +891,10 @@ void starpu_shutdown(void)
 	}
 
 	{
-	     // Display statistics on data which have not been unregistered
-	     const char *stats;
-	     if ((stats = getenv("STARPU_MEMORY_STATS")) && atoi(stats))
+	     int stats = starpu_get_env_number("STARPU_MEMORY_STATS");
+	     if (stats != 0)
 	     {
+		  // Display statistics on data which have not been unregistered
 		  starpu_display_memory_stats();
 	     }
 	}

+ 3 - 3
src/datawizard/memalloc.c

@@ -936,13 +936,13 @@ void _starpu_display_memory_stats_by_node(int node)
 {
 	_STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
 
-	fprintf(stderr, "#-------\n");
-	fprintf(stderr, "Data on Node #%d\n",node);
 	if (!_starpu_mem_chunk_list_empty(mc_list[node]))
 	{
-
 		struct _starpu_mem_chunk *mc;
 
+		fprintf(stderr, "#-------\n");
+		fprintf(stderr, "Data on Node #%d\n",node);
+
 		for (mc = _starpu_mem_chunk_list_begin(mc_list[node]);
 		     mc != _starpu_mem_chunk_list_end(mc_list[node]);
 		     mc = _starpu_mem_chunk_list_next(mc))