瀏覽代碼

src: minor fixes

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

+ 2 - 1
src/common/utils.c

@@ -305,7 +305,8 @@ char *_starpu_mktemp_many(const char *directory, int depth, int flags, int *fd)
 		return NULL;
 	}
 	retpath = _starpu_mktemp(path, flags, fd);
-	if (!retpath) {
+	if (!retpath)
+	{
 		/* That failed, drop our directories */
 		_starpu_rmdir_many(path, depth);
 	}

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

@@ -1357,8 +1357,10 @@ int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
 	struct _starpu_perfmodel *node;
 	for (node  = _starpu_perfmodel_list_begin(&registered_models);
 	     node != _starpu_perfmodel_list_end(&registered_models);
-	     node  = _starpu_perfmodel_list_next(node)) {
-		if (node->model == model) {
+	     node  = _starpu_perfmodel_list_next(node))
+	{
+		if (node->model == model)
+		{
 			_starpu_perfmodel_list_erase(&registered_models, node);
 			_starpu_perfmodel_delete(node);
 			break;

+ 2 - 2
src/core/sched_ctx.c

@@ -1199,13 +1199,13 @@ static void _defer_ctx_change(int sched_ctx_id, enum _starpu_ctx_change_op op, i
 	chg->op = op;
 	STARPU_ASSERT(workerids_to_change != NULL);
 	chg->nworkers_to_change = nworkers_to_change;
-	chg->workerids_to_change = malloc(nworkers_to_change * sizeof(chg->workerids_to_change[0]));
+	_STARPU_MALLOC(chg->workerids_to_change, nworkers_to_change * sizeof(chg->workerids_to_change[0]));
 	memcpy(chg->workerids_to_change, workerids_to_change, nworkers_to_change * sizeof(chg->workerids_to_change[0]));
 	if (nworkers_to_notify != 0)
 	{
 		STARPU_ASSERT(workerids_to_notify != NULL);
 		chg->nworkers_to_notify = nworkers_to_notify;
-		chg->workerids_to_notify = malloc(nworkers_to_notify * sizeof(chg->workerids_to_notify[0]));
+		_STARPU_MALLOC(chg->workerids_to_notify, nworkers_to_notify * sizeof(chg->workerids_to_notify[0]));
 		memcpy(chg->workerids_to_notify, workerids_to_notify, nworkers_to_notify * sizeof(chg->workerids_to_notify[0]));
 	}
 	else

+ 2 - 1
src/core/task.c

@@ -1248,7 +1248,8 @@ unsigned long starpu_task_get_job_id(struct starpu_task *task)
 
 static starpu_pthread_t watchdog_thread;
 
-static int sleep_some(float timeout) {
+static int sleep_some(float timeout)
+{
 	/* If we do a sleep(timeout), we might have to wait too long at the end of the computation. */
 	/* To avoid that, we do several sleep() of 1s (and check after each if starpu is still running) */
 	float t;

+ 4 - 2
src/datawizard/malloc.c

@@ -306,7 +306,8 @@ int _starpu_malloc_flags_on_node(unsigned dst_node, void **A, size_t dim, int fl
 #endif
 	}
 #ifdef STARPU_HAVE_HWLOC
-	if (starpu_memory_nodes_get_numa_count() > 1) {
+	if (starpu_memory_nodes_get_numa_count() > 1)
+	{
 		struct _starpu_machine_config *config = _starpu_get_machine_config();
 		hwloc_topology_t hwtopology = config->topology.hwtopology;
 		hwloc_obj_t numa_node_obj = hwloc_get_obj_by_type(hwtopology, HWLOC_OBJ_NODE, starpu_memory_nodes_numa_id_to_hwloclogid(dst_node));
@@ -495,7 +496,8 @@ int _starpu_free_flags_on_node(unsigned dst_node, void *A, size_t dim, int flags
 #endif
 	}
 #ifdef STARPU_HAVE_HWLOC
-	else if (starpu_memory_nodes_get_numa_count() > 1) {
+	else if (starpu_memory_nodes_get_numa_count() > 1)
+	{
 		struct _starpu_machine_config *config = _starpu_get_machine_config();
 		hwloc_topology_t hwtopology = config->topology.hwtopology;
 		hwloc_free(hwtopology, A, dim);

+ 2 - 1
src/debug/traces/starpu_fxt.c

@@ -618,7 +618,8 @@ static int prefixTOnodeid (const char *prefix)
 	//if we are a single-node trace, prefix is empty, so return 0
 	if (strcmp(prefix, "")==0) return 0;
 
-	char *str = malloc(sizeof(char)*strlen(prefix));
+	char *str;
+	_STARPU_MALLOC(str, sizeof(char)*strlen(prefix));
 	strncpy (str, prefix, strlen(prefix));
 	str[strlen(prefix)-1] = '\0';
 	unsigned long nodeid = atoi(str);

+ 18 - 16
src/sched_policies/component_prio.c

@@ -124,7 +124,7 @@ static int prio_push_local_task(struct starpu_sched_component * component, struc
 	else
 		exp_len = prio->exp_len;
 
-	if((data->ntasks_threshold != 0) && (data->exp_len_threshold != 0.0) && 
+	if((data->ntasks_threshold != 0) && (data->exp_len_threshold != 0.0) &&
 			((prio->ntasks >= data->ntasks_threshold) || (exp_len >= data->exp_len_threshold)))
 	{
 		static int warned;
@@ -146,15 +146,16 @@ static int prio_push_local_task(struct starpu_sched_component * component, struc
 			starpu_sched_component_prefetch_on_node(component, task);
 			STARPU_TRACE_SCHED_COMPONENT_PUSH_PRIO(component, prio->ntasks, exp_len);
 		}
-		
-		if(!isnan(task->predicted_transfer)) {
-			double end = prio_estimated_end(component); 
-			double tfer_end = now + task->predicted_transfer; 
-			if(tfer_end < end) 
-				task->predicted_transfer = 0.0; 
-			else 
-				task->predicted_transfer = tfer_end - end; 
-			exp_len += task->predicted_transfer; 
+
+		if(!isnan(task->predicted_transfer))
+		{
+			double end = prio_estimated_end(component);
+			double tfer_end = now + task->predicted_transfer;
+			if(tfer_end < end)
+				task->predicted_transfer = 0.0;
+			else
+				task->predicted_transfer = tfer_end - end;
+			exp_len += task->predicted_transfer;
 		}
 
 		if(!isnan(task->predicted))
@@ -165,7 +166,7 @@ static int prio_push_local_task(struct starpu_sched_component * component, struc
 		STARPU_ASSERT(!isnan(prio->exp_end));
 		STARPU_ASSERT(!isnan(prio->exp_len));
 		STARPU_ASSERT(!isnan(prio->exp_start));
-		
+
 		STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
 		if(!is_pushback)
 			component->can_pull(component);
@@ -206,7 +207,8 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 			}
 		}
 		STARPU_ASSERT_MSG(prio->exp_len>=0, "prio->exp_len=%lf\n",prio->exp_len);
-		if(!isnan(task->predicted_transfer)){
+		if(!isnan(task->predicted_transfer))
+		{
 			if (prio->exp_len > task->predicted_transfer)
 			{
 				prio->exp_start += task->predicted_transfer;
@@ -222,7 +224,7 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 		prio->exp_end = prio->exp_start + prio->exp_len;
 		if(prio->ntasks == 0)
 			prio->exp_len = 0.0;
-		
+
 		STARPU_TRACE_SCHED_COMPONENT_POP_PRIO(component, prio->ntasks, prio->exp_len);
 	}
 	STARPU_ASSERT(!isnan(prio->exp_end));
@@ -233,8 +235,8 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 	// When a pop is called, a can_push is called for pushing tasks onto
 	// the empty place of the queue left by the popped task.
 
-	starpu_sched_component_send_can_push_to_parents(component); 
-	
+	starpu_sched_component_send_can_push_to_parents(component);
+
 	if(task)
 		return task;
 
@@ -252,7 +254,7 @@ static int prio_can_push(struct starpu_sched_component * component)
 	int res = 0;
 	struct starpu_task * task;
 
-	task = starpu_sched_component_pump_downstream(component, &res); 
+	task = starpu_sched_component_pump_downstream(component, &res);
 
 	if(task)
 	{

+ 17 - 17
src/sched_policies/component_sched.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2013, 2017  INRIA
  * Copyright (C) 2013  Simon Archipoff
- * 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
@@ -43,7 +43,7 @@ int starpu_sched_component_execute_preds(struct starpu_sched_component * compone
 	int can_execute = 0;
 	starpu_task_bundle_t bundle = task->bundle;
 	double len = DBL_MAX;
-	
+
 
 	int workerid;
 	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
@@ -67,7 +67,6 @@ int starpu_sched_component_execute_preds(struct starpu_sched_component * compone
 				{
 					*length = d;
 					return can_execute;
-						
 				}
 				if(_STARPU_IS_ZERO(d))
 				{
@@ -85,7 +84,7 @@ int starpu_sched_component_execute_preds(struct starpu_sched_component * compone
 	}
 
 	if(len == DBL_MAX) /* we dont have perf model */
-		len = 0.0; 
+		len = 0.0;
 	if(length)
 		*length = len;
 	return can_execute;
@@ -147,7 +146,7 @@ double starpu_sched_component_transfer_length(struct starpu_sched_component * co
 }
 
 /* This function can be called by components when they think that a prefetching request can be submitted.
- * For example, it is currently used by the MCT component to begin the prefetching on accelerators 
+ * For example, it is currently used by the MCT component to begin the prefetching on accelerators
  * on which it pushed tasks as soon as possible.
  */
 void starpu_sched_component_prefetch_on_node(struct starpu_sched_component * component, struct starpu_task * task)
@@ -163,7 +162,7 @@ void starpu_sched_component_prefetch_on_node(struct starpu_sched_component * com
 }
 
 /* remove all child
- * for all child of component, if child->parents[x] == component, set child->parents[x] to null 
+ * for all child of component, if child->parents[x] == component, set child->parents[x] to null
  * call component->deinit_data
  */
 void starpu_sched_component_destroy(struct starpu_sched_component *component)
@@ -234,14 +233,14 @@ void set_properties(struct starpu_sched_component * component)
 	int is_all_same_component = 1;
 	for(;
 	    worker != -1;
-	    worker = starpu_bitmap_next(component->workers_in_ctx, worker))		
+	    worker = starpu_bitmap_next(component->workers_in_ctx, worker))
 	{
 		if(first_worker != _starpu_get_worker_struct(worker)->worker_mask)
 			is_homogeneous = 0;
 		if(first_memory_node != _starpu_get_worker_struct(worker)->memory_node)
 			is_all_same_component = 0;
 	}
-	
+
 
 	if(is_homogeneous)
 		component->properties |= STARPU_SCHED_COMPONENT_HOMOGENEOUS;
@@ -337,7 +336,7 @@ int starpu_sched_tree_push_task(struct starpu_task * task)
 	struct starpu_sched_tree *tree = starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
 	int ret_val = starpu_sched_component_push_task(NULL, tree->root,task);
-	
+
 	return ret_val;
 }
 
@@ -369,10 +368,10 @@ struct starpu_task * starpu_sched_component_pull_task(struct starpu_sched_compon
 
 /* Pump mechanic to get the task flow rolling. Takes tasks from component and send them to the child.
    To be used by components with only one child */
-struct starpu_task* starpu_sched_component_pump_downstream(struct starpu_sched_component *component, int* success) 
+struct starpu_task* starpu_sched_component_pump_downstream(struct starpu_sched_component *component, int* success)
 {
 	int ret = 0;
-	
+
 	STARPU_ASSERT(component->nchildren == 1);
 	struct starpu_sched_component * child = component->children[0];
 	struct starpu_task * task;
@@ -382,17 +381,17 @@ struct starpu_task* starpu_sched_component_pump_downstream(struct starpu_sched_c
 		task = starpu_sched_component_pull_task(component,component);
 		if (!task)
 			break;
-		ret = starpu_sched_component_push_task(component,child,task);	
+		ret = starpu_sched_component_push_task(component,child,task);
 		if (ret)
 			break;
-		if(success) 
-			* success = 1; 
+		if(success)
+			* success = 1;
 	}
 	if(task && ret)
 		return task;
 
 	return NULL;
-	
+
 }
 
 void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
@@ -580,7 +579,8 @@ static int starpu_sched_component_can_pull(struct starpu_sched_component * compo
 	STARPU_ASSERT(component);
 	STARPU_ASSERT(!starpu_sched_component_is_worker(component));
 	unsigned i;
-	for(i = 0; i < component->nchildren; i++) {
+	for(i = 0; i < component->nchildren; i++)
+	{
 		if (component->children[i]->can_pull(component->children[i]))
 			return 1;
 	}
@@ -596,7 +596,7 @@ int starpu_sched_component_send_can_push_to_parents(struct starpu_sched_componen
 {
 	STARPU_ASSERT(component);
 	STARPU_ASSERT(!starpu_sched_component_is_worker(component));
-	
+
 	unsigned i;
 	int ret = 0;
 	for(i=0; i < component->nparents; i++)

+ 2 - 1
src/worker_collection/worker_tree.c

@@ -186,7 +186,8 @@ static unsigned tree_has_next(struct starpu_worker_collection *workers, struct s
 	int nworkers;
 	int w;
 
-	if (it->value) {
+	if (it->value)
+	{
 		struct starpu_tree *node = it->value;
 		/* Are there workers left to be processed in the current node? */
 		nworkers = starpu_bindid_get_workerids(node->id, &workerids);