Pārlūkot izejas kodu

inline access to profile and top statuses

Samuel Thibault 12 gadi atpakaļ
vecāks
revīzija
9fc59e19cd

+ 4 - 0
include/starpu_profiling.h

@@ -100,6 +100,10 @@ int starpu_profiling_status_set(int status);
 /* Return the current profiling status or a negative value in case there was an
  * error. */
 int starpu_profiling_status_get(void);
+#ifdef BUILDING_STARPU
+extern int _starpu_profiling;
+#define starpu_profiling_status_get() _starpu_profiling
+#endif
 
 /* Get the profiling info associated to a worker, and reset the profiling
  * measurements. If worker_info is NULL, we only reset the counters. */

+ 13 - 13
src/profiling/profiling.c

@@ -58,12 +58,12 @@ static void _starpu_bus_reset_profiling_info(struct starpu_bus_profiling_info *b
  */
 
 /* Disabled by default */
-static int profiling = 0;
+static int _starpu_profiling = 0;
 
 int starpu_profiling_status_set(int status)
 {
-	int prev_value = profiling;
-	profiling = status;
+	int prev_value = _starpu_profiling;
+	_starpu_profiling = status;
 
 	_STARPU_TRACE_SET_PROFILING(status);
 
@@ -90,7 +90,7 @@ int starpu_profiling_status_set(int status)
 
 int starpu_profiling_status_get(void)
 {
-	return profiling;
+	return _starpu_profiling;
 }
 
 void _starpu_profiling_init(void)
@@ -103,7 +103,7 @@ void _starpu_profiling_init(void)
 		_starpu_worker_reset_profiling_info(worker);
 	}
 	if ((env = getenv("STARPU_PROFILING")) && atoi(env))
-		profiling = 1;
+		_starpu_profiling = 1;
 }
 
 void _starpu_profiling_terminate(void)
@@ -120,7 +120,7 @@ struct starpu_task_profiling_info *_starpu_allocate_profiling_info_if_needed(str
 	struct starpu_task_profiling_info *info = NULL;
 
 	/* If we are benchmarking, we need room for the power consumption */
-	if (profiling || (task->cl && task->cl->power_model && (task->cl->power_model->benchmarking || _starpu_get_calibrate_flag())))
+	if (_starpu_profiling || (task->cl && task->cl->power_model && (task->cl->power_model->benchmarking || _starpu_get_calibrate_flag())))
 	{
 		info = (struct starpu_task_profiling_info *) calloc(1, sizeof(struct starpu_task_profiling_info));
 		STARPU_ASSERT(info);
@@ -184,7 +184,7 @@ void _starpu_worker_reset_profiling_info(int workerid)
 
 void _starpu_worker_restart_sleeping(int workerid)
 {
-	if (profiling)
+	if (_starpu_profiling)
 	{
 		struct timespec sleep_start_time;
 		_starpu_clock_gettime(&sleep_start_time);
@@ -198,7 +198,7 @@ void _starpu_worker_restart_sleeping(int workerid)
 
 void _starpu_worker_stop_sleeping(int workerid)
 {
-	if (profiling)
+	if (_starpu_profiling)
 	{
 		struct timespec *sleeping_start, sleep_end_time;
 
@@ -233,7 +233,7 @@ void _starpu_worker_stop_sleeping(int workerid)
 
 void _starpu_worker_register_executing_start_date(int workerid, struct timespec *executing_start)
 {
-	if (profiling)
+	if (_starpu_profiling)
 	{
 		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
 		worker_registered_executing_start[workerid] = 1;
@@ -245,7 +245,7 @@ void _starpu_worker_register_executing_start_date(int workerid, struct timespec
 
 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 power_consumed)
 {
-	if (profiling)
+	if (_starpu_profiling)
 	{
 		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
 
@@ -265,7 +265,7 @@ void _starpu_worker_update_profiling_info_executing(int workerid, struct timespe
 
 int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profiling_info *info)
 {
-	if (!profiling)
+	if (!_starpu_profiling)
 	{
 		/* Not thread safe, shouldn't be too much a problem */
 		info->executed_tasks = worker_info[workerid].executed_tasks;
@@ -312,7 +312,7 @@ int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profilin
 /* When did the task reach the scheduler  ? */
 void _starpu_profiling_set_task_push_start_time(struct starpu_task *task)
 {
-	if (!profiling)
+	if (!_starpu_profiling)
 		return;
 
 	struct starpu_task_profiling_info *profiling_info;
@@ -324,7 +324,7 @@ void _starpu_profiling_set_task_push_start_time(struct starpu_task *task)
 
 void _starpu_profiling_set_task_push_end_time(struct starpu_task *task)
 {
-	if (!profiling)
+	if (!_starpu_profiling)
 		return;
 
 	struct starpu_task_profiling_info *profiling_info;

+ 3 - 3
src/top/starpu_top.c

@@ -29,7 +29,7 @@
 #include <common/utils.h>
 
 extern struct _starpu_top_message_queue*  _starpu_top_mt;
-int starpu_top = 0;
+int _starpu_top = 0;
 int starpu_top_debug_on = 0;
 unsigned int starpu_top_data_cpt = 0;
 unsigned int starpu_top_param_cpt = 0;
@@ -44,7 +44,7 @@ pthread_cond_t starpu_top_wait_for_continue_cond = PTHREAD_COND_INITIALIZER;
 
 int _starpu_top_status_get(void)
 {
-	return starpu_top;
+	return _starpu_top;
 }
 
 static
@@ -133,7 +133,7 @@ static void starpu_top_send_devices_info(void)
 
 void starpu_top_init_and_wait(const char* server_name)
 {
-	starpu_top=1;
+	_starpu_top=1;
 	sem_init(&starpu_top_wait_for_go,0,0);
 
 	_STARPU_PTHREAD_MUTEX_INIT(&starpu_top_wait_for_continue_mutex, NULL);

+ 2 - 0
src/top/starpu_top_core.h

@@ -27,7 +27,9 @@ unsigned long long _starpu_top_timing_timespec_to_ms(const struct timespec *ts);
 /*
  * This function returns 1 if starpu_top is initialized. 0 otherwise.
  */
+extern int _starpu_top;
 int _starpu_top_status_get(void);
+#define _starpu_top_status_get() _starpu_top
 
 /*
  * This functions notify UI than the task has started or ended