瀏覽代碼

src: use _STARPU_MSG instead of fprintf and avoid direct calls to fprintf(stderr, ...)

Nathalie Furmento 8 年之前
父節點
當前提交
d917eaa107

+ 3 - 3
src/common/fxt.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  *
  * 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
@@ -199,7 +199,7 @@ void _starpu_stop_fxt_profiling(void)
 #ifdef STARPU_VERBOSE
 	        char hostname[128];
 		gethostname(hostname, 128);
-		fprintf(stderr, "Writing FxT traces into file %s:%s\n", hostname, _STARPU_PROF_FILE_USER);
+		_STARPU_MSG("Writing FxT traces into file %s:%s\n", hostname, _STARPU_PROF_FILE_USER);
 #endif
 		fut_endup(_STARPU_PROF_FILE_USER);
 
@@ -213,7 +213,7 @@ void _starpu_stop_fxt_profiling(void)
 		{
 			/* Something went wrong with the FxT trace (eg. there
 			 * was too many events) */
-			fprintf(stderr, "Warning: the FxT trace could not be generated properly\n");
+			_STARPU_MSG("Warning: the FxT trace could not be generated properly\n");
 		}
 
 		_starpu_written = 1;

+ 3 - 3
src/common/utils.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2012-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  *
  * 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
@@ -104,7 +104,7 @@ int _starpu_mkpath(const char *s, mode_t mode)
 	{
 		if (!S_ISDIR(sb.st_mode))
 		{
-			fprintf(stderr,"Error: %s is not a directory:\n", path);
+			_STARPU_MSG("Error: %s is not a directory:\n", path);
 			STARPU_ABORT();
 		}
 		/* It already exists and is a directory.  */
@@ -137,7 +137,7 @@ void _starpu_mkpath_and_check(const char *path, mode_t mode)
 
 	if (ret == -1 && errno != EEXIST)
 	{
-		fprintf(stderr,"Error making StarPU directory %s:\n", path);
+		_STARPU_MSG("Error making StarPU directory %s:\n", path);
 		perror("mkdir");
 		STARPU_ABORT();
 	}

+ 2 - 2
src/core/perfmodel/perfmodel_history.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2016  Inria
  *
@@ -1101,7 +1101,7 @@ int starpu_perfmodel_list(FILE *output)
         }
 	return 0;
 #else
-	fprintf(stderr,"Listing perfmodels is not implemented on pure Windows yet\n");
+	_STARPU_MSG("Listing perfmodels is not implemented on pure Windows yet\n");
 	return 1;
 #endif
 }

+ 7 - 7
src/core/sched_policy.c

@@ -144,7 +144,7 @@ static struct starpu_sched_policy *find_sched_policy_from_name(const char *polic
 	return NULL;
 }
 
-static void display_sched_help_message(void)
+static void display_sched_help_message(FILE *stream)
 {
 	const char *sched_env = starpu_getenv("STARPU_SCHED");
 	if (sched_env && (strcmp(sched_env, "help") == 0))
@@ -152,13 +152,13 @@ static void display_sched_help_message(void)
 		/* display the description of all predefined policies */
 		struct starpu_sched_policy **policy;
 
-		fprintf(stderr, "\nThe variable STARPU_SCHED can be set to one of the following strings:\n");
+		fprintf(stream, "\nThe variable STARPU_SCHED can be set to one of the following strings:\n");
 		for(policy=predefined_policies ; *policy!=NULL ; policy++)
 		{
 			struct starpu_sched_policy *p = *policy;
-			fprintf(stderr, "%-30s\t-> %s\n", p->policy_name, p->policy_description);
+			fprintf(stream, "%-30s\t-> %s\n", p->policy_name, p->policy_description);
 		}
-		fprintf(stderr, "\n");
+		fprintf(stream, "\n");
 	 }
 }
 
@@ -197,7 +197,7 @@ struct starpu_sched_policy *_starpu_select_sched_policy(struct _starpu_machine_c
 void _starpu_init_sched_policy(struct _starpu_machine_config *config, struct _starpu_sched_ctx *sched_ctx, struct starpu_sched_policy *selected_policy)
 {
 	/* Perhaps we have to display some help */
-	display_sched_help_message();
+	display_sched_help_message(stderr);
 
 	/* Prefetch is activated by default */
 	use_prefetch = starpu_get_env_number("STARPU_PREFETCH");
@@ -598,7 +598,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 
 		if(ret == -1)
 		{
-			fprintf(stderr, "repush task \n");
+			_STARPU_MSG("repush task \n");
 			_STARPU_TRACE_JOB_POP(task, task->priority > 0);
 			ret = _starpu_push_task_to_workers(task);
 		}
@@ -1128,7 +1128,7 @@ void _starpu_print_idle_time()
 	f = fopen(starpu_idle_file, "a");
 	if (!f)
 	{
-		fprintf(stderr, "couldn't open %s: %s\n", starpu_idle_file, strerror(errno));
+		_STARPU_MSG("couldn't open %s: %s\n", starpu_idle_file, strerror(errno));
 	}
 	else
 	{

+ 4 - 4
src/core/task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011, 2014, 2016  INRIA
  * Copyright (C) 2016  Uppsala University
@@ -1227,14 +1227,14 @@ static void *watchdog_func(void *arg)
 		if (!config->watchdog_ok && last_nsubmitted
 				&& last_nsubmitted == starpu_task_nsubmitted())
 		{
-			fprintf(stderr,"The StarPU watchdog detected that no task finished for %fs (can be configure through STARPU_WATCHDOG_TIMEOUT)\n", timeout);
+			_STARPU_MSG("The StarPU watchdog detected that no task finished for %fs (can be configured through STARPU_WATCHDOG_TIMEOUT)\n", timeout);
 			if (watchdog_crash)
 			{
-				fprintf(stderr,"Crashing the process\n");
+				_STARPU_MSG("Crashing the process\n");
 				raise(SIGABRT);
 			}
 			else
-				fprintf(stderr,"Set the STARPU_WATCHDOG_CRASH environment variable if you want to abort the process in such a case\n");
+				_STARPU_MSG("Set the STARPU_WATCHDOG_CRASH environment variable if you want to abort the process in such a case\n");
 		}
 		/* Only shout again after another period */
 		config->watchdog_ok = 1;

+ 7 - 11
src/core/topology.c

@@ -447,10 +447,10 @@ _starpu_init_mic_node (struct _starpu_machine_config *config, int mic_idx,
 
 	if (0 != mic_file_found)
 	{
-		fprintf(stderr, "No MIC program specified, use the environment\n"
-			"variable STARPU_MIC_SINK_PROGRAM_NAME or the environment\n"
-			"or the field 'starpu_conf.mic_sink_program_path'\n"
-			"to define it.\n");
+		_STARPU_MSG("No MIC program specified, use the environment\n"
+			    "variable STARPU_MIC_SINK_PROGRAM_NAME or the environment\n"
+			    "or the field 'starpu_conf.mic_sink_program_path'\n"
+			    "to define it.\n");
 
 		return -1;
 	}
@@ -832,9 +832,7 @@ _starpu_init_mic_config (struct _starpu_machine_config *config,
 		if ((unsigned) nmiccores > topology->nhwmiccores[mic_idx])
 		{
 			/* The user requires more MIC cores than there is available */
-			fprintf(stderr,
-				"# Warning: %d MIC cores requested. Only %d available.\n",
-				nmiccores, topology->nhwmiccores[mic_idx]);
+			_STARPU_MSG("# Warning: %d MIC cores requested. Only %d available.\n", nmiccores, topology->nhwmiccores[mic_idx]);
 			nmiccores = topology->nhwmiccores[mic_idx];
 		}
 	}
@@ -905,9 +903,7 @@ _starpu_init_mp_config (struct _starpu_machine_config *config,
 		if ((unsigned) reqmicdevices > nhwmicdevices)
 		{
 			/* The user requires more MIC devices than there is available */
-			fprintf(stderr,
-				"# Warning: %d MIC devices requested. Only %d available.\n",
-				reqmicdevices, nhwmicdevices);
+			_STARPU_MSG("# Warning: %d MIC devices requested. Only %d available.\n", reqmicdevices, nhwmicdevices);
 			reqmicdevices = nhwmicdevices;
 		}
 	}
@@ -1457,7 +1453,7 @@ _starpu_bind_thread_on_cpu (
 	if (ret)
 	{
 		const char *msg = strerror(ret);
-		fprintf(stderr, "pthread_setaffinity_np: %s\n", msg);
+		_STARPU_MSG("pthread_setaffinity_np: %s\n", msg);
 		STARPU_ABORT();
 	}
 

+ 2 - 2
src/core/workers.c

@@ -1522,8 +1522,8 @@ void starpu_shutdown(void)
 	     int stats = starpu_get_env_number("STARPU_STATS");
 	     if (stats != 0)
 	     {
-		  _starpu_display_msi_stats();
-		  _starpu_display_alloc_cache_stats();
+		  _starpu_display_msi_stats(stderr);
+		  _starpu_display_alloc_cache_stats(stderr);
 	     }
 	}
 

+ 1 - 3
src/datawizard/coherency.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017  CNRS
  * Copyright (C) 2014-2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -271,8 +271,6 @@ struct _starpu_data_state
 	void *user_data;
 };
 
-void _starpu_display_msi_stats(void);
-
 /* This does not take a reference on the handle, the caller has to do it,
  * e.g. through _starpu_attempt_to_submit_data_request_from_apps()
  * detached means that the core is allowed to drop the request. The caller

+ 17 - 17
src/datawizard/datastats.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2013, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2015, 2016, 2017  CNRS
  *
  * 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
@@ -43,7 +43,7 @@ void __starpu_msi_cache_miss(unsigned node)
 	miss_cnt[node]++;
 }
 
-void _starpu_display_msi_stats(void)
+void _starpu_display_msi_stats(FILE *stream)
 {
 	if (!starpu_enable_stats())
 		return;
@@ -52,8 +52,8 @@ void _starpu_display_msi_stats(void)
 	unsigned total_hit_cnt = 0;
 	unsigned total_miss_cnt = 0;
 
-	fprintf(stderr, "\n#---------------------\n");
-	fprintf(stderr, "MSI cache stats :\n");
+	fprintf(stream, "\n#---------------------\n");
+	fprintf(stream, "MSI cache stats :\n");
 
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	{
@@ -61,18 +61,18 @@ void _starpu_display_msi_stats(void)
 		total_miss_cnt += miss_cnt[node];
 	}
 
-	fprintf(stderr, "TOTAL MSI stats\thit %u (%2.2f %%)\tmiss %u (%2.2f %%)\n", total_hit_cnt, (100.0f*total_hit_cnt)/(total_hit_cnt+total_miss_cnt), total_miss_cnt, (100.0f*total_miss_cnt)/(total_hit_cnt+total_miss_cnt));
+	fprintf(stream, "TOTAL MSI stats\thit %u (%2.2f %%)\tmiss %u (%2.2f %%)\n", total_hit_cnt, (100.0f*total_hit_cnt)/(total_hit_cnt+total_miss_cnt), total_miss_cnt, (100.0f*total_miss_cnt)/(total_hit_cnt+total_miss_cnt));
 
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	{
 		if (hit_cnt[node]+miss_cnt[node])
 		{
-			fprintf(stderr, "memory node %u\n", node);
-			fprintf(stderr, "\thit : %u (%2.2f %%)\n", hit_cnt[node], (100.0f*hit_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(stream, "memory node %u\n", node);
+			fprintf(stream, "\thit : %u (%2.2f %%)\n", hit_cnt[node], (100.0f*hit_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
+			fprintf(stream, "\tmiss : %u (%2.2f %%)\n", miss_cnt[node], (100.0f*miss_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
 		}
 	}
-	fprintf(stderr, "#---------------------\n");
+	fprintf(stream, "#---------------------\n");
 }
 
 /* measure the efficiency of our allocation cache */
@@ -91,25 +91,25 @@ void __starpu_data_allocation_inc_stats(unsigned node)
 	alloc_cnt[node]++;
 }
 
-void _starpu_display_alloc_cache_stats(void)
+void _starpu_display_alloc_cache_stats(FILE *stream)
 {
 	if (!starpu_enable_stats())
 		return;
 
-	fprintf(stderr, "\n#---------------------\n");
-	fprintf(stderr, "Allocation cache stats:\n");
+	fprintf(stream, "\n#---------------------\n");
+	fprintf(stream, "Allocation cache stats:\n");
 	unsigned node;
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	{
 		if (alloc_cnt[node])
 		{
-			fprintf(stderr, "memory node %u\n", node);
-			fprintf(stderr, "\ttotal alloc : %u\n", alloc_cnt[node]);
-			fprintf(stderr, "\tcached alloc: %u (%2.2f %%)\n",
+			fprintf(stream, "memory node %u\n", node);
+			fprintf(stream, "\ttotal alloc : %u\n", alloc_cnt[node]);
+			fprintf(stream, "\tcached alloc: %u (%2.2f %%)\n",
 				alloc_cache_hit_cnt[node], (100.0f*alloc_cache_hit_cnt[node])/(alloc_cnt[node]));
 		}
 		else
-			fprintf(stderr, "No allocation on node %u\n", node);
+			fprintf(stream, "No allocation on node %u\n", node);
 	}
-	fprintf(stderr, "#---------------------\n");
+	fprintf(stream, "#---------------------\n");
 }

+ 3 - 3
src/datawizard/datastats.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2015, 2017  CNRS
  *
  * 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
@@ -45,7 +45,7 @@ void __starpu_msi_cache_miss(unsigned node);
 		__starpu_msi_cache_miss(node); \
 } while (0)
 
-void _starpu_display_msi_stats(void);
+void _starpu_display_msi_stats(FILE *stream);
 
 void __starpu_allocation_cache_hit(unsigned node STARPU_ATTRIBUTE_UNUSED);
 void __starpu_data_allocation_inc_stats(unsigned node STARPU_ATTRIBUTE_UNUSED);
@@ -60,6 +60,6 @@ void __starpu_data_allocation_inc_stats(unsigned node STARPU_ATTRIBUTE_UNUSED);
 		__starpu_data_allocation_inc_stats(node); \
 } while (0)
 
-void _starpu_display_alloc_cache_stats(void);
+void _starpu_display_alloc_cache_stats(FILE *stream);
 
 #endif // __DATASTATS_H__

+ 23 - 20
src/datawizard/memalloc.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2017  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -492,7 +492,7 @@ static size_t try_to_free_mem_chunk(struct _starpu_mem_chunk *mc, unsigned node)
 
 			/* in case there was nobody using that buffer, throw it
 			 * away after writing it back to main memory */
-			
+
 			/* choose the best target */
 			target = choose_target(handle, node);
 
@@ -767,7 +767,6 @@ restart:
 
 		if (mc->data->is_not_important && (mc->footprint == footprint))
 		{
-//			fprintf(stderr, "found a candidate ...\n");
 			/* Note: this may unlock mc_list! */
 			success = try_to_reuse_mem_chunk(mc, node, replicate, 1);
 		}
@@ -1518,7 +1517,7 @@ void _starpu_memchunk_dirty(struct _starpu_mem_chunk *mc, unsigned node)
 }
 
 #ifdef STARPU_MEMORY_STATS
-void _starpu_memory_display_stats_by_node(int node)
+void _starpu_memory_display_stats_by_node(FILE *stream, int node)
 {
 	_starpu_spin_lock(&mc_lock[node]);
 
@@ -1526,38 +1525,42 @@ void _starpu_memory_display_stats_by_node(int node)
 	{
 		struct _starpu_mem_chunk *mc;
 
-		fprintf(stderr, "#-------\n");
-		fprintf(stderr, "Data on Node #%d\n",node);
+		fprintf(stream, "#-------\n");
+		fprintf(stream, "Data on Node #%d\n",node);
 
 		for (mc = _starpu_mem_chunk_list_begin(&mc_list[node]);
 		     mc != _starpu_mem_chunk_list_end(&mc_list[node]);
 		     mc = _starpu_mem_chunk_list_next(mc))
 		{
 			if (mc->automatically_allocated == 0)
-				_starpu_memory_display_handle_stats(mc->data);
+				_starpu_memory_display_handle_stats(stream, mc->data);
 		}
 
 	}
 
 	_starpu_spin_unlock(&mc_lock[node]);
 }
-#endif
 
-void starpu_data_display_memory_stats(void)
+void _starpu_data_display_memory_stats(FILE *stream)
 {
-#ifdef STARPU_MEMORY_STATS
 	unsigned node;
 
-	fprintf(stderr, "\n#---------------------\n");
-	fprintf(stderr, "Memory stats :\n");
+	fprintf(stream, "\n#---------------------\n");
+	fprintf(stream, "Memory stats :\n");
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	{
-	     _starpu_memory_display_stats_by_node(node);
+		_starpu_memory_display_stats_by_node(stream, node);
 	}
-	fprintf(stderr, "\n#---------------------\n");
-#endif
+	fprintf(stream, "\n#---------------------\n");
 }
+#endif
 
+void starpu_data_display_memory_stats(void)
+{
+#ifdef STARPU_MEMORY_STATS
+	_starpu_data_display_memory_stats(stderr);
+#endif
+}
 
 static int
 get_better_disk_can_accept_size(starpu_data_handle_t handle, unsigned node)
@@ -1566,7 +1569,7 @@ get_better_disk_can_accept_size(starpu_data_handle_t handle, unsigned node)
 	unsigned nnodes = starpu_memory_nodes_get_count();
 	unsigned int i;
 	double time_disk = 0;
-				
+
 	for (i = 0; i < nnodes; i++)
 	{
 		if (starpu_node_get_kind(i) == STARPU_DISK_RAM && i != node &&
@@ -1576,7 +1579,7 @@ get_better_disk_can_accept_size(starpu_data_handle_t handle, unsigned node)
 			/* if we can write on the disk */
 			if (_starpu_get_disk_flag(i) != STARPU_DISK_NO_RECLAIM)
 			{
-				/* only time can change between disk <-> main_ram 
+				/* only time can change between disk <-> main_ram
 				 * and not between main_ram <-> worker if we compare diks*/
 				double time_tmp = starpu_transfer_predict(i, STARPU_MAIN_RAM, _starpu_data_get_size(handle));
 				if (target == -1 || time_disk > time_tmp)
@@ -1600,7 +1603,7 @@ choose_target(starpu_data_handle_t handle, unsigned node)
 		/* try to push on RAM if we can before to push on disk */
 		if(starpu_node_get_kind(handle->home_node) == STARPU_DISK_RAM && node != STARPU_MAIN_RAM)
 		{
-			if (handle->per_node[STARPU_MAIN_RAM].allocated || 
+			if (handle->per_node[STARPU_MAIN_RAM].allocated ||
 			    _starpu_memory_manager_test_allocate_size(STARPU_MAIN_RAM, size_handle) == 1)
 			{
 				target = STARPU_MAIN_RAM;
@@ -1612,7 +1615,7 @@ choose_target(starpu_data_handle_t handle, unsigned node)
 
 		}
           	/* others memory nodes */
-		else 
+		else
 		{
 			target = handle->home_node;
 		}
@@ -1626,7 +1629,7 @@ choose_target(starpu_data_handle_t handle, unsigned node)
 		}
 		/* node != 0 */
 		/* try to push data to RAM if we can before to push on disk*/
-		else if (handle->per_node[STARPU_MAIN_RAM].allocated || 
+		else if (handle->per_node[STARPU_MAIN_RAM].allocated ||
 			 _starpu_memory_manager_test_allocate_size(STARPU_MAIN_RAM, size_handle) == 1)
 		{
 			target = STARPU_MAIN_RAM;

+ 15 - 15
src/datawizard/memstats.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010, 2012  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2016, 2017  CNRS
  *
  * 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
@@ -47,31 +47,31 @@ void _starpu_memory_stats_free(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUS
 }
 
 #ifdef STARPU_MEMORY_STATS
-void _starpu_memory_display_handle_stats(starpu_data_handle_t handle)
+void _starpu_memory_display_handle_stats(FILE *stream, starpu_data_handle_t handle)
 {
 	unsigned node;
 
-	fprintf(stderr, "#-----\n");
-	fprintf(stderr, "Data : %p\n", handle);
-	fprintf(stderr, "Size : %d\n", (int)handle->ops->get_size(handle));
-	fprintf(stderr, "\n");
+	fprintf(stream, "#-----\n");
+	fprintf(stream, "Data : %p\n", handle);
+	fprintf(stream, "Size : %d\n", (int)handle->ops->get_size(handle));
+	fprintf(stream, "\n");
 
-	fprintf(stderr, "#--\n");
-	fprintf(stderr, "Data access stats\n");
-	fprintf(stderr, "/!\\ Work Underway\n");
+	fprintf(stream, "#--\n");
+	fprintf(stream, "Data access stats\n");
+	fprintf(stream, "/!\\ Work Underway\n");
 	for (node = 0; node < STARPU_MAXNODES; node++)
 	{
 		if (handle->memory_stats->direct_access[node]+handle->memory_stats->loaded_shared[node]
 		    +handle->memory_stats->invalidated[node]+handle->memory_stats->loaded_owner[node])
 		{
-			fprintf(stderr, "Node #%u\n", node);
-			fprintf(stderr, "\tDirect access : %d\n", handle->memory_stats->direct_access[node]);
+			fprintf(stream, "Node #%u\n", node);
+			fprintf(stream, "\tDirect access : %d\n", handle->memory_stats->direct_access[node]);
 			/* XXX Not Working yet. */
 			if (handle->memory_stats->shared_to_owner[node])
-				fprintf(stderr, "\t\tShared to Owner : %d\n", handle->memory_stats->shared_to_owner[node]);
-			fprintf(stderr, "\tLoaded (Owner) : %d\n", handle->memory_stats->loaded_owner[node]);
-			fprintf(stderr, "\tLoaded (Shared) : %d\n", handle->memory_stats->loaded_shared[node]);
-			fprintf(stderr, "\tInvalidated (was Owner) : %d\n\n", handle->memory_stats->invalidated[node]);
+				fprintf(stream, "\t\tShared to Owner : %d\n", handle->memory_stats->shared_to_owner[node]);
+			fprintf(stream, "\tLoaded (Owner) : %d\n", handle->memory_stats->loaded_owner[node]);
+			fprintf(stream, "\tLoaded (Shared) : %d\n", handle->memory_stats->loaded_shared[node]);
+			fprintf(stream, "\tInvalidated (was Owner) : %d\n\n", handle->memory_stats->invalidated[node]);
 		}
 	}
 }

+ 2 - 2
src/datawizard/memstats.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2017  CNRS
  *
  * 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
@@ -42,7 +42,7 @@ void _starpu_memory_stats_init_per_node(starpu_data_handle_t handle, unsigned no
 
 void _starpu_memory_stats_free(starpu_data_handle_t handle);
 
-void _starpu_memory_display_handle_stats(starpu_data_handle_t handle);
+void _starpu_memory_display_handle_stats(FILE *stream, starpu_data_handle_t handle);
 
 void _starpu_memory_handle_stats_cache_hit(starpu_data_handle_t handle, unsigned node);
 void _starpu_memory_handle_stats_loaded_shared(starpu_data_handle_t handle, unsigned node);

+ 2 - 1
src/debug/starpu_debug_helpers.h

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux
+ * Copyright (C) 2017  CNRS
  *
  * 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
@@ -30,7 +31,7 @@ extern "C"
 void _starpu_benchmark_ping_pong(starpu_data_handle_t handle, unsigned node0, unsigned node1, unsigned niter);
 
 /* Display the size of different data structures */
-void _starpu_debug_display_structures_size(void);
+void _starpu_debug_display_structures_size(FILE *stream);
 
 #ifdef __cplusplus
 }

+ 8 - 7
src/debug/structures_size.c

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011  Université de Bordeaux
+ * Copyright (C) 2017        CNRS
  *
  * 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
@@ -21,18 +22,18 @@
 #include <profiling/bound.h>
 #include <debug/starpu_debug_helpers.h>
 
-void _starpu_debug_display_structures_size(void)
+void _starpu_debug_display_structures_size(FILE *stream)
 {
-	fprintf(stderr, "struct starpu_task\t\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct starpu_task\t\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct starpu_task), (unsigned) sizeof(struct starpu_task));
-	fprintf(stderr, "struct _starpu_job\t\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct _starpu_job\t\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct _starpu_job), (unsigned) sizeof(struct _starpu_job));
-	fprintf(stderr, "struct _starpu_data_state\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct _starpu_data_state\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct _starpu_data_state), (unsigned) sizeof(struct _starpu_data_state));
-	fprintf(stderr, "struct _starpu_tag\t\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct _starpu_tag\t\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct _starpu_tag), (unsigned) sizeof(struct _starpu_tag));
-	fprintf(stderr, "struct _starpu_cg\t\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct _starpu_cg\t\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct _starpu_cg), (unsigned) sizeof(struct _starpu_cg));
-	fprintf(stderr, "struct _starpu_worker\t\t%u bytes\t(%x)\n",
+	fprintf(stream, "struct _starpu_worker\t\t%u bytes\t(%x)\n",
 			(unsigned) sizeof(struct _starpu_worker), (unsigned) sizeof(struct _starpu_worker));
 }

+ 8 - 8
src/debug/traces/starpu_fxt.c

@@ -2181,7 +2181,7 @@ static void handle_mpi_isend_submit_end(struct fxt_ev_64 *ev, struct starpu_fxt_
 	{
 		if (!mpi_warned)
 		{
-			fprintf(stderr,"Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
+			_STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
 			mpi_warned = 1;
 		}
 	}
@@ -2244,7 +2244,7 @@ static void handle_mpi_irecv_complete_begin(struct fxt_ev_64 *ev, struct starpu_
 	{
 		if (!mpi_warned)
 		{
-			fprintf(stderr,"Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
+			_STARPU_MSG("Warning : Only one trace file is given. MPI transfers will not be displayed. Add all trace files to show them ! \n");
 			mpi_warned = 1;
 		}
 	}
@@ -2997,8 +2997,8 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 
 			default:
 #ifdef STARPU_VERBOSE
-				fprintf(stderr, "unknown event.. %x at time %llx WITH OFFSET %llx\n",
-					(unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-options->file_offset));
+				_STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
+					    (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time-options->file_offset));
 #endif
 				break;
 		}
@@ -3155,7 +3155,7 @@ void _starpu_fxt_paje_file_init(struct starpu_fxt_options *options)
 		out_paje_file = fopen(options->out_paje_path, "w+");
 		if (!out_paje_file)
 		{
-			fprintf(stderr,"error while opening %s\n", options->out_paje_path);
+			_STARPU_MSG("error while opening %s\n", options->out_paje_path);
 			perror("fopen");
 			exit(1);
 		}
@@ -3303,7 +3303,7 @@ void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
 				{
 					if (key != unique_keys[inputfile])
 					{
-						fprintf(stderr, "Warning: traces are coming from different run so we will not try to display MPI communications.\n");
+						_STARPU_MSG("Warning: traces are coming from different run so we will not try to display MPI communications.\n");
 						display_mpi = 0;
 					}
 				}
@@ -3483,8 +3483,8 @@ void starpu_fxt_write_data_trace(char *filename_in)
 
 		default:
 #ifdef STARPU_VERBOSE
-			fprintf(stderr, "unknown event.. %x at time %llx WITH OFFSET %llx\n",
-				(unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time));
+			_STARPU_MSG("unknown event.. %x at time %llx WITH OFFSET %llx\n",
+				    (unsigned)ev.code, (long long unsigned)ev.time, (long long unsigned)(ev.time));
 #endif
 			break;
 		}

+ 1 - 1
src/debug/traces/starpu_fxt_dag.c

@@ -37,7 +37,7 @@ void _starpu_fxt_dag_init(char *out_path)
 	out_file = fopen(out_path, "w+");
 	if (!out_file)
 	{
-		fprintf(stderr,"error while opening %s\n", out_path);
+		_STARPU_MSG("error while opening %s\n", out_path);
 		perror("fopen");
 		exit(1);
 	}

+ 2 - 2
src/debug/traces/starpu_fxt_mpi.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012-2013, 2016  Université Bordeaux
- * Copyright (C) 2010, 2011, 2014, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2014, 2016, 2017  CNRS
  *
  * 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
@@ -70,7 +70,7 @@ int _starpu_fxt_mpi_find_sync_point(char *filename_in, uint64_t *offset, int *ke
 		int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
 		if (ret != FXT_EV_OK)
 		{
-			fprintf(stderr, "no more block ...\n");
+			_STARPU_MSG("no more block ...\n");
 			break;
 		}
 

+ 6 - 6
src/drivers/cuda/driver_cuda.c

@@ -227,13 +227,13 @@ void starpu_cuda_set_device(unsigned devid STARPU_ATTRIBUTE_UNUSED)
 #ifdef HAVE_CUDA_MEMCPY_PEER
 	if (conf->n_cuda_opengl_interoperability)
 	{
-		fprintf(stderr, "OpenGL interoperability was requested, but StarPU was built with multithread GPU control support, please reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
+		_STARPU_MSG("OpenGL interoperability was requested, but StarPU was built with multithread GPU control support, please reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
 		STARPU_ABORT();
 	}
 #elif !defined(HAVE_CUDA_GL_INTEROP_H)
 	if (conf->n_cuda_opengl_interoperability)
 	{
-		fprintf(stderr,"OpenGL interoperability was requested, but cuda_gl_interop.h could not be compiled, please make sure that OpenGL headers were available before ./configure run.");
+		_STARPU_MSG("OpenGL interoperability was requested, but cuda_gl_interop.h could not be compiled, please make sure that OpenGL headers were available before ./configure run.");
 		STARPU_ABORT();
 	}
 #else
@@ -324,7 +324,7 @@ static void init_device_context(unsigned devid, unsigned memnode)
 	{
 		if (cures == cudaErrorDevicesUnavailable)
 		{
-			fprintf(stderr,"All CUDA-capable devices are busy or unavailable\n");
+			_STARPU_MSG("All CUDA-capable devices are busy or unavailable\n");
 			exit(77);
 		}
 		STARPU_CUDA_REPORT_ERROR(cures);
@@ -336,7 +336,7 @@ static void init_device_context(unsigned devid, unsigned memnode)
 #ifdef HAVE_CUDA_MEMCPY_PEER
 	if (props[devid].computeMode == cudaComputeModeExclusive)
 	{
-		fprintf(stderr, "CUDA is in EXCLUSIVE-THREAD mode, but StarPU was built with multithread GPU control support, please either ask your administrator to use EXCLUSIVE-PROCESS mode (which should really be fine), or reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
+		_STARPU_MSG("CUDA is in EXCLUSIVE-THREAD mode, but StarPU was built with multithread GPU control support, please either ask your administrator to use EXCLUSIVE-PROCESS mode (which should really be fine), or reconfigure with --disable-cuda-memcpy-peer but that will disable the memcpy-peer optimizations\n");
 		STARPU_ABORT();
 	}
 #endif
@@ -447,7 +447,7 @@ unsigned _starpu_get_cuda_device_count(void)
 
 	if (cnt > STARPU_MAXCUDADEVS)
 	{
-		fprintf(stderr, "# Warning: %d CUDA devices available. Only %d enabled. Use configure option --enable-maxcudadev=xxx to update the maximum value of supported CUDA devices.\n", cnt, STARPU_MAXCUDADEVS);
+		_STARPU_MSG("# Warning: %d CUDA devices available. Only %d enabled. Use configure option --enable-maxcudadev=xxx to update the maximum value of supported CUDA devices.\n", cnt, STARPU_MAXCUDADEVS);
 		cnt = STARPU_MAXCUDADEVS;
 	}
 	return (unsigned)cnt;
@@ -975,7 +975,7 @@ void starpu_cublas_report_error(const char *func, const char *file, int line, in
 			errormsg = "unknown error";
 			break;
 	}
-	fprintf(stderr, "oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
+	_STARPU_MSG("oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 	STARPU_ABORT();
 }
 

+ 4 - 4
src/drivers/scc/driver_scc_common.c

@@ -47,9 +47,9 @@ static void _starpu_scc_set_src_node_id()
 		else if (RCCE_ue() == 0)
 		{
 			/* Only node 0 print the error message. */
-			fprintf(stderr, "The node you specify to be the master is "
-					"greater than the total number of nodes.\n"
-					"Taking node 0 (core %d) by default...\n", RC_COREID[0]);
+			_STARPU_MSG("The node you specify to be the master is "
+				    "greater than the total number of nodes.\n"
+				    "Taking node 0 (core %d) by default...\n", RC_COREID[0]);
 		}
 	}
 
@@ -169,7 +169,7 @@ void _starpu_scc_common_report_rcce_error(const char *func, const char *file, co
 
 	RCCE_error_string(err_no, error_string, &error_string_length); 
 
-	fprintf(stderr, "RCCE error in %s (%s:%d): %s\n", func, file, line, error_string); 
+	_STARPU_MSG("RCCE error in %s (%s:%d): %s\n", func, file, line, error_string); 
 	STARPU_ABORT();
 }
 

+ 1 - 1
src/drivers/scc/driver_scc_sink.c

@@ -139,7 +139,7 @@ void _starpu_scc_sink_execute(const struct _starpu_mp_node *node, void *arg, int
 			case STARPU_CSR_INTERFACE_ID:
 			case STARPU_BCSR_INTERFACE_ID:
 			case STARPU_MULTIFORMAT_INTERFACE_ID:
-			fprintf(stderr, "Data type not supported on SCC.\n");
+				_STARPU_MSG("Data type not supported on SCC.\n");
 
 			default:
 				STARPU_ABORT();

+ 2 - 2
src/drivers/scc/driver_scc_source.c

@@ -239,8 +239,8 @@ void _starpu_scc_set_offset_in_shared_memory(void *ptr, void **dev_handle, size_
 	{
 		if (!_starpu_scc_common_is_in_shared_memory(ptr))
 		{
-			fprintf(stderr, "The data (%p) you want to register does not seem to be allocated in shared memory. "
-					"Please use starpu_malloc to do this.\n", ptr);
+			_STARPU_MSG("The data (%p) you want to register does not seem to be allocated in shared memory. "
+				    "Please use starpu_malloc to do this.\n", ptr);
 			STARPU_ABORT();
 		}
 

+ 6 - 6
src/profiling/bound.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2011  Télécom-SudParis
  *
@@ -397,7 +397,7 @@ void _starpu_bound_job_id_dep(starpu_data_handle_t handle, struct _starpu_job *j
 	dep_t = find_job(id);
 	if (!dep_t)
 	{
-		fprintf(stderr,"dependency %lu not found !\n", id);
+		_STARPU_MSG("dependency %lu not found !\n", id);
 		STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
@@ -520,7 +520,7 @@ void starpu_bound_print_lp(FILE *output)
 			if (t1->cl->model->type != STARPU_HISTORY_BASED &&
 			    t1->cl->model->type != STARPU_NL_REGRESSION_BASED)
 				/* TODO: */
-				fprintf(stderr, "Warning: task %s uses a perf model which is neither history nor non-linear regression-based, support for such model is not implemented yet, system will not be solvable.\n", _starpu_codelet_get_model_name(t1->cl));
+				_STARPU_MSG("Warning: task %s uses a perf model which is neither history nor non-linear regression-based, support for such model is not implemented yet, system will not be solvable.\n", _starpu_codelet_get_model_name(t1->cl));
 
 			struct _starpu_job j =
 			{
@@ -824,7 +824,7 @@ void starpu_bound_print_lp(FILE *output)
 				for (w = 0; w < nw; w++)
 				{
 					if (isnan(times[w*nt+t]))
-						fprintf(stderr, "Warning: task %s has no performance measurement for worker %d.\n", _starpu_codelet_get_model_name(tp->cl), w);
+						_STARPU_MSG("Warning: task %s has no performance measurement for worker %d.\n", _starpu_codelet_get_model_name(tp->cl), w);
 					else
 					{
 						got_one = 1;
@@ -833,7 +833,7 @@ void starpu_bound_print_lp(FILE *output)
 				}
 				fprintf(output, " = %lu;\n", tp->n);
 				if (!got_one)
-					fprintf(stderr, "Warning: task %s has no performance measurement for any worker, system will not be solvable!\n", _starpu_codelet_get_model_name(tp->cl));
+					_STARPU_MSG("Warning: task %s has no performance measurement for any worker, system will not be solvable!\n", _starpu_codelet_get_model_name(tp->cl));
 				/* Show actual values */
 				fprintf(output, "/*");
 				for (w = 0; w < nw; w++)
@@ -1133,7 +1133,7 @@ void starpu_bound_print(FILE *output, int integer STARPU_ATTRIBUTE_UNUSED)
 	}
 	else
 	{
-		fprintf(stderr, "Simplex failed\n");
+		_STARPU_MSG("Simplex failed\n");
 	}
 	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 #else /* STARPU_HAVE_GLPK_H */

+ 34 - 25
src/profiling/profiling_helpers.c

@@ -31,17 +31,15 @@ static double convert_to_byte_units(float d, unsigned max_unit, unsigned *unit)
 	return d;
 }
 
-void starpu_profiling_bus_helper_display_summary(void)
+void _starpu_profiling_bus_helper_display_summary(FILE *stream)
 {
 	const char *stats;
 	int long long sum_transferred = 0;
 	const char *byte_units[] = { "B", "KB", "MB", "GB", "TB" };
 	unsigned max_unit = sizeof(byte_units) / sizeof(byte_units[0]);
 
-	if (!((stats = starpu_getenv("STARPU_BUS_STATS")) && atoi(stats))) return;
-
-	fprintf(stderr, "\n#---------------------\n");
-	fprintf(stderr, "Data transfer stats:\n");
+	fprintf(stream, "\n#---------------------\n");
+	fprintf(stream, "Data transfer stats:\n");
 
 	int busid;
 	int bus_cnt = starpu_bus_get_count();
@@ -66,10 +64,10 @@ void starpu_profiling_bus_helper_display_summary(void)
 		_starpu_memory_node_get_name(src, src_name, sizeof(src_name));
 		_starpu_memory_node_get_name(dst, dst_name, sizeof(dst_name));
 
-		fprintf(stderr, "\t%s -> %s", src_name, dst_name);
-		fprintf(stderr, "\t%.2lf %s", d, byte_units[unit]);
-		fprintf(stderr, "\t%.2lf %s/s", d / elapsed_time, byte_units[unit]);
-		fprintf(stderr, "\t(transfers : %lld - avg %.2lf %s)\n", transfer_cnt, d / transfer_cnt, byte_units[unit]);
+		fprintf(stream, "\t%s -> %s", src_name, dst_name);
+		fprintf(stream, "\t%.2lf %s", d, byte_units[unit]);
+		fprintf(stream, "\t%.2lf %s/s", d / elapsed_time, byte_units[unit]);
+		fprintf(stream, "\t(transfers : %lld - avg %.2lf %s)\n", transfer_cnt, d / transfer_cnt, byte_units[unit]);
 
 		sum_transferred += transferred;
 	}
@@ -77,23 +75,27 @@ void starpu_profiling_bus_helper_display_summary(void)
 	unsigned unit = 0;
 	double d = convert_to_byte_units(sum_transferred, max_unit, &unit);
 
-	fprintf(stderr, "Total transfers: %.2lf %s\n", d, byte_units[unit]);
-	fprintf(stderr, "#---------------------\n");
+	fprintf(stream, "Total transfers: %.2lf %s\n", d, byte_units[unit]);
+	fprintf(stream, "#---------------------\n");
 }
 
-void starpu_profiling_worker_helper_display_summary(void)
+void starpu_profiling_bus_helper_display_summary(void)
 {
 	const char *stats;
+	if (!((stats = starpu_getenv("STARPU_BUS_STATS")) && atoi(stats))) return;
+	_starpu_profiling_bus_helper_display_summary(stderr);
+}
+
+void _starpu_profiling_worker_helper_display_summary(FILE *stream)
+{
 	double sum_consumed = 0.;
 	int profiling = starpu_profiling_status_get();
 	double overall_time = 0;
 	int workerid;
 	int worker_cnt = starpu_worker_get_count();
 
-	if (!((stats = starpu_getenv("STARPU_WORKER_STATS")) && atoi(stats))) return;
-
-	fprintf(stderr, "\n#---------------------\n");
-	fprintf(stderr, "Worker stats:\n");
+	fprintf(stream, "\n#---------------------\n");
+	fprintf(stream, "Worker stats:\n");
 
 	for (workerid = 0; workerid < worker_cnt; workerid++)
 	{
@@ -103,8 +105,8 @@ void starpu_profiling_worker_helper_display_summary(void)
 
 		starpu_worker_get_name(workerid, name, sizeof(name));
 
-		fprintf(stderr, "%-32s\n", name);
-		fprintf(stderr, "\t%d task(s)\n", info.executed_tasks);
+		fprintf(stream, "%-32s\n", name);
+		fprintf(stream, "\t%d task(s)\n", info.executed_tasks);
 
 		if (profiling)
 		{
@@ -114,14 +116,14 @@ void starpu_profiling_worker_helper_display_summary(void)
 			if (total_time > overall_time)
 				overall_time = total_time;
 
-			fprintf(stderr, "\ttotal: %.2lf ms executing: %.2lf ms sleeping: %.2lf ms overhead %.2lf ms\n",
+			fprintf(stream, "\ttotal: %.2lf ms executing: %.2lf ms sleeping: %.2lf ms overhead %.2lf ms\n",
 				total_time, executing_time, sleeping_time, total_time - executing_time - sleeping_time);
 			if (info.used_cycles || info.stall_cycles)
-				fprintf(stderr, "\t%llu Mcy %llu Mcy stall\n", (unsigned long long)info.used_cycles/1000000, (unsigned long long)info.stall_cycles/1000000);
+				fprintf(stream, "\t%llu Mcy %llu Mcy stall\n", (unsigned long long)info.used_cycles/1000000, (unsigned long long)info.stall_cycles/1000000);
 			if (info.energy_consumed)
-				fprintf(stderr, "\t%f J consumed\n", info.energy_consumed);
+				fprintf(stream, "\t%f J consumed\n", info.energy_consumed);
 			if (info.flops)
-				fprintf(stderr, "\t%f GFlop/s\n\n", info.flops / total_time / 1000000);
+				fprintf(stream, "\t%f GFlop/s\n\n", info.flops / total_time / 1000000);
 		}
 
 		sum_consumed += info.energy_consumed;
@@ -135,10 +137,17 @@ void starpu_profiling_worker_helper_display_summary(void)
 			double idle_power = atof(strval_idle_power); /* Watt */
 			double idle_energy = idle_power * overall_time / 1000.; /* J */
 
-			fprintf(stderr, "Idle energy: %.2lf J\n", idle_energy);
-			fprintf(stderr, "Total energy: %.2lf J\n",
+			fprintf(stream, "Idle energy: %.2lf J\n", idle_energy);
+			fprintf(stream, "Total energy: %.2lf J\n",
 				sum_consumed + idle_energy);
 		}
 	}
-	fprintf(stderr, "#---------------------\n");
+	fprintf(stream, "#---------------------\n");
+}
+
+void starpu_profiling_worker_helper_display_summary(void)
+{
+	const char *stats;
+	if (!((stats = starpu_getenv("STARPU_WORKER_STATS")) && atoi(stats))) return;
+	_starpu_profiling_worker_helper_display_summary(stderr);
 }

+ 4 - 5
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2017  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011-2012, 2016  INRIA
  * Copyright (C) 2016  Uppsala University
@@ -111,10 +111,9 @@ static void param_modified(struct starpu_top_param* d)
 #warning FIXME: get sched ctx to get alpha/beta/gamma/idle values
 #endif
 	/* Just to show parameter modification. */
-	fprintf(stderr,
-		"%s has been modified : "
-		"alpha=%f|beta=%f|gamma=%f|idle_power=%f !\n",
-		d->name, alpha,beta,_gamma, idle_power);
+	_STARPU_MSG("%s has been modified : "
+		    "alpha=%f|beta=%f|gamma=%f|idle_power=%f !\n",
+		    d->name, alpha,beta,_gamma, idle_power);
 }
 #endif /* !STARPU_USE_TOP */
 

+ 1 - 2
src/sched_policies/helper_mct.c

@@ -32,8 +32,7 @@
 static void param_modified(struct starpu_top_param* d)
 {
 	/* Just to show parameter modification. */
-	fprintf(stderr, "%s has been modified : %f\n",
-			d->name, *(double*) d->value);
+	_STARPU_MSG("%s has been modified : %f\n", d->name, *(double*) d->value);
 }
 #endif /* !STARPU_USE_TOP */
 

+ 2 - 2
src/sched_policies/parallel_eager.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2011-2016  Université de Bordeaux
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011-2013  INRIA
- * Copyright (C) 2016       CNRS
+ * Copyright (C) 2016, 2017       CNRS
  *
  * 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
@@ -100,7 +100,7 @@ static void peager_add_workers(unsigned sched_ctx_id, int *workerids, unsigned n
         {
 		workerid = workerids[i];
 
-		fprintf(stderr, "MASTER of %d = %d\n", workerid, master_id[workerid]);
+		_STARPU_MSG("MASTER of %d = %d\n", workerid, master_id[workerid]);
 	}
 #endif
 }

+ 1 - 1
src/sched_policies/scheduler_maker.c

@@ -265,7 +265,7 @@ struct starpu_sched_tree * starpu_sched_component_make_scheduler(unsigned sched_
 
 	starpu_sched_tree_update_workers(tree);
 #ifdef STARPU_DEVEL
-	fprintf(stderr, "scheduler created :\n");
+	_STARPU_MSG("scheduler created :\n");
 	helper_display_scheduler(stderr, 0, tree->root);
 #endif
 

+ 6 - 6
src/util/openmp_runtime_support_environment.c

@@ -236,7 +236,7 @@ static void read_wait_policy_var()
 	ret = read_string_var(env, strings, &value);
 	if (!ret)
 	{
-		fprintf(stderr, "StarPU: Invalid value for environment variable OMP_WAIT_POLICY\n");
+		_STARPU_MSG("StarPU: Invalid value for environment variable OMP_WAIT_POLICY\n");
 		return;
 	}
 	_initial_icv_values.wait_policy_var = value;
@@ -256,7 +256,7 @@ static void read_display_env_var(int *dest)
 	ret = read_string_var(env, strings, &value);
 	if (!ret)
 	{
-		fprintf(stderr, "StarPU: Invalid value for environment variable OMP_DISPLAY_ENV\n");
+		_STARPU_MSG("StarPU: Invalid value for environment variable OMP_DISPLAY_ENV\n");
 		return;
 	}
 
@@ -559,7 +559,7 @@ static void read_proc_bind_var()
 
 			if (!read_string_var(token, strings, &value))
 			{
-				fprintf(stderr, "StarPU: Invalid value for environment variable OMP_PROC_BIND\n");
+				_STARPU_MSG("StarPU: Invalid value for environment variable OMP_PROC_BIND\n");
 				break;
 			}
 
@@ -590,7 +590,7 @@ static void read_num_threads_var()
 
 			if (!read_int_var(token, &value))
 			{
-				fprintf(stderr, "StarPU: Invalid value for environment variable OMP_NUM_THREADS\n");
+				_STARPU_MSG("StarPU: Invalid value for environment variable OMP_NUM_THREADS\n");
 				break;
 			}
 
@@ -613,7 +613,7 @@ static void read_omp_int_var(const char *name, int *icv)
 	ret = read_int_var(env, &value);
 	if (!ret || value < 0)
 	{
-		fprintf(stderr, "StarPU: Invalid value for environment variable %s\n", name);
+		_STARPU_MSG("StarPU: Invalid value for environment variable %s\n", name);
 		return;
 	}
 	*icv = value;
@@ -632,7 +632,7 @@ static void read_omp_boolean_var(const char *name, int *icv)
 	ret = read_string_var(env, strings, &value);
 	if (!ret)
 	{
-		fprintf(stderr, "StarPU: Invalid value for environment variable %s\n", name);
+		_STARPU_MSG("StarPU: Invalid value for environment variable %s\n", name);
 		return;
 	}
 	*icv = value;

+ 5 - 5
src/util/starpu_task_insert.c

@@ -141,11 +141,11 @@ int _starpu_task_insert_v(struct starpu_codelet *cl, va_list varg_list)
 
 	if (STARPU_UNLIKELY(ret == -ENODEV))
 	{
-		fprintf(stderr, "submission of task %p wih codelet %p failed (symbol `%s') (err: ENODEV)\n",
-			task, task->cl,
-			(cl == NULL) ? "none" :
-			task->cl->name ? task->cl->name :
-			(task->cl->model && task->cl->model->symbol)?task->cl->model->symbol:"none");
+		_STARPU_MSG("submission of task %p wih codelet %p failed (symbol `%s') (err: ENODEV)\n",
+			    task, task->cl,
+			    (cl == NULL) ? "none" :
+			    task->cl->name ? task->cl->name :
+			    (task->cl->model && task->cl->model->symbol)?task->cl->model->symbol:"none");
 
 		task->destroy = 0;
 		starpu_task_destroy(task);

+ 2 - 1
tests/microbenchs/display_structures_size.c

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2016  Université de Bordeaux
+ * Copyright (C) 2017        CNRS
  *
  * 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
@@ -23,7 +24,7 @@
 
 int main(int argc, char **argv)
 {
-	_starpu_debug_display_structures_size();
+	_starpu_debug_display_structures_size(stderr);
 
 	return EXIT_SUCCESS;
 }