Browse Source

src: use a standard debug/messaging system

Nathalie Furmento 15 years ago
parent
commit
92f41b0c15

+ 13 - 0
src/common/utils.h

@@ -23,6 +23,19 @@
 #include <string.h>
 #include <pthread.h>
 
+#ifdef STARPU_VERBOSE
+#  define _STARPU_DEBUG(fmt, args ...) fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args)
+#else
+#  define _STARPU_DEBUG(fmt, args ...)
+#endif
+#define _STARPU_DISP(fmt, args ...) fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args)
+#define _STARPU_ERROR(fmt, args ...)                                                  \
+	do {                                                                          \
+                fprintf(stderr, "[starpu][%s] Error: " fmt ,__func__ ,##args);        \
+		STARPU_ABORT();                                                            \
+	} while (0)
+
+
 int _starpu_mkpath(const char *s, mode_t mode);
 int _starpu_check_mutex_deadlock(pthread_mutex_t *mutex);
 

+ 8 - 8
src/core/dependencies/implicit_data_deps.c

@@ -20,9 +20,9 @@
 #include <datawizard/datawizard.h>
 
 #if 0
-# define _STARPU_DEBUG(fmt, args ...) fprintf(stderr, fmt, ##args);
+# define _STARPU_DEP_DEBUG(fmt, args ...) fprintf(stderr, fmt, ##args);
 #else
-# define _STARPU_DEBUG(fmt, args ...)
+# define _STARPU_DEP_DEBUG(fmt, args ...)
 #endif
 
 /* This function adds the implicit task dependencies introduced by data
@@ -56,10 +56,10 @@ void _starpu_detect_implicit_data_deps_with_handle(struct starpu_task *pre_sync_
 	
 		if (mode & STARPU_W)
 		{
-			_STARPU_DEBUG("W %p\n", handle);
+			_STARPU_DEP_DEBUG("W %p\n", handle);
 			if (previous_mode & STARPU_W)
 			{
-				_STARPU_DEBUG("WAW %p\n", handle);
+				_STARPU_DEP_DEBUG("WAW %p\n", handle);
 				/* (Read) Write */
 				/* This task depends on the previous writer */
 				if (handle->last_submitted_writer)
@@ -87,7 +87,7 @@ void _starpu_detect_implicit_data_deps_with_handle(struct starpu_task *pre_sync_
 				 * mode: this task must depend on all those read-only
 				 * tasks and we get rid of the list of readers */
 			
-				_STARPU_DEBUG("WAR %p\n", handle);
+				_STARPU_DEP_DEBUG("WAR %p\n", handle);
 				/* Count the readers */
 				unsigned nreaders = 0;
 				struct starpu_task_wrapper_list *l;
@@ -97,7 +97,7 @@ void _starpu_detect_implicit_data_deps_with_handle(struct starpu_task *pre_sync_
 					nreaders++;
 					l = l->next;
 				}
-				_STARPU_DEBUG("%d readers\n", nreaders);
+				_STARPU_DEP_DEBUG("%d readers\n", nreaders);
 
 				struct starpu_task *task_array[nreaders];
 
@@ -137,7 +137,7 @@ void _starpu_detect_implicit_data_deps_with_handle(struct starpu_task *pre_sync_
 	
 		}
 		else {
-			_STARPU_DEBUG("R %p\n", handle);
+			_STARPU_DEP_DEBUG("R %p\n", handle);
 			/* Add a reader */
 			STARPU_ASSERT(pre_sync_task);
 			STARPU_ASSERT(post_sync_task);
@@ -151,7 +151,7 @@ void _starpu_detect_implicit_data_deps_with_handle(struct starpu_task *pre_sync_
 			/* This task depends on the previous writer if any */
 			if (handle->last_submitted_writer)
 			{
-				_STARPU_DEBUG("RAW %p\n", handle);
+				_STARPU_DEP_DEBUG("RAW %p\n", handle);
 				struct starpu_task *task_array[1] = {handle->last_submitted_writer};
 				starpu_task_declare_deps_array(pre_sync_task, 1, task_array);
 			}

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

@@ -190,8 +190,7 @@ void _starpu_get_perf_model_dir(char *path, size_t maxlen)
 	if (!home_path)
 		home_path = getenv("USERPROFILE");
 	if (!home_path) {
-		fprintf(stderr,"couldn't find a home place to put starpu data\n");
-		STARPU_ABORT();
+		_STARPU_ERROR("couldn't find a home place to put starpu data\n");
 	}
 	snprintf(path, maxlen, "%s/.starpu/sampling/", home_path);
 #endif

+ 7 - 11
src/core/perfmodel/perfmodel_bus.c

@@ -363,12 +363,12 @@ static void measure_bandwidth_between_host_and_dev(int dev, double *dev_timing_h
 
 		double bandwidth_sum2 = bandwidth_dtoh*bandwidth_dtoh + bandwidth_htod*bandwidth_htod;
 
-		fprintf(stderr, "BANDWIDTH GPU %d CPU %d - htod %lf - dtoh %lf - %lf\n", dev, current_cpu, bandwidth_htod, bandwidth_dtoh, sqrt(bandwidth_sum2));
+		_STARPU_DISP("BANDWIDTH GPU %d CPU %d - htod %lf - dtoh %lf - %lf\n", dev, current_cpu, bandwidth_htod, bandwidth_dtoh, sqrt(bandwidth_sum2));
 	}
 
 	unsigned best_cpu = dev_timing_per_cpu[(dev+1)*MAXCPUS+0].cpu_id;
 
-	fprintf(stderr, "BANDWIDTH GPU %d BEST CPU %d\n", dev, best_cpu);
+	_STARPU_DISP("BANDWIDTH GPU %d BEST CPU %d\n", dev, best_cpu);
 #endif
 
 	/* The results are sorted in a decreasing order, so that the best
@@ -383,9 +383,7 @@ static void benchmark_all_gpu_devices(void)
 #if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
 	int i, ret;
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "Benchmarking the speed of the bus\n");
-#endif
+	_STARPU_DEBUG("Benchmarking the speed of the bus\n");
 
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_topology_init(&hwtopology);
@@ -439,9 +437,7 @@ static void benchmark_all_gpu_devices(void)
 	hwloc_topology_destroy(hwtopology);
 #endif
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "Benchmarking the speed of the bus is done.\n");
-#endif
+	_STARPU_DEBUG("Benchmarking the speed of the bus is done.\n");
 #endif /* defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL) */
 
 	was_benchmarked = 1;
@@ -550,7 +546,7 @@ static void write_bus_affinity_file_content(void)
 	if (!f)
 	{
 		perror("fopen write_buf_affinity_file_content");
-		fprintf(stderr,"path '%s'\n", path);
+		_STARPU_DISP("path '%s'\n", path);
 		fflush(stderr);
 		STARPU_ABORT();
 	}
@@ -689,7 +685,7 @@ static void write_bus_latency_file_content(void)
 	if (!f)
 	{
 		perror("fopen write_bus_latency_file_content");
-		fprintf(stderr,"path '%s'\n", path);
+		_STARPU_DISP("path '%s'\n", path);
 		fflush(stderr);
 		STARPU_ABORT();
 	}
@@ -778,7 +774,7 @@ static void load_bus_bandwidth_file_content(void)
 	if (!f)
 	{
 		perror("fopen load_bus_bandwidth_file_content");
-		fprintf(stderr,"path '%s'\n", path);
+		_STARPU_DISP("path '%s'\n", path);
 		fflush(stderr);
 		STARPU_ABORT();
 	}

+ 10 - 23
src/core/perfmodel/perfmodel_history.c

@@ -260,9 +260,7 @@ static void save_history_based_model(struct starpu_perfmodel_t *model)
 	char path[256];
 	get_model_path(model, path, 256);
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "Opening performance model file %s for model %s\n", path, model->symbol);
-#endif
+	_STARPU_DEBUG("Opening performance model file %s for model %s\n", path, model->symbol);
 
 	/* overwrite existing file, or create it */
 	FILE *f;
@@ -281,9 +279,7 @@ static void _starpu_dump_registered_models(void)
 	struct starpu_model_list_t *node;
 	node = registered_models;
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "DUMP MODELS !\n");
-#endif
+	_STARPU_DEBUG("DUMP MODELS !\n");
 
 	while (node) {
 		save_history_based_model(node->model);		
@@ -357,9 +353,8 @@ static void load_history_based_model(struct starpu_perfmodel_t *model, unsigned
 	char path[256];
 	get_model_path(model, path, 256);
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "Opening performance model file %s for model %s ... ", path, model->symbol);
-#endif
+	_STARPU_DEBUG("Opening performance model file %s for model %s ... ", path, model->symbol);
+
 	unsigned calibrate_flag = _starpu_get_calibrate_flag();
 	model->benchmarking = calibrate_flag; 
 	
@@ -372,18 +367,12 @@ static void load_history_based_model(struct starpu_perfmodel_t *model, unsigned
 			/* The user specified that the performance model should
 			 * be overwritten, so we don't load the existing file !
 			 * */
-#ifdef STARPU_VERBOSE
-			fprintf(stderr, "Overwrite existing file\n");
-#endif
-	
+                        _STARPU_DEBUG("Overwrite existing file\n");
 			initialize_model(model);
 		}
 		else {
 			/* We load the available file */
-#ifdef STARPU_VERBOSE
-			fprintf(stderr, "File exists\n");
-#endif
-	
+			_STARPU_DEBUG("File exists\n");
 			FILE *f;
 			f = fopen(path, "r");
 			STARPU_ASSERT(f);
@@ -394,11 +383,9 @@ static void load_history_based_model(struct starpu_perfmodel_t *model, unsigned
 		}
 	}
 	else {
-#ifdef STARPU_VERBOSE
-		fprintf(stderr, "File does not exists\n");
-#endif
+		_STARPU_DEBUG("File does not exists\n");
 		if (!calibrate_flag) {
-			fprintf(stderr, "Warning: model %s is not calibrated, forcing calibration for this run. Use the STARPU_CALIBRATE environment variable to control this.\n", model->symbol);
+			_STARPU_DISP("Warning: model %s is not calibrated, forcing calibration for this run. Use the STARPU_CALIBRATE environment variable to control this.\n", model->symbol);
 			_starpu_set_calibrate_flag(1);
 			model->benchmarking = 1;
 		}
@@ -456,13 +443,13 @@ int starpu_load_history_debug(const char *symbol, struct starpu_perfmodel_t *mod
 	char path[256];
 	get_model_path(model, path, 256);
 
-//	fprintf(stderr, "get_model_path -> %s\n", path);
+//	_STARPU_DEBUG("get_model_path -> %s\n", path);
 
 	/* does it exist ? */
 	int res;
 	res = access(path, F_OK);
 	if (res) {
-		fprintf(stderr, "There is no performance model for symbol %s\n", symbol);
+		_STARPU_DISP("There is no performance model for symbol %s\n", symbol);
 		return 1;
 	}
 

+ 3 - 6
src/core/sched_policy.c

@@ -74,14 +74,11 @@ static void load_sched_policy(struct starpu_sched_policy_s *sched_policy)
 #ifdef STARPU_VERBOSE
 	if (sched_policy->policy_name)
 	{
-		fprintf(stderr, "Use %s scheduler", sched_policy->policy_name);
-
 		if (sched_policy->policy_description)
-		{
-			fprintf(stderr, " (%s)", sched_policy->policy_description);
-		}
+                        _STARPU_DEBUG("Use %s scheduler (%s)\n", sched_policy->policy_name, sched_policy->policy_description);
+                else
+                        _STARPU_DEBUG("Use %s scheduler \n", sched_policy->policy_name);
 
-		fprintf(stderr, "\n");
 	}
 #endif
 

+ 1 - 3
src/core/topology.c

@@ -443,9 +443,7 @@ static int _starpu_init_machine_config(struct starpu_machine_config_s *config,
 
 	if (topology->nworkers == 0)
 	{
-#ifdef STARPU_VERBOSE
-		fprintf(stderr, "No worker found, aborting ...\n");
-#endif
+                _STARPU_DEBUG("No worker found, aborting ...\n");
 		return -ENODEV;
 	}
 

+ 3 - 5
src/core/workers.c

@@ -304,9 +304,7 @@ static void _starpu_terminate_workers(struct starpu_machine_config_s *config)
 	{
 		starpu_wake_all_blocked_workers();
 		
-#ifdef STARPU_VERBOSE
-		fprintf(stderr, "wait for worker %d\n", workerid);
-#endif
+		_STARPU_DEBUG("wait for worker %d\n", workerid);
 
 		struct starpu_worker_set_s *set = config->workers[workerid].set;
 		struct starpu_worker_s *worker = &config->workers[workerid];
@@ -320,7 +318,7 @@ static void _starpu_terminate_workers(struct starpu_machine_config_s *config)
 					status = pthread_join(set->worker_thread, NULL);
 #ifdef STARPU_VERBOSE
 					if (status)
-						fprintf(stderr, "pthread_join -> %d\n", status);
+						_STARPU_DEBUG("pthread_join -> %d\n", status);
 #endif
 				}
 
@@ -333,7 +331,7 @@ static void _starpu_terminate_workers(struct starpu_machine_config_s *config)
 				status = pthread_join(worker->worker_thread, NULL);
 #ifdef STARPU_VERBOSE
 				if (status)
-					fprintf(stderr, "pthread_join -> %d\n", status);
+					_STARPU_DEBUG("pthread_join -> %d\n", status);
 #endif
 			}
 		}

+ 2 - 4
src/datawizard/coherency.c

@@ -273,7 +273,7 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 			r->mode |= mode;
 		}
 
-		//fprintf(stderr, "found a similar request : refcnt (req) %d\n", r->refcnt);
+		//_STARPU_DEBUG("found a similar request : refcnt (req) %d\n", r->refcnt);
 		_starpu_spin_unlock(&r->lock);
 		_starpu_spin_unlock(&handle->header_lock);
 	}
@@ -434,7 +434,7 @@ int _starpu_fetch_task_input(struct starpu_task *task, uint32_t mask)
 enomem:
 	/* try to unreference all the input that were successfully taken */
 	/* XXX broken ... */
-	fprintf(stderr, "something went wrong with buffer %u\n", index);
+	_STARPU_DISP("something went wrong with buffer %u\n", index);
 	//push_codelet_output(task, index, mask);
 	_starpu_push_task_output(task, mask);
 	return -1;
@@ -444,8 +444,6 @@ void _starpu_push_task_output(struct starpu_task *task, uint32_t mask)
 {
 	STARPU_TRACE_START_PUSH_OUTPUT(NULL);
 
-	//fprintf(stderr, "_starpu_push_task_output\n");
-
         starpu_buffer_descr *descrs = task->buffers;
         unsigned nbuffers = task->cl->nbuffers;
 

+ 3 - 3
src/datawizard/data_request.c

@@ -162,7 +162,7 @@ int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_a
 
 	retval = r->retval;
 	if (retval)
-		fprintf(stderr, "REQUEST %p COMPLETED (retval %d) !\n", r, r->retval);
+		_STARPU_DISP("REQUEST %p COMPLETED (retval %d) !\n", r, r->retval);
 		
 
 	r->refcnt--;
@@ -182,7 +182,7 @@ int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_a
 /* this is non blocking */
 void _starpu_post_data_request(starpu_data_request_t r, uint32_t handling_node)
 {
-//	fprintf(stderr, "POST REQUEST\n");
+//	_STARPU_DEBUG("POST REQUEST\n");
 
 	if (r->mode & STARPU_R)
 	{
@@ -371,7 +371,7 @@ void _starpu_handle_node_data_requests(uint32_t src_node, unsigned may_alloc)
 
 static void _handle_pending_node_data_requests(uint32_t src_node, unsigned force)
 {
-//	fprintf(stderr, "_starpu_handle_pending_node_data_requests ...\n");
+//	_STARPU_DEBUG("_starpu_handle_pending_node_data_requests ...\n");
 
 	PTHREAD_MUTEX_LOCK(&data_requests_pending_list_mutex[src_node]);
 

+ 1 - 1
src/datawizard/interfaces/block_interface.c

@@ -301,7 +301,7 @@ static size_t allocate_block_buffer_on_node(void *interface_, uint32_t dst_node)
 		case STARPU_CUDA_RAM:
 			status = cudaMalloc((void **)&addr, nx*ny*nz*elemsize);
 
-			//fprintf(stderr, "cudaMalloc -> addr %p\n", addr);
+			//_STARPU_DEBUG("cudaMalloc -> addr %p\n", addr);
 
 			if (!addr || status != cudaSuccess)
 			{

+ 1 - 1
src/datawizard/user_interactions.c

@@ -198,7 +198,7 @@ int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode)
 		.finished = 0
 	};
 
-//	fprintf(stderr, "TAKE sequential_consistency_mutex starpu_data_acquire\n");
+//	_STARPU_DEBUG("TAKE sequential_consistency_mutex starpu_data_acquire\n");
 	PTHREAD_MUTEX_LOCK(&handle->sequential_consistency_mutex);
 	int sequential_consistency = handle->sequential_consistency;
 	if (sequential_consistency)

+ 1 - 3
src/drivers/cpu/driver_cpu.c

@@ -95,9 +95,7 @@ void *_starpu_cpu_worker(void *arg)
 
 	_starpu_bind_thread_on_cpu(cpu_arg->config, cpu_arg->bindid);
 
-#ifdef STARPU_VERBOSE
-        fprintf(stderr, "cpu worker %d is ready on logical cpu %d\n", devid, cpu_arg->bindid);
-#endif
+        _STARPU_DEBUG("cpu worker %d is ready on logical cpu %d\n", devid, cpu_arg->bindid);
 
 	_starpu_set_local_memory_node_key(&memnode);
 

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

@@ -178,9 +178,7 @@ void *_starpu_cuda_worker(void *arg)
 	strncpy(devname, prop.name, 128);
 	snprintf(args->name, 32, "CUDA %d (%s)", args->devid, devname);
 
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "cuda (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
-#endif
+	_STARPU_DEBUG("cuda (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
 
 	STARPU_TRACE_WORKER_INIT_END
 
@@ -243,7 +241,7 @@ void *_starpu_cuda_worker(void *arg)
 		if (res) {
 			switch (res) {
 				case -EAGAIN:
-					fprintf(stderr, "ouch, put the codelet %p back ... \n", j);
+					_STARPU_DISP("ouch, put the codelet %p back ... \n", j);
 					_starpu_push_task(j, 0);
 					STARPU_ABORT();
 					continue;

+ 7 - 7
src/drivers/gordon/driver_gordon.c

@@ -47,7 +47,7 @@ struct gordon_task_wrapper_s {
 
 void *gordon_worker_progress(void *arg)
 {
-	fprintf(stderr, "gordon_worker_progress\n");
+	_STARPU_DEBUG("gordon_worker_progress\n");
 
 	/* fix the thread on the correct cpu */
 	struct starpu_worker_set_s *gordon_set_arg = arg;
@@ -190,7 +190,7 @@ static void gordon_callback_list_func(void *arg)
 
 	task_wrapper->terminated = 1;
 
-//	fprintf(stderr, "gordon callback : push job j %p\n", task_wrapper->j);
+//	_STARPU_DEBUG("gordon callback : push job j %p\n", task_wrapper->j);
 
 	unsigned task_cnt = 0;
 
@@ -286,7 +286,7 @@ int inject_task_list(struct starpu_job_list_s *list, struct starpu_worker_s *wor
 //	}
 
 	nvalids = job_list_size(list);
-//	fprintf(stderr, "nvalids %d \n", nvalids);
+//	_STARPU_DEBUG("nvalids %d \n", nvalids);
 
 	
 
@@ -390,7 +390,7 @@ void *gordon_worker_inject(struct starpu_worker_set_s *arg)
 			/* gordon should accept a little more work */
 			starpu_job_t j;
 			j =  _starpu_pop_task();
-	//		fprintf(stderr, "pop task %p\n", j);
+	//		_STARPU_DEBUG("pop task %p\n", j);
 			if (j) {
 				if (STARPU_GORDON_MAY_PERFORM(j)) {
 					/* inject that task */
@@ -449,7 +449,7 @@ void *_starpu_gordon_worker(void *arg)
 		PTHREAD_COND_WAIT(&progress_cond, &progress_mutex);
 	PTHREAD_MUTEX_UNLOCK(&progress_mutex);
 
-	fprintf(stderr, "progress thread is running ... \n");
+	_STARPU_DEBUG("progress thread is running ... \n");
 	
 	/* tell the core that gordon is ready */
 	PTHREAD_MUTEX_LOCK(&gordon_set_arg->mutex);
@@ -459,9 +459,9 @@ void *_starpu_gordon_worker(void *arg)
 
 	gordon_worker_inject(gordon_set_arg);
 
-	fprintf(stderr, "gordon deinit...\n");
+	_STARPU_DEBUG("gordon deinit...\n");
 	gordon_deinit();
-	fprintf(stderr, "gordon was deinited\n");
+	_STARPU_DEBUG("gordon was deinited\n");
 
 	pthread_exit((void *)0x42);
 }

+ 10 - 10
src/drivers/opencl/driver_opencl.c

@@ -55,7 +55,7 @@ int _starpu_opencl_init_context(int devid)
 	cl_int err;
         cl_device_id device;
 
-        _STARPU_OPENCL_DEBUG("Initialising context for dev %d\n", devid);
+        _STARPU_DEBUG("Initialising context for dev %d\n", devid);
 
         // Create a compute context
         device = devices[devid];
@@ -73,7 +73,7 @@ int _starpu_opencl_deinit_context(int devid)
 {
         int err;
 
-        _STARPU_OPENCL_DEBUG("De-initialising context for dev %d\n", devid);
+        _STARPU_DEBUG("De-initialising context for dev %d\n", devid);
 
         err = clReleaseContext(contexts[devid]);
         if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
@@ -222,12 +222,12 @@ void _starpu_opencl_init(void)
                 cl_int err;
                 unsigned int i;
 
-                _STARPU_OPENCL_DEBUG("Initialising OpenCL\n");
+                _STARPU_DEBUG("Initialising OpenCL\n");
 
                 // Get Platforms
                 err = clGetPlatformIDs(STARPU_OPENCL_PLATFORM_MAX, platform_id, &nb_platforms);
                 if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
-                _STARPU_OPENCL_DEBUG("Platforms detected: %d\n", nb_platforms);
+                _STARPU_DEBUG("Platforms detected: %d\n", nb_platforms);
 
                 // Get devices
                 nb_devices = 0;
@@ -240,16 +240,16 @@ void _starpu_opencl_init(void)
                                         char name[1024], vendor[1024];
                                         clGetPlatformInfo(platform_id[i], CL_PLATFORM_NAME, 1024, name, NULL);
                                         clGetPlatformInfo(platform_id[i], CL_PLATFORM_VENDOR, 1024, vendor, NULL);
-                                        _STARPU_OPENCL_DEBUG("Platform: %s - %s\n", name, vendor);
+                                        _STARPU_DEBUG("Platform: %s - %s\n", name, vendor);
                                 }
 #endif
                                 err = clGetDeviceIDs(platform_id[i], device_type, STARPU_MAXOPENCLDEVS-nb_devices, &devices[nb_devices], &num);
                                 if (err == CL_DEVICE_NOT_FOUND) {
-                                        _STARPU_OPENCL_DEBUG("  No devices detected on this platform\n");
+                                        _STARPU_DEBUG("  No devices detected on this platform\n");
                                 }
                                 else {
                                         if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
-                                        _STARPU_OPENCL_DEBUG("  %d devices detected\n", num);
+                                        _STARPU_DEBUG("  %d devices detected\n", num);
                                         nb_devices += num;
                                 }
                         }
@@ -303,7 +303,7 @@ void *_starpu_opencl_worker(void *arg)
 	_starpu_opencl_get_device_name(devid, devname, 128);
 	snprintf(args->name, 32, "OpenCL %d (%s)", args->devid, devname);
 
-	_STARPU_OPENCL_DEBUG("OpenCL (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
+	_STARPU_DEBUG("OpenCL (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
 
 	STARPU_TRACE_WORKER_INIT_END
 
@@ -366,7 +366,7 @@ void *_starpu_opencl_worker(void *arg)
                 if (res) {
 			switch (res) {
 				case -EAGAIN:
-					fprintf(stderr, "ouch, put the codelet %p back ... \n", j);
+					_STARPU_DISP("ouch, put the codelet %p back ... \n", j);
 					_starpu_push_task(j, 0);
 					STARPU_ABORT();
 					continue;
@@ -399,7 +399,7 @@ static unsigned _starpu_opencl_get_device_name(int dev, char *name, int lname)
 	err = clGetDeviceInfo(devices[dev], CL_DEVICE_NAME, lname, name, NULL);
 	if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
 
-	_STARPU_OPENCL_DEBUG("Device %d : [%s]\n", dev, name);
+	_STARPU_DEBUG("Device %d : [%s]\n", dev, name);
 	return EXIT_SUCCESS;
 }
 

+ 10 - 10
src/drivers/opencl/driver_opencl_utils.c

@@ -34,25 +34,25 @@ char *_starpu_opencl_program_dir;
 
 static
 int _starpu_opencl_locate_file(char *source_file_name, char *located_file_name) {
-        _STARPU_OPENCL_DEBUG("Trying to locate <%s>\n", source_file_name);
+        _STARPU_DEBUG("Trying to locate <%s>\n", source_file_name);
         if (access(source_file_name, R_OK) == 0) {
                 strcpy(located_file_name, source_file_name);
                 return EXIT_SUCCESS;
         }
         if (_starpu_opencl_program_dir) {
                 sprintf(located_file_name, "%s/%s", _starpu_opencl_program_dir, source_file_name);
-                _STARPU_OPENCL_DEBUG("Trying to locate <%s>\n", located_file_name);
+                _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
                 if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;
         }
         sprintf(located_file_name, "%s/%s", _STARPU_STRINGIFY(STARPU_OPENCL_DATADIR), source_file_name);
-        _STARPU_OPENCL_DEBUG("Trying to locate <%s>\n", located_file_name);
+        _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
         if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;
         sprintf(located_file_name, "%s/%s", STARPU_SRC_DIR, source_file_name);
-        _STARPU_OPENCL_DEBUG("Trying to locate <%s>\n", located_file_name);
+        _STARPU_DEBUG("Trying to locate <%s>\n", located_file_name);
         if (access(located_file_name, R_OK) == 0) return EXIT_SUCCESS;
 
         strcpy(located_file_name, "");
-        _STARPU_OPENCL_ERROR("Cannot locate file <%s>\n", source_file_name);
+        _STARPU_ERROR("Cannot locate file <%s>\n", source_file_name);
         return EXIT_FAILURE;
 }
 
@@ -70,7 +70,7 @@ int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct
 
         program = opencl_programs->programs[devid];
         if (!program) {
-                fprintf(stderr, "Program not available\n");
+                _STARPU_DISP("Program not available\n");
                 return CL_INVALID_PROGRAM;
         }
 
@@ -140,10 +140,10 @@ int starpu_opencl_load_opencl_from_string(char *opencl_program_source, struct st
                         size_t len;
                         static char buffer[4096];
 
-                        fprintf(stderr, "Error: Failed to build program executable!\n");
+                        _STARPU_DISP("Error: Failed to build program executable!\n");
                         clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
 
-                        fprintf(stderr, "<%s>\n", buffer);
+                        _STARPU_DISP("<%s>\n", buffer);
                         return EXIT_FAILURE;
                 }
 
@@ -159,12 +159,12 @@ int starpu_opencl_load_opencl_from_file(char *source_file_name, struct starpu_op
 
         // Locate source file
         _starpu_opencl_locate_file(source_file_name, located_file_name);
-        _STARPU_OPENCL_DEBUG("Source file name : <%s>\n", located_file_name);
+        _STARPU_DEBUG("Source file name : <%s>\n", located_file_name);
 
         // Load the compute program from disk into a cstring buffer
         char *opencl_program_source = _starpu_opencl_load_program_source(located_file_name);
         if(!opencl_program_source)
-                _STARPU_OPENCL_ERROR("Failed to load compute program from file <%s>!\n", located_file_name);
+                _STARPU_ERROR("Failed to load compute program from file <%s>!\n", located_file_name);
 
         return starpu_opencl_load_opencl_from_string(opencl_program_source, opencl_programs);
 }

+ 0 - 14
src/drivers/opencl/driver_opencl_utils.h

@@ -19,20 +19,6 @@
 
 #include <config.h>
 
-#ifdef STARPU_VERBOSE
-#  define _STARPU_OPENCL_DEBUG(fmt, args ...) fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args)
-#else
-#  define _STARPU_OPENCL_DEBUG(fmt, args ...)
-#endif
-
-#define _STARPU_OPENCL_DISP(fmt, args ...) fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args)
-
-#define _STARPU_OPENCL_ERROR(fmt, args ...)                                                   \
-	do {                                                                          \
-                fprintf(stderr, "[starpu][%s] Error: " fmt ,__func__ ,##args); \
-		assert(0);                                                            \
-	} while (0)
-
 #define STARPU_OPENCL_PLATFORM_MAX 4
 
 #endif /* __STARPU_OPENCL_UTILS_H__ */

+ 4 - 10
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -30,10 +30,6 @@ static double alpha = 1.0;
 static double beta = 1.0;
 
 #ifdef STARPU_VERBOSE
-#define DISPLAY_DEBUG
-#endif
-
-#ifdef DISPLAY_DEBUG
 static long int total_task_cnt = 0;
 static long int ready_task_cnt = 0;
 #endif
@@ -125,7 +121,7 @@ static struct starpu_task *dmda_pop_ready_task(void)
 		fifo->exp_start = _starpu_timing_now() + model;
 		fifo->exp_end = fifo->exp_start + fifo->exp_len;
 
-#ifdef DISPLAY_DEBUG
+#ifdef STARPU_VERBOSE
 		if (task->cl)
 		{
 			int non_ready = count_non_ready_buffers(task, starpu_worker_get_memory_node(workerid));
@@ -155,7 +151,7 @@ static struct starpu_task *dmda_pop_task(void)
 		fifo->exp_start = _starpu_timing_now() + model;
 		fifo->exp_end = fifo->exp_start + fifo->exp_len;
 
-#ifdef DISPLAY_DEBUG
+#ifdef STARPU_VERBOSE
 		if (task->cl)
 		{
 			int non_ready = count_non_ready_buffers(task, starpu_worker_get_memory_node(workerid));
@@ -427,7 +423,7 @@ static int _dmda_push_task(struct starpu_task *task, unsigned prio)
 				best_fitness = fitness[worker];
 				best = worker;
 
-	//			fprintf(stderr, "best fitness (worker %d) %le = alpha*(%le) + beta(%le) \n", worker, best_fitness, exp_end[worker] - best_exp_end, local_data_penalty[worker]);
+	//			_STARPU_DEBUG("best fitness (worker %d) %le = alpha*(%le) + beta(%le) \n", worker, best_fitness, exp_end[worker] - best_exp_end, local_data_penalty[worker]);
 			}
 		}
 	}
@@ -516,9 +512,7 @@ static void deinitialize_dmda_policy(struct starpu_machine_topology_s *topology,
 	for (workerid = 0; workerid < topology->nworkers; workerid++)
 		_starpu_destroy_fifo(queue_array[workerid]);
 
-#ifdef DISPLAY_DEBUG
-	fprintf(stderr, "total_task_cnt %ld ready_task_cnt %ld -> %f\n", total_task_cnt, ready_task_cnt, (100.0f*ready_task_cnt)/total_task_cnt);
-#endif
+	_STARPU_DEBUG("total_task_cnt %ld ready_task_cnt %ld -> %f\n", total_task_cnt, ready_task_cnt, (100.0f*ready_task_cnt)/total_task_cnt);
 }
 
 struct starpu_sched_policy_s _starpu_sched_dm_policy = {

+ 1 - 1
src/sched_policies/random_policy.c

@@ -51,7 +51,7 @@ static int _random_push_task(struct starpu_task *task, unsigned prio)
 	}
 
 	double random = starpu_drand48()*alpha_sum;
-//	fprintf(stderr, "my rand is %e\n", random);
+//	_STARPU_DEBUG("my rand is %e\n", random);
 
 	double alpha = 0.0;
 	for (worker = 0; worker < nworkers; worker++)