Browse Source

mpi: Communication statistics can also be enabled at execution time by defining the environment variable STARPU_COMM_STATS

Nathalie Furmento 12 years ago
parent
commit
121fd8f349
3 changed files with 28 additions and 14 deletions
  1. 2 0
      ChangeLog
  2. 7 0
      doc/chapters/configuration.texi
  3. 19 14
      mpi/src/starpu_mpi_stats.c

+ 2 - 0
ChangeLog

@@ -36,6 +36,8 @@ New features:
   * SOCL
         - Manual mapping of commands on specific devices is now possible
   * New interface: COO matrix.
+  * Communication statistics for MPI can also be enabled at execution
+    time by defining the environment variable STARPU_COMM_STATS
 
 Changes:
   * Fix the block filter functions.

+ 7 - 0
doc/chapters/configuration.texi

@@ -171,6 +171,7 @@ Use the @command{mpicc} compiler at @var{path}, for starpumpi
 (@pxref{StarPU MPI support}).
 
 @item --enable-comm-stats
+@anchor{enable-comm-stats}
 Enable communication statistics for starpumpi (@pxref{StarPU MPI
 support}).
 
@@ -420,6 +421,12 @@ THE SOCL test suite is only run when the environment variable
 @code{SOCL_OCL_LIB_OPENCL} is defined. It should contain the location
 of the libOpenCL.so file of the OCL ICD implementation.
 
+@item @code{STARPU_COMM_STATS}
+Communication statistics for starpumpi (@pxref{StarPU MPI support})
+will be enabled when the environment variable @code{STARPU_COMM_STATS}
+is defined. The statistics can also be enabled by configuring StarPU
+with the option @code{--enable-comm-stats} (@pxref{enable-comm-stats}).
+
 @end table
 
 @node Misc

+ 19 - 14
mpi/src/starpu_mpi_stats.c

@@ -21,53 +21,59 @@
 #include <starpu_mpi_private.h>
 
 /* measure the amount of data transfers between each pair of MPI nodes */
-#ifdef STARPU_COMM_STATS
 static size_t *comm_amount;
 static int world_size;
-#endif /* STARPU_COMM_STATS */
+static int stats_enabled=0;
 
 void _starpu_mpi_comm_amounts_init(MPI_Comm comm)
 {
 #ifdef STARPU_COMM_STATS
-	if (!getenv("STARPU_SILENT")) fprintf(stderr,"Warning: StarPU was configured with --enable-comm-stats, which slows down a bit\n");
+	stats_enabled = 1;
+#else
+	stats_enabled = starpu_get_env_number("STARPU_COMM_STATS");
+	if (stats_enabled == -1)
+	{
+		stats_enabled = 0;
+	}
+#endif /* STARPU_COMM_STATS */
+
+	if (stats_enabled == 0) return;
+
+	if (!getenv("STARPU_SILENT")) fprintf(stderr,"Warning: StarPU was configured with --enable-comm-stats or is executed with STARPU_COMM_STATS=1, which slows down a bit\n");
 
 	MPI_Comm_size(comm, &world_size);
 	_STARPU_MPI_DEBUG("allocating for %d nodes\n", world_size);
 
 	comm_amount = (size_t *) calloc(world_size, sizeof(size_t));
-#endif /* STARPU_COMM_STATS */
 }
 
 void _starpu_mpi_comm_amounts_free()
 {
-#ifdef STARPU_COMM_STATS
+	if (stats_enabled == 0) return;
 	free(comm_amount);
-#endif /* STARPU_COMM_STATS */
 }
 
-void _starpu_mpi_comm_amounts_inc(MPI_Comm comm  __attribute__ ((unused)),
-				  unsigned dst  __attribute__ ((unused)),
-				  MPI_Datatype datatype  __attribute__ ((unused)),
-				  int count __attribute__ ((unused)))
+void _starpu_mpi_comm_amounts_inc(MPI_Comm comm, unsigned dst, MPI_Datatype datatype, int count)
 {
-#ifdef STARPU_COMM_STATS
 	int src, size;
 
+	if (stats_enabled == 0) return;
+
 	MPI_Comm_rank(comm, &src);
 	MPI_Type_size(datatype, &size);
 
 	_STARPU_MPI_DEBUG("[%d] adding %d to %d\n", src, count*size, dst);
 
 	comm_amount[dst] += count*size;
-#endif /* STARPU_COMM_STATS */
 }
 
 void _starpu_mpi_comm_amounts_display(int node)
 {
-#ifdef STARPU_COMM_STATS
 	unsigned dst;
 	size_t sum = 0;
 
+	if (stats_enabled == 0) return;
+
 	for (dst = 0; dst < world_size; dst++)
 	{
 		sum += comm_amount[dst];
@@ -83,6 +89,5 @@ void _starpu_mpi_comm_amounts_display(int node)
 				node, dst, (float)comm_amount[dst], ((float)comm_amount[dst])/(1024*1024));
 		}
 	}
-#endif /* STARPU_COMM_STATS */
 }