Pārlūkot izejas kodu

src: calculate communication amount between nodes when option --enable-stats is specified to configure

Nathalie Furmento 14 gadi atpakaļ
vecāks
revīzija
2bd91cd1e7
3 mainītis faili ar 22 papildinājumiem un 12 dzēšanām
  1. 2 0
      src/datawizard/copy_driver.c
  2. 18 10
      src/datawizard/datastats.c
  3. 2 2
      src/datawizard/datastats.h

+ 2 - 0
src/datawizard/copy_driver.c

@@ -105,6 +105,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle handle, struct starpu_dat
 	cudaStream_t stream;
 #endif
 
+	_starpu_comm_amounts_inc(src_node, dst_node, handle->ops->get_size(handle));
+
 	void *src_interface = src_replicate->data_interface;
 	void *dst_interface = dst_replicate->data_interface;
 

+ 18 - 10
src/datawizard/datastats.c

@@ -113,29 +113,37 @@ void _starpu_display_alloc_cache_stats(void)
 static size_t comm_ammount[STARPU_MAXNODES][STARPU_MAXNODES];
 #endif /* STARPU_DATA_STATS */
 
+void _starpu_comm_amounts_inc(unsigned src, unsigned dst, size_t size)
+{
+#ifdef STARPU_DATA_STATS
+	comm_ammount[src][dst] += size;
+#endif /* STARPU_DATA_STATS */
+}
+
 void _starpu_display_comm_amounts(void)
 {
 #ifdef STARPU_DATA_STATS
 	unsigned src, dst;
 
-	unsigned long sum = 0;
+	size_t sum = 0;
 
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
-	for (src = 0; src < STARPU_MAXNODES; src++)
-	{
-		sum += (unsigned long)comm_ammount[src][dst];
-	}
+		for (src = 0; src < STARPU_MAXNODES; src++)
+		{
+			sum += (unsigned long)comm_ammount[src][dst];
+			sum += (unsigned long)comm_ammount[dst][src];
+		}
 
-	fprintf(stderr, "\nData transfers stats:\nTOTAL transfers %ld MB\n", sum/(1024*1024));
+	fprintf(stderr, "\nData transfers stats:\nTOTAL transfers %f MB\n", (float)sum/1024/1024);
 
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		for (src = dst + 1; src < STARPU_MAXNODES; src++)
 		{
 			if (comm_ammount[src][dst])
-				fprintf(stderr, "\t%d <-> %d\t%ld MB\n\t\t%d -> %d\t%ld MB\n\t\t%d -> %d\t%ld MB\n",
-					src, dst, ((unsigned long)comm_ammount[src][dst] + (unsigned long)comm_ammount[dst][src])/(1024*1024),
-					src, dst, ((unsigned long)comm_ammount[src][dst])/(1024*1024),
-					dst, src, ((unsigned long)comm_ammount[dst][src])/(1024*1024));
+				fprintf(stderr, "\t%d <-> %d\t%f MB\n\t\t%d -> %d\t%f MB\n\t\t%d -> %d\t%f MB\n",
+					src, dst, ((float)comm_ammount[src][dst] + (float)comm_ammount[dst][src])/(1024*1024),
+					src, dst, ((float)comm_ammount[src][dst])/(1024*1024),
+					dst, src, ((float)comm_ammount[dst][src])/(1024*1024));
 		}
 #endif
 }

+ 2 - 2
src/datawizard/datastats.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -31,7 +31,7 @@ void _starpu_display_msi_stats(void);
 void _starpu_allocation_cache_hit(unsigned node __attribute__ ((unused)));
 void _starpu_data_allocation_inc_stats(unsigned node __attribute__ ((unused)));
 
-
+void _starpu_comm_amounts_inc(unsigned src, unsigned dst, size_t size);
 void _starpu_display_comm_amounts(void);
 void _starpu_display_alloc_cache_stats(void);