Cédric Augonnet 15 rokov pred
rodič
commit
7d04e39814

+ 3 - 23
src/datawizard/coherency.h

@@ -40,7 +40,6 @@
 #include <datawizard/datastats.h>
 
 typedef enum {
-//	MODIFIED,
 	OWNER,
 	SHARED,
 	INVALID
@@ -72,29 +71,10 @@ typedef struct local_data_state_t {
 	struct data_request_s *request;
 } local_data_state;
 
-/* Everyone that wants to access some piece of data will post a request.
- * Not only StarPU internals, but also the application may put such requests */
-
-LIST_TYPE(data_requester,
-	/* what kind of access is requested ? */
-	starpu_access_mode mode;
-
-	/* applications may also directly manipulate data */
-	unsigned is_requested_by_codelet;
-
-	/* in case this is a codelet that will do the access */
-	struct job_s *j;
-	unsigned buffer_index;
-
-	/* if this is more complicated ... (eg. application request) 
-	 * NB: this callback is not called with the lock taken !
-	 */
-	void (*ready_data_callback)(void *argcb);
-	void *argcb;
-);
+struct data_requester_list_s;
 
 struct starpu_data_state_t {
-	data_requester_list_t req_list;
+	struct data_requester_list_s *req_list;
 	/* the number of requests currently in the scheduling engine
 	 * (not in the req_list anymore) */
 	unsigned refcnt;
@@ -104,7 +84,7 @@ struct starpu_data_state_t {
 
 	uint32_t nnodes; /* the number of memory nodes that may use it */
 	struct starpu_data_state_t *children;
-	int nchildren;
+	unsigned nchildren;
 
 	/* describe the state of the data in term of coherency */
 	local_data_state per_node[MAXNODES];

+ 7 - 4
src/datawizard/data_request.c

@@ -206,11 +206,14 @@ static void handle_data_request_completion(data_request_t r)
 	unsigned do_delete = 0;
 	starpu_data_handle handle = r->handle;
 
-	update_data_state(handle, r->dst_node, r->write);
+	uint32_t src_node = r->src_node;
+	uint32_t dst_node = r->dst_node;
+
+	update_data_state(handle, dst_node, r->write);
 
 #ifdef USE_FXT
 	size_t size = handle->ops->get_size(handle);
-	TRACE_END_DRIVER_COPY(r->src_node, r->dst_node, size, r->com_id);
+	TRACE_END_DRIVER_COPY(src_node, dst_node, size, r->com_id);
 #endif
 
 	unsigned chained_req;
@@ -221,10 +224,10 @@ static void handle_data_request_completion(data_request_t r)
 
 	r->completed = 1;
 	
-	handle->per_node[r->dst_node].refcnt--;
+	handle->per_node[dst_node].refcnt--;
 
 	if (r->read)
-		handle->per_node[r->src_node].refcnt--;
+		handle->per_node[src_node].refcnt--;
 
 	r->refcnt--;
 

+ 20 - 0
src/datawizard/data_request.h

@@ -62,6 +62,26 @@ LIST_TYPE(data_request,
 #endif
 );
 
+/* Everyone that wants to access some piece of data will post a request.
+ * Not only StarPU internals, but also the application may put such requests */
+LIST_TYPE(data_requester,
+	/* what kind of access is requested ? */
+	starpu_access_mode mode;
+
+	/* applications may also directly manipulate data */
+	unsigned is_requested_by_codelet;
+
+	/* in case this is a codelet that will do the access */
+	struct job_s *j;
+	unsigned buffer_index;
+
+	/* if this is more complicated ... (eg. application request) 
+	 * NB: this callback is not called with the lock taken !
+	 */
+	void (*ready_data_callback)(void *argcb);
+	void *argcb;
+);
+
 void init_data_request_lists(void);
 void deinit_data_request_lists(void);
 void post_data_request(data_request_t r, uint32_t handling_node);

+ 7 - 6
src/datawizard/hierarchy.c

@@ -109,7 +109,7 @@ static void map_filter(starpu_data_handle root_handle, starpu_filter *f)
 	}
 	else {
 		/* try to apply the starpu_filter recursively */
-		int child;
+		unsigned child;
 		for (child = 0; child < root_handle->nchildren; child++)
 		{
 			map_filter(&root_handle->children[child], f);
@@ -139,8 +139,7 @@ void starpu_map_filters(starpu_data_handle root_handle, unsigned nfilters, ...)
  */
 starpu_data_handle starpu_data_get_child(starpu_data_handle handle, unsigned i)
 {
-#warning TODO nchildren should not be an int
-	STARPU_ASSERT(i < (unsigned)handle->nchildren);
+	STARPU_ASSERT(i < handle->nchildren);
 
 	return &handle->children[i];
 }
@@ -159,7 +158,7 @@ starpu_data_handle get_sub_data(starpu_data_handle root_handle, unsigned depth,
 		unsigned next_child;
 		next_child = va_arg(pa, unsigned);
 
-		STARPU_ASSERT((int)next_child < current_handle->nchildren);
+		STARPU_ASSERT(next_child < current_handle->nchildren);
 
 		current_handle = &current_handle->children[next_child];
 	}
@@ -225,7 +224,7 @@ void starpu_partition_data(starpu_data_handle initial_handle, starpu_filter *f)
 
 void starpu_unpartition_data(starpu_data_handle root_handle, uint32_t gathering_node)
 {
-	int child;
+	unsigned child;
 	unsigned node;
 
 	starpu_spin_lock(&root_handle->header_lock);
@@ -314,7 +313,7 @@ void starpu_advise_if_data_is_important(starpu_data_handle handle, unsigned is_i
 	starpu_spin_lock(&handle->header_lock);
 
 	/* first take all the children lock (in order !) */
-	int child;
+	unsigned child;
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		/* make sure the intermediate children is advised as well */
@@ -350,6 +349,8 @@ starpu_data_handle starpu_data_state_create(struct data_interface_ops_t *interfa
 	return handle;
 }
 
+/* TODO create an alternative version of that function which takes an array of
+ * data interface ops in case each child may have its own interface type */
 void starpu_data_create_children(starpu_data_handle handle,
 		unsigned nchildren, struct data_interface_ops_t *children_interface_ops)
 {

+ 0 - 1
src/datawizard/interfaces/blas_interface.c

@@ -20,7 +20,6 @@
 #include <datawizard/copy-driver.h>
 #include <datawizard/hierarchy.h>
 
-
 #include <common/hash.h>
 
 #include <starpu.h>

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

@@ -222,7 +222,7 @@ static size_t allocate_vector_buffer_on_node(starpu_data_handle handle, uint32_t
 	return allocated_memory;
 }
 
-void liberate_vector_buffer_on_node(void *interface, uint32_t node)
+static void liberate_vector_buffer_on_node(void *interface, uint32_t node)
 {
 	starpu_vector_interface_t *vector_interface = interface;
 

+ 9 - 6
src/datawizard/memalloc.c

@@ -54,7 +54,7 @@ static void lock_all_subtree(starpu_data_handle handle)
 	}
 	else {
 		/* lock all sub-subtrees children */
-		int child;
+		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
 		{
 			lock_all_subtree(&handle->children[child]);
@@ -70,10 +70,13 @@ static void unlock_all_subtree(starpu_data_handle handle)
 		starpu_spin_unlock(&handle->header_lock);
 	}
 	else {
-		/* lock all sub-subtrees children */
-		int child;
-		for (child = handle->nchildren - 1; child >= 0; child--)
+		/* lock all sub-subtrees children 
+		 * Note that this is done in the reverse order of the
+		 * lock_all_subtree so that we avoid deadlock */
+		unsigned i;
+		for (i =0; i < handle->nchildren; i++)
 		{
+			unsigned child = handle->nchildren - 1 - i;
 			unlock_all_subtree(&handle->children[child]);
 		}
 	}
@@ -90,7 +93,7 @@ static unsigned may_free_subtree(starpu_data_handle handle, unsigned node)
 		return 1;
 	
 	/* look into all sub-subtrees children */
-	int child;
+	unsigned child;
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		unsigned res;
@@ -176,7 +179,7 @@ static void transfer_subtree_to_node(starpu_data_handle handle, unsigned src_nod
 	}
 	else {
 		/* lock all sub-subtrees children */
-		int child;
+		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
 		{
 			transfer_subtree_to_node(&handle->children[child],

+ 1 - 1
src/datawizard/write_back.c

@@ -69,7 +69,7 @@ void starpu_data_set_wb_mask(starpu_data_handle handle, uint32_t wb_mask)
 	/* in case the data has some children, set their wb_mask as well */
 	if (handle->nchildren > 0) 
 	{
-		int child;
+		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
 			starpu_data_set_wb_mask(&handle->children[child], wb_mask);
 	}

+ 6 - 5
src/drivers/core/driver_core.c

@@ -28,11 +28,12 @@ static int execute_job_on_core(job_t j, struct worker_s *core_args)
 
 	unsigned calibrate_model = 0;
 	struct starpu_task *task = j->task;
+	struct starpu_codelet_t *cl = task->cl;
 
-	STARPU_ASSERT(task->cl);
-	STARPU_ASSERT(task->cl->core_func);
+	STARPU_ASSERT(cl);
+	STARPU_ASSERT(cl->core_func);
 
-	if (task->cl->model && task->cl->model->benchmarking)
+	if (cl->model && cl->model->benchmarking)
 		calibrate_model = 1;
 
 	if (calibrate_model || BENCHMARK_COMM)
@@ -55,10 +56,10 @@ static int execute_job_on_core(job_t j, struct worker_s *core_args)
 		GET_TICK(codelet_start);
 
 	core_args->status = STATUS_EXECUTING;
-	cl_func func = task->cl->core_func;
+	cl_func func = cl->core_func;
 	func(task->interface, task->cl_arg);
 
-	task->cl->per_worker_stats[core_args->workerid]++;
+	cl->per_worker_stats[core_args->workerid]++;
 	
 	if (calibrate_model || BENCHMARK_COMM)
 		GET_TICK(codelet_end);

+ 4 - 4
src/util/execute_on_all.c

@@ -17,14 +17,14 @@
 #include <starpu.h>
 #include <common/config.h>
 
-typedef struct wrapper_func_args {
+struct wrapper_func_args {
 	void (*func)(void *);
 	void *arg;
-} _wrapper_func_args;
+};
 
 static void wrapper_func(void *buffers[] __attribute__ ((unused)), void *_args)
 {
-	_wrapper_func_args *args = _args;
+	struct wrapper_func_args *args = _args;
 	args->func(args->arg);
 }
 
@@ -46,7 +46,7 @@ void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t whe
 
 	struct starpu_task *tasks[STARPU_NMAXWORKERS];
 
-	_wrapper_func_args args = {
+	struct wrapper_func_args args = {
 		.func = func,
 		.arg = arg
 	};