Browse Source

cleaning up of statistics code

Nathalie Furmento 12 years ago
parent
commit
5c386a0422

+ 3 - 12
src/core/workers.c

@@ -862,7 +862,6 @@ static void _starpu_kill_all_workers(struct _starpu_machine_config *config)
 
 
 void starpu_shutdown(void)
 void starpu_shutdown(void)
 {
 {
-	const char *stats;
 	_STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 	_STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 	init_count--;
 	init_count--;
 	if (init_count)
 	if (init_count)
@@ -884,19 +883,11 @@ void starpu_shutdown(void)
 	/* tell all workers to shutdown */
 	/* tell all workers to shutdown */
 	_starpu_kill_all_workers(&config);
 	_starpu_kill_all_workers(&config);
 
 
-#ifdef STARPU_MEMORY_STATUS
-	if ((stats = getenv("STARPU_MEMORY_STATS")) && atoi(stats))
-		_starpu_display_data_stats();
-#endif
-
-#ifdef STARPU_DATA_STATS
+	_starpu_display_data_stats();
 	_starpu_display_comm_amounts();
 	_starpu_display_comm_amounts();
-#endif
-	if ((stats = getenv("STARPU_BUS_STATS")) && atoi(stats))
-		starpu_bus_profiling_helper_display_summary();
 
 
-	if ((stats = getenv("STARPU_WORKER_STATS")) && atoi(stats))
-		starpu_worker_profiling_helper_display_summary();
+	starpu_bus_profiling_helper_display_summary();
+	starpu_worker_profiling_helper_display_summary();
 
 
 	_starpu_deinitialize_registered_performance_models();
 	_starpu_deinitialize_registered_performance_models();
 
 

+ 16 - 68
src/datawizard/datastats.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -47,6 +47,7 @@ void _starpu_display_msi_stats(void)
 	unsigned total_hit_cnt = 0;
 	unsigned total_hit_cnt = 0;
 	unsigned total_miss_cnt = 0;
 	unsigned total_miss_cnt = 0;
 
 
+	fprintf(stderr, "\n#---------------------\n");
 	fprintf(stderr, "MSI cache stats :\n");
 	fprintf(stderr, "MSI cache stats :\n");
 
 
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	for (node = 0; node < STARPU_MAXNODES; node++)
@@ -66,6 +67,7 @@ void _starpu_display_msi_stats(void)
 			fprintf(stderr, "\tmiss : %u (%2.2f \%%)\n", miss_cnt[node], (100.0f*miss_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
 			fprintf(stderr, "\tmiss : %u (%2.2f \%%)\n", miss_cnt[node], (100.0f*miss_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
 		}
 		}
 	}
 	}
+	fprintf(stderr, "#---------------------\n");
 #endif
 #endif
 }
 }
 
 
@@ -93,6 +95,7 @@ void _starpu_data_allocation_inc_stats(unsigned node __attribute__ ((unused)))
 void _starpu_display_alloc_cache_stats(void)
 void _starpu_display_alloc_cache_stats(void)
 {
 {
 #ifdef STARPU_DATA_STATS
 #ifdef STARPU_DATA_STATS
+	fprintf(stderr, "\n#---------------------\n");
 	fprintf(stderr, "Allocation cache stats:\n");
 	fprintf(stderr, "Allocation cache stats:\n");
 	unsigned node;
 	unsigned node;
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	for (node = 0; node < STARPU_MAXNODES; node++)
@@ -104,7 +107,10 @@ void _starpu_display_alloc_cache_stats(void)
 			fprintf(stderr, "\tcached alloc: %u (%2.2f \%%)\n",
 			fprintf(stderr, "\tcached alloc: %u (%2.2f \%%)\n",
 				alloc_cache_hit_cnt[node], (100.0f*alloc_cache_hit_cnt[node])/(alloc_cnt[node]));
 				alloc_cache_hit_cnt[node], (100.0f*alloc_cache_hit_cnt[node])/(alloc_cnt[node]));
 		}
 		}
+		else
+			fprintf(stderr, "No allocation on node %d\n", node);
 	}
 	}
+	fprintf(stderr, "#---------------------\n");
 #endif
 #endif
 }
 }
 
 
@@ -122,11 +128,17 @@ void _starpu_comm_amounts_inc(unsigned src  __attribute__ ((unused)), unsigned d
 
 
 void _starpu_display_comm_amounts(void)
 void _starpu_display_comm_amounts(void)
 {
 {
+#ifdef STARPU_DEVEL
+#  warning TODO. The information displayed here seems to be similar to the one displayed by starpu_bus_profiling_helper_display_summary()
+#endif
+
 #ifdef STARPU_DATA_STATS
 #ifdef STARPU_DATA_STATS
 	unsigned src, dst;
 	unsigned src, dst;
-
 	size_t sum = 0;
 	size_t sum = 0;
 
 
+	fprintf(stderr, "\n#---------------------\n");
+	fprintf(stderr, "Data transfer stats:\n");
+
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		for (src = 0; src < STARPU_MAXNODES; src++)
 		for (src = 0; src < STARPU_MAXNODES; src++)
 		{
 		{
@@ -134,7 +146,7 @@ void _starpu_display_comm_amounts(void)
 			sum += comm_amount[dst][src];
 			sum += comm_amount[dst][src];
 		}
 		}
 
 
-	fprintf(stderr, "\nData transfers stats:\nTOTAL transfers %f MB\n", (float)sum/1024/1024);
+	fprintf(stderr, "TOTAL transfers %f MB\n", (float)sum/1024/1024);
 
 
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
 	for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		for (src = dst + 1; src < STARPU_MAXNODES; src++)
 		for (src = dst + 1; src < STARPU_MAXNODES; src++)
@@ -145,71 +157,7 @@ void _starpu_display_comm_amounts(void)
 					src, dst, ((float)comm_amount[src][dst])/(1024*1024),
 					src, dst, ((float)comm_amount[src][dst])/(1024*1024),
 					dst, src, ((float)comm_amount[dst][src])/(1024*1024));
 					dst, src, ((float)comm_amount[dst][src])/(1024*1024));
 		}
 		}
+	fprintf(stderr, "#---------------------\n");
 #endif
 #endif
 }
 }
 
 
-#ifdef STARPU_MEMORY_STATUS
-void _starpu_display_data_stats(void)
-{
-	unsigned node;
-	for (node = 0; node < STARPU_MAXNODES; node++)
-	{
-		_starpu_display_data_stats_by_node(node);
-	}
-}
-
-void _starpu_display_data_handle_stats(starpu_data_handle_t handle)
-{
-	unsigned node;
-
-	fprintf(stderr, "#-----\n");
-	fprintf(stderr, "Data : %p\n", handle);
-	fprintf(stderr, "Size : %d\n", (int)handle->data_size);
-	fprintf(stderr, "\n");
-
-	fprintf(stderr, "#--\n");
-	fprintf(stderr, "Data access stats\n");
-	fprintf(stderr, "/!\\ Work Underway\n");
-	for (node = 0; node < STARPU_MAXNODES; node++)
-	{
-		if (handle->stats_direct_access[node]+handle->stats_loaded_shared[node]
-		    +handle->stats_invalidated[node]+handle->stats_loaded_owner[node])
-		{
-			fprintf(stderr, "Node #%d\n", node);
-			fprintf(stderr, "\tDirect access : %d\n", handle->stats_direct_access[node]);
-			/* XXX Not Working yet. */
-			if (handle->stats_shared_to_owner[node])
-				fprintf(stderr, "\t\tShared to Owner : %d\n", handle->stats_shared_to_owner[node]);
-			fprintf(stderr, "\tLoaded (Owner) : %d\n", handle->stats_loaded_owner[node]);
-			fprintf(stderr, "\tLoaded (Shared) : %d\n", handle->stats_loaded_shared[node]);
-			fprintf(stderr, "\tInvalidated (was Owner) : %d\n\n", handle->stats_invalidated[node]);
-		}
-	}
-}
-
-void _starpu_handle_stats_cache_hit(starpu_data_handle_t handle, unsigned node)
-{
-	handle->stats_direct_access[node]++;
-}
-
-void _starpu_handle_stats_loaded_shared(starpu_data_handle_t handle, unsigned node)
-{
-	handle->stats_loaded_shared[node]++;
-}
-
-void _starpu_handle_stats_loaded_owner(starpu_data_handle_t handle, unsigned node)
-{
-	handle->stats_loaded_owner[node]++;
-}
-
-void _starpu_handle_stats_shared_to_owner(starpu_data_handle_t handle, unsigned node)
-{
-	handle->stats_shared_to_owner[node]++;
-}
-
-void _starpu_handle_stats_invalidated(starpu_data_handle_t handle, unsigned node)
-{
-	handle->stats_invalidated[node]++;
-}
-
-#endif

+ 1 - 11
src/datawizard/datastats.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -35,14 +35,4 @@ void _starpu_comm_amounts_inc(unsigned src, unsigned dst, size_t size);
 void _starpu_display_comm_amounts(void);
 void _starpu_display_comm_amounts(void);
 void _starpu_display_alloc_cache_stats(void);
 void _starpu_display_alloc_cache_stats(void);
 
 
-void _starpu_display_data_stats();
-void _starpu_display_data_handle_stats(starpu_data_handle_t handle);
-
-void _starpu_handle_stats_cache_hit(starpu_data_handle_t handle, unsigned node);
-void _starpu_handle_stats_loaded_shared(starpu_data_handle_t handle, unsigned node);
-void _starpu_handle_stats_loaded_owner(starpu_data_handle_t handle, unsigned node);
-void _starpu_handle_stats_shared_to_owner(starpu_data_handle_t handle, unsigned node);
-void _starpu_handle_stats_invalidated(starpu_data_handle_t handle, unsigned node);
-
-
 #endif // __DATASTATS_H__
 #endif // __DATASTATS_H__

+ 79 - 3
src/datawizard/memalloc.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2009-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -936,10 +936,10 @@ void _starpu_display_data_stats_by_node(int node)
 {
 {
 	_STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[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]))
 	if (!_starpu_mem_chunk_list_empty(mc_list[node]))
 	{
 	{
-		fprintf(stderr, "#-------\n");
-		fprintf(stderr, "Data on Node #%d\n",node);
 
 
 		struct _starpu_mem_chunk *mc;
 		struct _starpu_mem_chunk *mc;
 
 
@@ -955,3 +955,79 @@ void _starpu_display_data_stats_by_node(int node)
 	_STARPU_PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
 	_STARPU_PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
 }
 }
 #endif
 #endif
+
+void _starpu_display_data_stats(void)
+{
+#ifdef STARPU_MEMORY_STATUS
+	unsigned node;
+	const char *stats;
+
+	if ((stats = getenv("STARPU_MEMORY_STATS")) && atoi(stats))
+	{
+		fprintf(stderr, "\n#---------------------\n");
+		fprintf(stderr, "Memory allocation stats :\n");
+		for (node = 0; node < STARPU_MAXNODES; node++)
+		{
+			_starpu_display_data_stats_by_node(node);
+		}
+		fprintf(stderr, "\n#---------------------\n");
+	}
+#endif
+}
+
+#ifdef STARPU_MEMORY_STATUS
+void _starpu_display_data_handle_stats(starpu_data_handle_t handle)
+{
+	unsigned node;
+
+	fprintf(stderr, "#-----\n");
+	fprintf(stderr, "Data : %p\n", handle);
+	fprintf(stderr, "Size : %d\n", (int)handle->data_size);
+	fprintf(stderr, "\n");
+
+	fprintf(stderr, "#--\n");
+	fprintf(stderr, "Data access stats\n");
+	fprintf(stderr, "/!\\ Work Underway\n");
+	for (node = 0; node < STARPU_MAXNODES; node++)
+	{
+		if (handle->stats_direct_access[node]+handle->stats_loaded_shared[node]
+		    +handle->stats_invalidated[node]+handle->stats_loaded_owner[node])
+		{
+			fprintf(stderr, "Node #%d\n", node);
+			fprintf(stderr, "\tDirect access : %d\n", handle->stats_direct_access[node]);
+			/* XXX Not Working yet. */
+			if (handle->stats_shared_to_owner[node])
+				fprintf(stderr, "\t\tShared to Owner : %d\n", handle->stats_shared_to_owner[node]);
+			fprintf(stderr, "\tLoaded (Owner) : %d\n", handle->stats_loaded_owner[node]);
+			fprintf(stderr, "\tLoaded (Shared) : %d\n", handle->stats_loaded_shared[node]);
+			fprintf(stderr, "\tInvalidated (was Owner) : %d\n\n", handle->stats_invalidated[node]);
+		}
+	}
+}
+
+void _starpu_handle_stats_cache_hit(starpu_data_handle_t handle, unsigned node)
+{
+	handle->stats_direct_access[node]++;
+}
+
+void _starpu_handle_stats_loaded_shared(starpu_data_handle_t handle, unsigned node)
+{
+	handle->stats_loaded_shared[node]++;
+}
+
+void _starpu_handle_stats_loaded_owner(starpu_data_handle_t handle, unsigned node)
+{
+	handle->stats_loaded_owner[node]++;
+}
+
+void _starpu_handle_stats_shared_to_owner(starpu_data_handle_t handle, unsigned node)
+{
+	handle->stats_shared_to_owner[node]++;
+}
+
+void _starpu_handle_stats_invalidated(starpu_data_handle_t handle, unsigned node)
+{
+	handle->stats_invalidated[node]++;
+}
+
+#endif

+ 10 - 1
src/datawizard/memalloc.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009, 2010, 2012  Université de Bordeaux 1
  * Copyright (C) 2009, 2010, 2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -64,4 +64,13 @@ size_t _starpu_free_all_automatically_allocated_buffers(uint32_t node);
 void _starpu_memchunk_recently_used(struct _starpu_mem_chunk *mc, unsigned node);
 void _starpu_memchunk_recently_used(struct _starpu_mem_chunk *mc, unsigned node);
 
 
 void _starpu_display_data_stats_by_node(int node);
 void _starpu_display_data_stats_by_node(int node);
+void _starpu_display_data_stats();
+void _starpu_display_data_handle_stats(starpu_data_handle_t handle);
+
+void _starpu_handle_stats_cache_hit(starpu_data_handle_t handle, unsigned node);
+void _starpu_handle_stats_loaded_shared(starpu_data_handle_t handle, unsigned node);
+void _starpu_handle_stats_loaded_owner(starpu_data_handle_t handle, unsigned node);
+void _starpu_handle_stats_shared_to_owner(starpu_data_handle_t handle, unsigned node);
+void _starpu_handle_stats_invalidated(starpu_data_handle_t handle, unsigned node);
+
 #endif
 #endif

+ 11 - 4
src/profiling/profiling_helpers.c

@@ -20,8 +20,11 @@
 
 
 void starpu_bus_profiling_helper_display_summary(void)
 void starpu_bus_profiling_helper_display_summary(void)
 {
 {
+	const char *stats;
 	int long long sum_transferred = 0;
 	int long long sum_transferred = 0;
 
 
+	if (!((stats = getenv("STARPU_BUS_STATS")) && atoi(stats))) return;
+
 	fprintf(stderr, "\nData transfer statistics:\n");
 	fprintf(stderr, "\nData transfer statistics:\n");
 	fprintf(stderr,   "*************************\n");
 	fprintf(stderr,   "*************************\n");
 
 
@@ -51,19 +54,23 @@ void starpu_bus_profiling_helper_display_summary(void)
 
 
 void starpu_worker_profiling_helper_display_summary(void)
 void starpu_worker_profiling_helper_display_summary(void)
 {
 {
+	const char *stats;
 	double sum_consumed = 0.;
 	double sum_consumed = 0.;
 	int profiling = starpu_profiling_status_get();
 	int profiling = starpu_profiling_status_get();
-	fprintf(stderr, "\nWorker statistics:\n");
-	fprintf(stderr,   "******************\n");
 	double overall_time = 0;
 	double overall_time = 0;
-
 	int workerid;
 	int workerid;
 	int worker_cnt = starpu_worker_get_count();
 	int worker_cnt = starpu_worker_get_count();
+
+	if (!((stats = getenv("STARPU_WORKER_STATS")) && atoi(stats))) return;
+
+	fprintf(stderr, "\nWorker statistics:\n");
+	fprintf(stderr,   "******************\n");
+
 	for (workerid = 0; workerid < worker_cnt; workerid++)
 	for (workerid = 0; workerid < worker_cnt; workerid++)
 	{
 	{
 		struct starpu_worker_profiling_info info;
 		struct starpu_worker_profiling_info info;
 		starpu_worker_get_profiling_info(workerid, &info);
 		starpu_worker_get_profiling_info(workerid, &info);
-		char name[32];
+		char name[64];
 
 
 		starpu_worker_get_name(workerid, name, sizeof(name));
 		starpu_worker_get_name(workerid, name, sizeof(name));