Browse Source

port r22014 from 1.2: Fix coherency between enabling profiling and accounting. This makes starpu_profiling_status_set more expensive, but that should not hurt

Samuel Thibault 7 years ago
parent
commit
c47bd0e875
2 changed files with 17 additions and 14 deletions
  1. 17 10
      src/profiling/profiling.c
  2. 0 4
      src/profiling/profiling.h

+ 17 - 10
src/profiling/profiling.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013, 2016-2017  Université de Bordeaux
+ * Copyright (C) 2010-2013, 2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -56,6 +56,9 @@ static unsigned busid_cnt = 0;
 
 static void _starpu_bus_reset_profiling_info(struct starpu_profiling_bus_info *bus_info);
 
+/* Clear all the profiling info related to the worker. */
+static void _starpu_worker_reset_profiling_info_with_lock(int workerid);
+
 /*
  *	Global control of profiling
  */
@@ -74,12 +77,12 @@ void starpu_profiling_init()
 	_starpu_profiling_init();
 }
 
-void _starpu_profiling_reset_counters()
+static void _starpu_profiling_reset_counters()
 {
 	int worker;
 	for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
 	{
-		_starpu_worker_reset_profiling_info(worker);
+		_starpu_worker_reset_profiling_info_with_lock(worker);
 	}
 
 	int busid;
@@ -94,6 +97,12 @@ void _starpu_profiling_reset_counters()
 
 int starpu_profiling_status_set(int status)
 {
+	int worker;
+	for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
+	{
+		STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[worker]);
+	}
+
 	ANNOTATE_HAPPENS_AFTER(&_starpu_profiling);
 	int prev_value = _starpu_profiling;
 	_starpu_profiling = status;
@@ -107,6 +116,11 @@ int starpu_profiling_status_set(int status)
 		_starpu_profiling_reset_counters();
 	}
 
+	for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
+	{
+		STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[worker]);
+	}
+
 	return prev_value;
 }
 
@@ -203,13 +217,6 @@ static void _starpu_worker_reset_profiling_info_with_lock(int workerid)
 	}
 }
 
-void _starpu_worker_reset_profiling_info(int workerid)
-{
-	STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
-	_starpu_worker_reset_profiling_info_with_lock(workerid);
-	STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
-}
-
 void _starpu_worker_restart_sleeping(int workerid)
 {
 	if (starpu_profiling_status_get())

+ 0 - 4
src/profiling/profiling.h

@@ -27,9 +27,6 @@
  * profiling is enabled. */
 struct starpu_profiling_task_info *_starpu_allocate_profiling_info_if_needed(struct starpu_task *task);
 
-/* Clear all the profiling info related to the worker. */
-void _starpu_worker_reset_profiling_info(int workerid);
-
 /* Update the per-worker profiling info after a task (or more) was executed.
  * This tells StarPU how much time was spent doing computation. */
 void _starpu_worker_update_profiling_info_executing(int workerid, struct timespec *executing_time, int executed_tasks, uint64_t used_cycles, uint64_t stall_cycles, double consumed_energy, double flops);
@@ -75,6 +72,5 @@ void _starpu_profiling_init(void);
 void _starpu_profiling_start(void);
 
 void _starpu_profiling_terminate(void);
-void _starpu_profiling_reset_counters();
 
 #endif // __PROFILING_H__