Просмотр исходного кода

src: avoid calling fprint directly, use instead starpu message functions

Nathalie Furmento лет назад: 8
Родитель
Сommit
1d90cf39b7

+ 8 - 9
src/core/combined_workers.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2010-2015  Université de Bordeaux
  * Copyright (C) 2010-2015  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2014, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2014, 2016, 2017  CNRS
  * Copyright (C) 2017  Inria
  * Copyright (C) 2017  Inria
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -88,14 +88,13 @@ int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
 	new_workerid = basic_worker_count + combined_worker_id;
 	new_workerid = basic_worker_count + combined_worker_id;
 	config->topology.ncombinedworkers++;
 	config->topology.ncombinedworkers++;
 
 
-#if 0
-	fprintf(stderr, "COMBINED WORKERS ");
-	for (i = 0; i < nworkers; i++)
-	{
-		fprintf(stderr, "%d ", workerid_array[i]);
-	}
-	fprintf(stderr, "into worker %d\n", new_workerid);
-#endif
+//	fprintf(stderr, "COMBINED WORKERS ");
+//	for (i = 0; i < nworkers; i++)
+//	{
+//		fprintf(stderr, "%d ", workerid_array[i]);
+//	}
+//	fprintf(stderr, "into worker %d\n", new_workerid);
+
 	for(i = 0; i < nworkers; i++)
 	for(i = 0; i < nworkers; i++)
 		_starpu_get_worker_struct(workerid_array[i])->combined_workerid = new_workerid;
 		_starpu_get_worker_struct(workerid_array[i])->combined_workerid = new_workerid;
 
 

+ 3 - 3
src/core/sched_ctx.c

@@ -1097,13 +1097,13 @@ unsigned _starpu_can_push_task(struct _starpu_sched_ctx *sched_ctx, struct starp
 			expected_len = expected_end - hyp_actual_start_sample[sched_ctx->id] ;
 			expected_len = expected_end - hyp_actual_start_sample[sched_ctx->id] ;
 		else
 		else
 		{
 		{
-			printf("%d: sc start is 0.0\n", sched_ctx->id);
+			_STARPU_MSG("%d: sc start is 0.0\n", sched_ctx->id);
 			expected_len = expected_end - starpu_timing_now();
 			expected_len = expected_end - starpu_timing_now();
 		}
 		}
 		if(expected_len < 0.0)
 		if(expected_len < 0.0)
-			printf("exp len negative %lf \n", expected_len);
+			_STARPU_MSG("exp len negative %lf \n", expected_len);
 		expected_len /= 1000000.0;
 		expected_len /= 1000000.0;
-//		printf("exp_end %lf start %lf expected_len %lf \n", expected_end, hyp_actual_start_sample[sched_ctx->id], expected_len);
+		//		_STARPU_MSG("exp_end %lf start %lf expected_len %lf \n", expected_end, hyp_actual_start_sample[sched_ctx->id], expected_len);
 		if(expected_len > (window_size + 0.2*window_size))
 		if(expected_len > (window_size + 0.2*window_size))
 			return 0;
 			return 0;
 	}
 	}

+ 1 - 2
src/core/simgrid.c

@@ -270,8 +270,7 @@ int main(int argc, char **argv)
 	{
 	{
 		if (!smpi_process_get_user_data)
 		if (!smpi_process_get_user_data)
 		{
 		{
-			fprintf(stderr,"Your version of simgrid does not provide smpi_process_get_user_data, we can not continue without it\n");
-			exit(1);
+			_STARPU_ERROR("Your version of simgrid does not provide smpi_process_get_user_data, we can not continue without it\n");
 		}
 		}
 
 
 #if SIMGRID_VERSION_MAJOR > 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR >= 16)
 #if SIMGRID_VERSION_MAJOR > 3 || (SIMGRID_VERSION_MAJOR == 3 && SIMGRID_VERSION_MINOR >= 16)

+ 2 - 3
src/core/topology.c

@@ -945,9 +945,8 @@ _starpu_init_mpi_config (struct _starpu_machine_config *config,
                 if ((unsigned) nmpicores > topology->nhwmpicores[mpi_idx])
                 if ((unsigned) nmpicores > topology->nhwmpicores[mpi_idx])
                 {
                 {
                         /* The user requires more MPI cores than there is available */
                         /* The user requires more MPI cores than there is available */
-                        fprintf(stderr,
-                                        "# Warning: %d MPI cores requested. Only %d available.\n",
-                                        nmpicores, topology->nhwmpicores[mpi_idx]);
+                        _STARPU_MSG("# Warning: %d MPI cores requested. Only %d available.\n",
+				    nmpicores, topology->nhwmpicores[mpi_idx]);
                         nmpicores = topology->nhwmpicores[mpi_idx];
                         nmpicores = topology->nhwmpicores[mpi_idx];
                 }
                 }
         }
         }

+ 1 - 2
src/drivers/cuda/driver_cuda.c

@@ -1060,8 +1060,7 @@ void starpu_cublas_report_error(const char *func, const char *file, int line, in
 void starpu_cuda_report_error(const char *func, const char *file, int line, cudaError_t status)
 void starpu_cuda_report_error(const char *func, const char *file, int line, cudaError_t status)
 {
 {
 	const char *errormsg = cudaGetErrorString(status);
 	const char *errormsg = cudaGetErrorString(status);
-	printf("oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
-	STARPU_ABORT();
+	_STARPU_ERROR("oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 }
 }
 #endif /* STARPU_USE_CUDA */
 #endif /* STARPU_USE_CUDA */
 
 

+ 1 - 2
src/drivers/mic/driver_mic_common.c

@@ -23,8 +23,7 @@
 void _starpu_mic_common_report_scif_error(const char *func, const char *file, const int line, const int status)
 void _starpu_mic_common_report_scif_error(const char *func, const char *file, const int line, const int status)
 {
 {
 	const char *errormsg = strerror(status);
 	const char *errormsg = strerror(status);
-	printf("Common: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
-	STARPU_ASSERT(0);
+	_STARPU_ERROR("Common: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 }
 }
 
 
 /* Handles the error so the caller (which must be generic) doesn't have to
 /* Handles the error so the caller (which must be generic) doesn't have to

+ 1 - 2
src/drivers/mic/driver_mic_sink.c

@@ -154,8 +154,7 @@ void _starpu_mic_sink_deinit(struct _starpu_mp_node *node)
 void _starpu_mic_sink_report_error(const char *func, const char *file, const int line, const int status)
 void _starpu_mic_sink_report_error(const char *func, const char *file, const int line, const int status)
 {
 {
 	const char *errormsg = strerror(status);
 	const char *errormsg = strerror(status);
-	printf("SINK: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
-	STARPU_ASSERT(0);
+	_STARPU_ERROR("SINK: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 }
 }
 
 
 /* Allocate memory on the MIC.
 /* Allocate memory on the MIC.

+ 2 - 4
src/drivers/mic/driver_mic_source.c

@@ -193,8 +193,7 @@ void _starpu_mic_src_report_coi_error(const char *func, const char *file,
 				      const int line, const COIRESULT status)
 				      const int line, const COIRESULT status)
 {
 {
 	const char *errormsg = COIResultGetName(status);
 	const char *errormsg = COIResultGetName(status);
-	printf("SRC: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
-	STARPU_ASSERT(0);
+	_STARPU_ERROR("SRC: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 }
 }
 
 
 /* Report an error which occured when using a MIC device
 /* Report an error which occured when using a MIC device
@@ -205,8 +204,7 @@ void _starpu_mic_src_report_coi_error(const char *func, const char *file,
 void _starpu_mic_src_report_scif_error(const char *func, const char *file, const int line, const int status)
 void _starpu_mic_src_report_scif_error(const char *func, const char *file, const int line, const int status)
 {
 {
 	const char *errormsg = strerror(status);
 	const char *errormsg = strerror(status);
-	printf("SRC: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
-	STARPU_ASSERT(0);
+	_STARPU_ERROR("SRC: oops in %s (%s:%d)... %d: %s \n", func, file, line, status, errormsg);
 }
 }
 
 
 /* Return the number of MIC devices in the system.
 /* Return the number of MIC devices in the system.

+ 1 - 1
src/drivers/mp_common/sink_common.c

@@ -425,7 +425,7 @@ void _starpu_sink_common_worker(void)
 					_starpu_sink_common_recv_workers(node, arg, arg_size);
 					_starpu_sink_common_recv_workers(node, arg, arg_size);
 					break;
 					break;
 				default:
 				default:
-					printf("Oops, command %x unrecognized\n", command);
+					_STARPU_MSG("Oops, command %x unrecognized\n", command);
 			}
 			}
 		}
 		}
 
 

+ 1 - 2
src/drivers/mp_common/source_common.c

@@ -273,8 +273,7 @@ static void _starpu_src_common_recv_async(struct _starpu_mp_node * node)
 	answer = _starpu_mp_common_recv_command(node, &arg, &arg_size);
 	answer = _starpu_mp_common_recv_command(node, &arg, &arg_size);
 	if(!_starpu_src_common_handle_async(node,arg,arg_size,answer, 0))
 	if(!_starpu_src_common_handle_async(node,arg,arg_size,answer, 0))
 	{
 	{
-		printf("incorrect commande: unknown command or sync command");
-		STARPU_ASSERT(0);
+		_STARPU_ERROR("incorrect command: unknown command or sync command");
 	}
 	}
 }
 }
 
 

+ 18 - 19
src/drivers/mpi/driver_mpi_common.c

@@ -162,7 +162,7 @@ void _starpu_mpi_common_send(const struct _starpu_mp_node *node, void *msg, int
         int id_proc;
         int id_proc;
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
 
 
-        //printf("envoi %d B to %d\n", len, node->mp_connection.mpi_remote_nodeid);
+        //_STARPU_MSG("envoi %d B to %d\n", len, node->mp_connection.mpi_remote_nodeid);
 
 
         if (event)
         if (event)
         {
         {
@@ -177,7 +177,7 @@ void _starpu_mpi_common_send(const struct _starpu_mp_node *node, void *msg, int
                 /* Initialize the list */
                 /* Initialize the list */
                 if (channel->event.mpi_ms_event.requests == NULL)
                 if (channel->event.mpi_ms_event.requests == NULL)
                 {
                 {
-                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();            
+                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                 }
                 }
 
 
@@ -189,7 +189,7 @@ void _starpu_mpi_common_send(const struct _starpu_mp_node *node, void *msg, int
                 channel->starpu_mp_common_finished_sender++;
                 channel->starpu_mp_common_finished_sender++;
 
 
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
-        } 
+        }
         else
         else
         {
         {
                 /* Synchronous send */
                 /* Synchronous send */
@@ -212,7 +212,7 @@ void _starpu_mpi_common_recv(const struct _starpu_mp_node *node, void *msg, int
         MPI_Status s;
         MPI_Status s;
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
 
 
-        //printf("recv %d B from %d in %p\n", len, node->mp_connection.mpi_remote_nodeid, msg);
+        //_STARPU_MSG("recv %d B from %d in %p\n", len, node->mp_connection.mpi_remote_nodeid, msg);
 
 
         if (event)
         if (event)
         {
         {
@@ -227,7 +227,7 @@ void _starpu_mpi_common_recv(const struct _starpu_mp_node *node, void *msg, int
                 /* Initialize the list */
                 /* Initialize the list */
                 if (channel->event.mpi_ms_event.requests == NULL)
                 if (channel->event.mpi_ms_event.requests == NULL)
                 {
                 {
-                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();            
+                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                 }
                 }
 
 
@@ -239,7 +239,7 @@ void _starpu_mpi_common_recv(const struct _starpu_mp_node *node, void *msg, int
                 channel->starpu_mp_common_finished_sender++;
                 channel->starpu_mp_common_finished_sender++;
 
 
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
-        } 
+        }
         else
         else
         {
         {
                 /* Synchronous recv */
                 /* Synchronous recv */
@@ -259,12 +259,12 @@ void _starpu_mpi_common_mp_recv(const struct _starpu_mp_node *node, void *msg, i
 
 
 /* SEND to any node */
 /* SEND to any node */
 void _starpu_mpi_common_send_to_device(const struct _starpu_mp_node *node, int dst_devid, void *msg, int len, void * event)
 void _starpu_mpi_common_send_to_device(const struct _starpu_mp_node *node, int dst_devid, void *msg, int len, void * event)
-{   
+{
         int res;
         int res;
         int id_proc;
         int id_proc;
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
 
 
-        //printf("S_to_D send %d bytes from %d from %p\n", len, dst_devid, msg);
+        //_STARPU_MSG("S_to_D send %d bytes from %d from %p\n", len, dst_devid, msg);
 
 
         if (event)
         if (event)
         {
         {
@@ -279,7 +279,7 @@ void _starpu_mpi_common_send_to_device(const struct _starpu_mp_node *node, int d
                 /* Initialize the list */
                 /* Initialize the list */
                 if (channel->event.mpi_ms_event.requests == NULL)
                 if (channel->event.mpi_ms_event.requests == NULL)
                 {
                 {
-                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();            
+                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                 }
                 }
 
 
@@ -291,12 +291,12 @@ void _starpu_mpi_common_send_to_device(const struct _starpu_mp_node *node, int d
                 channel->starpu_mp_common_finished_sender++;
                 channel->starpu_mp_common_finished_sender++;
 
 
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
-        } 
+        }
         else
         else
         {
         {
                 /* Synchronous send */
                 /* Synchronous send */
                 res = MPI_Send(msg, len, MPI_BYTE, dst_devid, SYNC_TAG, MPI_COMM_WORLD);
                 res = MPI_Send(msg, len, MPI_BYTE, dst_devid, SYNC_TAG, MPI_COMM_WORLD);
-        }    
+        }
 
 
         STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
         STARPU_ASSERT_MSG(res == MPI_SUCCESS, "MPI Master/Slave cannot receive a msg with a size of %d Bytes !", len);
 }
 }
@@ -308,7 +308,7 @@ void _starpu_mpi_common_recv_from_device(const struct _starpu_mp_node *node, int
         int id_proc;
         int id_proc;
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
         MPI_Comm_rank(MPI_COMM_WORLD, &id_proc);
 
 
-        //printf("R_to_D nop recv %d bytes from %d\n", len, src_devid);
+        //_STARPU_MSG("R_to_D nop recv %d bytes from %d\n", len, src_devid);
 
 
         if (event)
         if (event)
         {
         {
@@ -323,7 +323,7 @@ void _starpu_mpi_common_recv_from_device(const struct _starpu_mp_node *node, int
                 /* Initialize the list */
                 /* Initialize the list */
                 if (channel->event.mpi_ms_event.requests == NULL)
                 if (channel->event.mpi_ms_event.requests == NULL)
                 {
                 {
-                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();            
+                        channel->event.mpi_ms_event.requests = _starpu_mpi_ms_event_request_list_new();
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                         _starpu_mpi_ms_event_request_list_init(channel->event.mpi_ms_event.requests);
                 }
                 }
 
 
@@ -335,7 +335,7 @@ void _starpu_mpi_common_recv_from_device(const struct _starpu_mp_node *node, int
                 channel->starpu_mp_common_finished_sender++;
                 channel->starpu_mp_common_finished_sender++;
 
 
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
                 _starpu_mpi_ms_event_request_list_push_back(channel->event.mpi_ms_event.requests, req);
-        } 
+        }
         else
         else
         {
         {
                 /* Synchronous recv */
                 /* Synchronous recv */
@@ -363,8 +363,7 @@ static void _starpu_mpi_common_polling_node(struct _starpu_mp_node * node)
                         answer = _starpu_mp_common_recv_command(node, &arg, &arg_size);
                         answer = _starpu_mp_common_recv_command(node, &arg, &arg_size);
                         if(!_starpu_src_common_store_message(node,arg,arg_size,answer))
                         if(!_starpu_src_common_store_message(node,arg,arg_size,answer))
                         {
                         {
-                                printf("incorrect commande: unknown command or sync command");
-                                STARPU_ASSERT(0);
+                                _STARPU_ERROR("incorrect command: unknown command or sync command");
                         }
                         }
                 }
                 }
                 STARPU_PTHREAD_MUTEX_UNLOCK(&node->connection_mutex);
                 STARPU_PTHREAD_MUTEX_UNLOCK(&node->connection_mutex);
@@ -485,7 +484,7 @@ void _starpu_mpi_common_measure_bandwidth_latency(double bandwidth_dtod[STARPU_M
         unsigned sender, receiver;
         unsigned sender, receiver;
         for(sender = 0; sender < nb_proc; sender++)
         for(sender = 0; sender < nb_proc; sender++)
         {
         {
-                for(receiver = 0; receiver < nb_proc; receiver++) 
+                for(receiver = 0; receiver < nb_proc; receiver++)
                 {
                 {
                         //Node can't be a sender and a receiver
                         //Node can't be a sender and a receiver
                         if(sender == receiver)
                         if(sender == receiver)
@@ -501,7 +500,7 @@ void _starpu_mpi_common_measure_bandwidth_latency(double bandwidth_dtod[STARPU_M
                                 start = starpu_timing_now();
                                 start = starpu_timing_now();
                                 for (iter = 0; iter < NITER; iter++)
                                 for (iter = 0; iter < NITER; iter++)
                                 {
                                 {
-                                        ret = MPI_Send(buf, SIZE_BANDWIDTH, MPI_BYTE, receiver, 42, MPI_COMM_WORLD); 
+                                        ret = MPI_Send(buf, SIZE_BANDWIDTH, MPI_BYTE, receiver, 42, MPI_COMM_WORLD);
                                         STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "Bandwidth of MPI Master/Slave cannot be measured !");
                                         STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "Bandwidth of MPI Master/Slave cannot be measured !");
                                 }
                                 }
                                 end = starpu_timing_now();
                                 end = starpu_timing_now();
@@ -511,7 +510,7 @@ void _starpu_mpi_common_measure_bandwidth_latency(double bandwidth_dtod[STARPU_M
                                 start = starpu_timing_now();
                                 start = starpu_timing_now();
                                 for (iter = 0; iter < NITER; iter++)
                                 for (iter = 0; iter < NITER; iter++)
                                 {
                                 {
-                                        ret = MPI_Send(buf, 1, MPI_BYTE, receiver, 42, MPI_COMM_WORLD); 
+                                        ret = MPI_Send(buf, 1, MPI_BYTE, receiver, 42, MPI_COMM_WORLD);
                                         STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "Latency of MPI Master/Slave cannot be measured !");
                                         STARPU_ASSERT_MSG(ret == MPI_SUCCESS, "Latency of MPI Master/Slave cannot be measured !");
                                 }
                                 }
                                 end = starpu_timing_now();
                                 end = starpu_timing_now();

+ 2 - 4
src/drivers/opencl/driver_opencl_utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010-2016  Université de Bordeaux
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -776,9 +776,7 @@ const char *starpu_opencl_error_string(cl_int status)
 
 
 void starpu_opencl_display_error(const char *func, const char *file, int line, const char* msg, cl_int status)
 void starpu_opencl_display_error(const char *func, const char *file, int line, const char* msg, cl_int status)
 {
 {
-	printf("oops in %s (%s:%d) (%s) ... <%s> (%d) \n", func, file, line, msg,
-	       starpu_opencl_error_string (status), status);
-
+	_STARPU_MSG("oops in %s (%s:%d) (%s) ... <%s> (%d) \n", func, file, line, msg, starpu_opencl_error_string (status), status);
 }
 }
 
 
 int starpu_opencl_set_kernel_args(cl_int *error, cl_kernel *kernel, ...)
 int starpu_opencl_set_kernel_args(cl_int *error, cl_kernel *kernel, ...)

+ 12 - 12
src/top/starpu_top.c

@@ -69,7 +69,7 @@ char *message_for_topparam_init(struct starpu_top_param* param);
 static
 static
 void copy_data_and_param(void)
 void copy_data_and_param(void)
 {
 {
-	printf("%s:%d trace\n", __FILE__, __LINE__);
+	_STARPU_MSG("trace\n");
 	//copying datas
 	//copying datas
 	_STARPU_MALLOC(starpu_top_datas, starpu_top_data_cpt*sizeof(struct starpu_top_data*));
 	_STARPU_MALLOC(starpu_top_datas, starpu_top_data_cpt*sizeof(struct starpu_top_data*));
 	struct starpu_top_data* cur = starpu_top_first_data;
 	struct starpu_top_data* cur = starpu_top_first_data;
@@ -159,7 +159,7 @@ void starpu_top_init_and_wait(const char* server_name)
 	STARPU_ASSERT(_starpu_top_mt);
 	STARPU_ASSERT(_starpu_top_mt);
 
 
 	//waiting for UI to connect
 	//waiting for UI to connect
-	printf("%s:%d launching network threads\n", __FILE__, __LINE__);
+	_STARPU_MSG("launching network threads\n");
 	_starpu_top_communications_threads_launcher();
 	_starpu_top_communications_threads_launcher();
 
 
 	//sending server information (report to protocol)
 	//sending server information (report to protocol)
@@ -197,22 +197,22 @@ void starpu_top_init_and_wait(const char* server_name)
 	sprintf(message, "%s", "PARAMS\n");
 	sprintf(message, "%s", "PARAMS\n");
 	_starpu_top_message_add(_starpu_top_mt,message);
 	_starpu_top_message_add(_starpu_top_mt,message);
 	struct starpu_top_param * cur_param = starpu_top_first_param;
 	struct starpu_top_param * cur_param = starpu_top_first_param;
-	printf("%s:%d sending parameters\n", __FILE__, __LINE__);
+	_STARPU_MSG("sending parameters\n");
 	while(cur_param != NULL)
 	while(cur_param != NULL)
 	{
 	{
 	  _starpu_top_message_add(_starpu_top_mt,message_for_topparam_init(cur_param));
 	  _starpu_top_message_add(_starpu_top_mt,message_for_topparam_init(cur_param));
 	  cur_param = cur_param->next;
 	  cur_param = cur_param->next;
 	}
 	}
-	printf("%s:%d parameters sended\n", __FILE__, __LINE__);
+	_STARPU_MSG("parameters sended\n");
 	_STARPU_MALLOC(message, strlen("/PARAMS\n")+1);
 	_STARPU_MALLOC(message, strlen("/PARAMS\n")+1);
 	sprintf(message, "%s", "/PARAMS\n");
 	sprintf(message, "%s", "/PARAMS\n");
 	_starpu_top_message_add(_starpu_top_mt,message);
 	_starpu_top_message_add(_starpu_top_mt,message);
 
 
 
 
 	//sending DEVICE list
 	//sending DEVICE list
-	printf("%s:%d sending devices info\n", __FILE__, __LINE__);
+	_STARPU_MSG("sending devices info\n");
 	starpu_top_send_devices_info();
 	starpu_top_send_devices_info();
-	printf("%s:%d devices_info sended\n", __FILE__, __LINE__);
+	_STARPU_MSG("devices_info sended\n");
 	//copying data and params
 	//copying data and params
 	copy_data_and_param();
 	copy_data_and_param();
 
 
@@ -222,7 +222,7 @@ void starpu_top_init_and_wait(const char* server_name)
 	_starpu_top_message_add(_starpu_top_mt,message);
 	_starpu_top_message_add(_starpu_top_mt,message);
 
 
 	//This threads keeps locked while we don't receive an GO message from UI
 	//This threads keeps locked while we don't receive an GO message from UI
-	printf("%s:%d waiting for GO message\n", __FILE__, __LINE__);
+	_STARPU_MSG("waiting for GO message\n");
 	sem_wait(&starpu_top_wait_for_go);
 	sem_wait(&starpu_top_wait_for_go);
 }
 }
 
 
@@ -721,7 +721,7 @@ static
 void starpu_top_unlock_starpu(void)
 void starpu_top_unlock_starpu(void)
 {
 {
 	sem_post(&starpu_top_wait_for_go);
 	sem_post(&starpu_top_wait_for_go);
-	printf("%s:%d starpu started\n", __FILE__, __LINE__);
+	_STARPU_MSG("starpu started\n");
 }
 }
 
 
 static
 static
@@ -731,7 +731,7 @@ void starpu_top_change_data_active(char* message, int active)
 	char* fin = strstr(debut+1, "\n");
 	char* fin = strstr(debut+1, "\n");
 	*fin = '\0';
 	*fin = '\0';
 	int data_id = atoi(debut);
 	int data_id = atoi(debut);
-	printf("%s:%d data %d %s\n", __FILE__, __LINE__, data_id, active ? "ENABLED" : "DISABLE");
+	_STARPU_MSG("data %d %s\n", data_id, active ? "ENABLED" : "DISABLE");
 	starpu_top_datas[data_id]->active = active;
 	starpu_top_datas[data_id]->active = active;
 }
 }
 
 
@@ -775,12 +775,12 @@ void starpu_top_change_debug_mode(const char*message)
 	if(!strncmp("ON",debut, 2))
 	if(!strncmp("ON",debut, 2))
 	{
 	{
 		starpu_top_debug_on = 1;
 		starpu_top_debug_on = 1;
-		printf("%s:%d debug is now ON\n", __FILE__, __LINE__);
+		_STARPU_MSG("debug is now ON\n");
 	}
 	}
 	else
 	else
 	{
 	{
 		starpu_top_debug_on = 0;
 		starpu_top_debug_on = 0;
-		printf("%s:%d debug is now OFF\n", __FILE__, __LINE__);
+		_STARPU_MSG("debug is now OFF\n");
 	}
 	}
 
 
 	char *m;
 	char *m;
@@ -823,7 +823,7 @@ void _starpu_top_process_input_message(char *buffer)
 			starpu_top_debug_next_step();
 			starpu_top_debug_next_step();
 		break;
 		break;
 		default:
 		default:
-			printf("%s:%d unknow message : '%s'\n", __FILE__, __LINE__, buffer);
+			_STARPU_MSG("unknown message : '%s'\n", buffer);
 	}
 	}
 }
 }
 
 

+ 10 - 15
src/top/starpu_top_connection.c

@@ -65,14 +65,14 @@ void * message_from_ui(void * p)
 	{
 	{
 		char * check=fgets (str, STARPU_TOP_BUFFER_SIZE, starpu_top_socket_fd_read);
 		char * check=fgets (str, STARPU_TOP_BUFFER_SIZE, starpu_top_socket_fd_read);
 
 
-		printf("Message from UI : %s",str);
+		_STARPU_MSG("Message from UI : %s",str);
 		if (check)
 		if (check)
 		{
 		{
 			_starpu_top_process_input_message(str);
 			_starpu_top_process_input_message(str);
 		}
 		}
 		else
 		else
 		{
 		{
-			fprintf(stderr,"Connection dropped\n");
+			_STARPU_MSG("Connection dropped\n");
 			//unlocking StarPU.
 			//unlocking StarPU.
 			_starpu_top_process_input_message("GO\n");
 			_starpu_top_process_input_message("GO\n");
 			_starpu_top_process_input_message("DEBUG;OFF\n");
 			_starpu_top_process_input_message("DEBUG;OFF\n");
@@ -96,7 +96,7 @@ void * message_to_ui(void * p)
 		free(message);
 		free(message);
 		if (check!=len || check2==EOF )
 		if (check!=len || check2==EOF )
 		{
 		{
-			fprintf(stderr,"Connection dropped : message no longer send\n");
+			_STARPU_MSG("Connection dropped : message no longer send\n");
 			while(1)
 			while(1)
 			{
 			{
 				message=_starpu_top_message_remove(_starpu_top_mt);
 				message=_starpu_top_message_remove(_starpu_top_mt);
@@ -115,7 +115,7 @@ void _starpu_top_communications_threads_launcher(void)
 
 
 
 
 	//Connection to UI & Socket Initilization
 	//Connection to UI & Socket Initilization
-	printf("%s:%d Connection to UI initilization\n",__FILE__, __LINE__);
+	_STARPU_MSG("Connection to UI initilization\n");
 	struct sockaddr_storage from;
 	struct sockaddr_storage from;
 	struct addrinfo req, *ans;
 	struct addrinfo req, *ans;
 	int code;
 	int code;
@@ -126,7 +126,7 @@ void _starpu_top_communications_threads_launcher(void)
 
 
 	if ((code = getaddrinfo(NULL, STARPU_TOP_PORT, &req, &ans)) != 0)
 	if ((code = getaddrinfo(NULL, STARPU_TOP_PORT, &req, &ans)) != 0)
 	{
 	{
-		fprintf(stderr, " getaddrinfo failed %d\n", code);
+		_STARPU_MSG(" getaddrinfo failed %d\n", code);
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
    	}
    	}
   	int sock=socket(ans->ai_family, ans->ai_socktype, ans->ai_protocol);
   	int sock=socket(ans->ai_family, ans->ai_socktype, ans->ai_protocol);
@@ -156,34 +156,29 @@ void _starpu_top_communications_threads_launcher(void)
 
 
    	if ((starpu_top_socket_fd=accept(sock, (struct sockaddr *) &from, &len)) ==-1)
    	if ((starpu_top_socket_fd=accept(sock, (struct sockaddr *) &from, &len)) ==-1)
 	{
 	{
-		fprintf(stderr, "accept error\n");
-		perror("accept");
-		exit(EXIT_FAILURE);
+		_STARPU_ERROR("accept error %s\n", strerror(errno));
 	}
 	}
 
 
 	if ( (starpu_top_socket_fd_read=fdopen(starpu_top_socket_fd, "r")) == NULL)
 	if ( (starpu_top_socket_fd_read=fdopen(starpu_top_socket_fd, "r")) == NULL)
 	{
 	{
-		perror("fdopen");
-		exit(EXIT_FAILURE);
+		_STARPU_ERROR("fdopen error %s\n", strerror(errno));
 	}
 	}
 
 
 	starpu_top_socket_fd=dup(starpu_top_socket_fd);
 	starpu_top_socket_fd=dup(starpu_top_socket_fd);
 	if (starpu_top_socket_fd == -1)
 	if (starpu_top_socket_fd == -1)
 	{
 	{
-		perror("dup");
-		exit(EXIT_FAILURE);
+		_STARPU_ERROR("dup error %s\n", strerror(errno));
 	}
 	}
 
 
 	if ((starpu_top_socket_fd_write=fdopen(starpu_top_socket_fd, "w")) == NULL)
 	if ((starpu_top_socket_fd_write=fdopen(starpu_top_socket_fd, "w")) == NULL)
 	{
 	{
-		perror("fdopen");
-		exit(EXIT_FAILURE);
+		_STARPU_ERROR("fdopen error %s\n", strerror(errno));
 	}
 	}
 
 
 	close(sock);
 	close(sock);
 
 
 	//Threads creation
 	//Threads creation
-	fprintf(stderr,"Threads Creation\n");
+	_STARPU_MSG("Threads Creation\n");
 	starpu_pthread_attr_init(&threads_attr);
 	starpu_pthread_attr_init(&threads_attr);
 	starpu_pthread_attr_setdetachstate(&threads_attr, PTHREAD_CREATE_DETACHED);
 	starpu_pthread_attr_setdetachstate(&threads_attr, PTHREAD_CREATE_DETACHED);
 
 

+ 5 - 5
src/top/starpu_top_message_queue.c

@@ -31,7 +31,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 {
 {
 	if( NULL == s )
 	if( NULL == s )
 	{
 	{
-		printf("Queue not initialized\n");
+		_STARPU_MSG("Queue not initialized\n");
 		free(msg);
 		free(msg);
 		return s;
 		return s;
 	}
 	}
@@ -40,7 +40,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 	STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	if( NULL == p )
 	if( NULL == p )
 	{
 	{
-		fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
+		_STARPU_MSG("IN %s, %s: malloc() failed\n", __FILE__, "list_add");
 		free(msg);
 		free(msg);
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 		return s;
@@ -51,7 +51,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 
 
 	if( NULL == s->head && NULL == s->tail )
 	if( NULL == s->head && NULL == s->tail )
 	{
 	{
-		/* printf("Empty list, adding p->num: %d\n\n", p->num);  */
+		/* _STARPU_MSG("Empty list, adding p->num: %d\n\n", p->num);  */
 		sem_post(&(s->semaphore));
 		sem_post(&(s->semaphore));
 		s->head = s->tail = p;
 		s->head = s->tail = p;
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
@@ -59,7 +59,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 	}
 	}
 	else
 	else
 	{
 	{
-		/* printf("List not empty, adding element to tail\n"); */
+		/* _STARPU_MSG("List not empty, adding element to tail\n"); */
 		sem_post(&(s->semaphore));
 		sem_post(&(s->semaphore));
 		s->tail->next = p;
 		s->tail->next = p;
 		s->tail = p;
 		s->tail = p;
@@ -73,7 +73,7 @@ char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
 {
 {
 	if( NULL == s )
 	if( NULL == s )
 	{
 	{
-		printf("List is null\n");
+		_STARPU_MSG("List is null\n");
 		return NULL;
 		return NULL;
 	}
 	}
 
 

+ 12 - 13
src/util/fstarpu.c

@@ -18,8 +18,7 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include <starpu.h>
 #include <starpu.h>
-
-#define _FSTARPU_ERROR(msg) do {fprintf(stderr, "fstarpu error: %s\n", (msg));abort();} while(0)
+#include <common/utils.h>
 
 
 typedef void (*_starpu_callback_func_t)(void *);
 typedef void (*_starpu_callback_func_t)(void *);
 
 
@@ -160,7 +159,7 @@ intptr_t fstarpu_get_constant(char *s)
 	else if (!strcmp(s, "FSTARPU_CUDA_ASYNC"))	{ return fstarpu_starpu_cuda_async; }
 	else if (!strcmp(s, "FSTARPU_CUDA_ASYNC"))	{ return fstarpu_starpu_cuda_async; }
 	else if (!strcmp(s, "FSTARPU_OPENCL_ASYNC"))	{ return fstarpu_starpu_opencl_async; }
 	else if (!strcmp(s, "FSTARPU_OPENCL_ASYNC"))	{ return fstarpu_starpu_opencl_async; }
 
 
-	else { _FSTARPU_ERROR("unknown constant"); }
+	else { _STARPU_ERROR("unknown constant"); }
 }
 }
 
 
 struct starpu_conf *fstarpu_conf_allocate(void)
 struct starpu_conf *fstarpu_conf_allocate(void)
@@ -270,7 +269,7 @@ void fstarpu_codelet_add_cpu_func(struct starpu_codelet *cl, void *f_ptr)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many cpu functions in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many cpu functions in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_cuda_func(struct starpu_codelet *cl, void *f_ptr)
 void fstarpu_codelet_add_cuda_func(struct starpu_codelet *cl, void *f_ptr)
@@ -285,7 +284,7 @@ void fstarpu_codelet_add_cuda_func(struct starpu_codelet *cl, void *f_ptr)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many cuda functions in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many cuda functions in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_cuda_flags(struct starpu_codelet *cl, intptr_t flags)
 void fstarpu_codelet_add_cuda_flags(struct starpu_codelet *cl, intptr_t flags)
@@ -300,7 +299,7 @@ void fstarpu_codelet_add_cuda_flags(struct starpu_codelet *cl, intptr_t flags)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many cuda flags in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many cuda flags in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_opencl_func(struct starpu_codelet *cl, void *f_ptr)
 void fstarpu_codelet_add_opencl_func(struct starpu_codelet *cl, void *f_ptr)
@@ -315,7 +314,7 @@ void fstarpu_codelet_add_opencl_func(struct starpu_codelet *cl, void *f_ptr)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many opencl functions in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many opencl functions in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_opencl_flags(struct starpu_codelet *cl, intptr_t flags)
 void fstarpu_codelet_add_opencl_flags(struct starpu_codelet *cl, intptr_t flags)
@@ -330,7 +329,7 @@ void fstarpu_codelet_add_opencl_flags(struct starpu_codelet *cl, intptr_t flags)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many opencl flags in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many opencl flags in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_mic_func(struct starpu_codelet *cl, void *f_ptr)
 void fstarpu_codelet_add_mic_func(struct starpu_codelet *cl, void *f_ptr)
@@ -345,7 +344,7 @@ void fstarpu_codelet_add_mic_func(struct starpu_codelet *cl, void *f_ptr)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many mic functions in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many mic functions in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_scc_func(struct starpu_codelet *cl, void *f_ptr)
 void fstarpu_codelet_add_scc_func(struct starpu_codelet *cl, void *f_ptr)
@@ -360,7 +359,7 @@ void fstarpu_codelet_add_scc_func(struct starpu_codelet *cl, void *f_ptr)
 			return;
 			return;
 		}
 		}
 	}
 	}
-	_FSTARPU_ERROR("fstarpu: too many scc functions in Fortran codelet");
+	_STARPU_ERROR("fstarpu: too many scc functions in Fortran codelet");
 }
 }
 
 
 void fstarpu_codelet_add_buffer(struct starpu_codelet *cl, intptr_t _mode)
 void fstarpu_codelet_add_buffer(struct starpu_codelet *cl, intptr_t _mode)
@@ -370,7 +369,7 @@ void fstarpu_codelet_add_buffer(struct starpu_codelet *cl, intptr_t _mode)
 	const size_t max_modes = sizeof(cl->modes)/sizeof(cl->modes[0])-1;
 	const size_t max_modes = sizeof(cl->modes)/sizeof(cl->modes[0])-1;
 	if ((mode & (STARPU_ACCESS_MODE_MAX-1)) != mode)
 	if ((mode & (STARPU_ACCESS_MODE_MAX-1)) != mode)
 	{
 	{
-		_FSTARPU_ERROR("fstarpu: invalid data mode");
+		_STARPU_ERROR("fstarpu: invalid data mode");
 	}
 	}
 	if  (cl->nbuffers < (int) max_modes)
 	if  (cl->nbuffers < (int) max_modes)
 	{
 	{
@@ -379,7 +378,7 @@ void fstarpu_codelet_add_buffer(struct starpu_codelet *cl, intptr_t _mode)
 	}
 	}
 	else
 	else
 	{
 	{
-		_FSTARPU_ERROR("fstarpu: too many buffers in Fortran codelet");
+		_STARPU_ERROR("fstarpu: too many buffers in Fortran codelet");
 	}
 	}
 }
 }
 
 
@@ -396,7 +395,7 @@ void fstarpu_codelet_set_nbuffers(struct starpu_codelet *cl, int nbuffers)
 	}
 	}
 	else
 	else
 	{
 	{
-		_FSTARPU_ERROR("fstarpu: invalid nbuffers parameter");
+		_STARPU_ERROR("fstarpu: invalid nbuffers parameter");
 	}
 	}
 }
 }