Bladeren bron

src/datawizard: update children storage in starpu_data_handle_t

update struct _starpu_data_state to have
       starpu_data_handle_t *children;
instead of
	struct _starpu_data_state *children;

The function

    starpu_data_handle_t _starpu_data_handle_allocate(struct starpu_data_interface_ops *interface_ops)

is made available to other units. So that it can be used to create
children when partitionning a data. It ensures children are properly
initialised (the initialisation of the memory statistics was not
done before this update)
Nathalie Furmento 12 jaren geleden
bovenliggende
commit
d0213f8b01

+ 1 - 1
src/datawizard/coherency.h

@@ -126,7 +126,7 @@ struct _starpu_data_state
 	unsigned sibling_index; /* indicate which child this node is from the father's perpsective (if any) */
 	unsigned depth; /* what's the depth of the tree ? */
 
-	struct _starpu_data_state *children;
+	starpu_data_handle_t *children;
 	unsigned nchildren;
 
 	/* describe the state of the data in term of coherency */

+ 12 - 12
src/datawizard/filters.c

@@ -19,6 +19,7 @@
 
 #include <datawizard/filters.h>
 #include <datawizard/footprint.h>
+#include <datawizard/interfaces/data_interface.h>
 
 static void starpu_data_create_children(starpu_data_handle_t handle, unsigned nchildren, struct starpu_data_filter *f);
 
@@ -39,7 +40,7 @@ static void map_filter(starpu_data_handle_t root_handle, struct starpu_data_filt
 		unsigned child;
 		for (child = 0; child < root_handle->nchildren; child++)
 		{
-			map_filter(&root_handle->children[child], f);
+			map_filter(root_handle->children[child], f);
 		}
 	}
 }
@@ -74,7 +75,7 @@ starpu_data_handle_t starpu_data_get_child(starpu_data_handle_t handle, unsigned
 {
 	STARPU_ASSERT(i < handle->nchildren);
 
-	return &handle->children[i];
+	return handle->children[i];
 }
 
 /*
@@ -104,7 +105,7 @@ starpu_data_handle_t starpu_data_vget_sub_data(starpu_data_handle_t root_handle,
 
 		STARPU_ASSERT(next_child < current_handle->nchildren);
 
-		current_handle = &current_handle->children[next_child];
+		current_handle = current_handle->children[next_child];
 	}
 
 	return current_handle;
@@ -277,7 +278,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 	/* first take all the children lock (in order !) */
 	for (child = 0; child < root_handle->nchildren; child++)
 	{
-		struct _starpu_data_state *child_handle = &root_handle->children[child];
+		starpu_data_handle_t child_handle = root_handle->children[child];
 
 		/* make sure the intermediate children is unpartitionned as well */
 		if (child_handle->nchildren > 0)
@@ -315,7 +316,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 
 		_starpu_spin_lock(&child_handle->header_lock);
 
-		_starpu_data_free_interfaces(&root_handle->children[child]);
+		_starpu_data_free_interfaces(root_handle->children[child]);
 		_starpu_data_requester_list_delete(child_handle->req_list);
 		_starpu_data_requester_list_delete(child_handle->reduction_req_list);
 	}
@@ -342,7 +343,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 
 		for (child = 0; child < root_handle->nchildren; child++)
 		{
-			struct _starpu_data_replicate *local = &root_handle->children[child].per_node[node];
+			struct _starpu_data_replicate *local = &root_handle->children[child]->per_node[node];
 
 			if (local->state == STARPU_INVALID)
 			{
@@ -352,7 +353,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 
 			if (local->allocated && local->automatically_allocated)
 				/* free the child data copy in a lazy fashion */
-				_starpu_request_mem_chunk_removal(&root_handle->children[child], node, 1);
+				_starpu_request_mem_chunk_removal(root_handle->children[child], node, 1);
 		}
 
 		if (!root_handle->per_node[node].allocated)
@@ -383,7 +384,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 
 	for (child = 0; child < root_handle->nchildren; child++)
 	{
-		struct _starpu_data_state *child_handle = &root_handle->children[child];
+		starpu_data_handle_t child_handle = root_handle->children[child];
 		_starpu_spin_unlock(&child_handle->header_lock);
 	}
 
@@ -399,7 +400,7 @@ void starpu_data_unpartition(starpu_data_handle_t root_handle, uint32_t gatherin
 /* each child may have his own interface type */
 static void starpu_data_create_children(starpu_data_handle_t handle, unsigned nchildren, struct starpu_data_filter *f)
 {
-	handle->children = (struct _starpu_data_state *) calloc(nchildren, sizeof(struct _starpu_data_state));
+	handle->children = (struct _starpu_data_state **) calloc(nchildren, sizeof(struct _starpu_data_state *));
 	STARPU_ASSERT(handle->children);
 
 	unsigned node;
@@ -410,8 +411,6 @@ static void starpu_data_create_children(starpu_data_handle_t handle, unsigned nc
 
 	for (child = 0; child < nchildren; child++)
 	{
-		starpu_data_handle_t handle_child = &handle->children[child];
-
 		struct starpu_data_interface_ops *ops;
 
 		/* what's this child's interface ? */
@@ -420,7 +419,7 @@ static void starpu_data_create_children(starpu_data_handle_t handle, unsigned nc
 		else
 		  ops = handle->ops;
 
-		handle_child->ops = ops;
+		starpu_data_handle_t handle_child = _starpu_data_handle_allocate(ops);
 
 		size_t interfacesize = ops->interface_size;
 
@@ -440,6 +439,7 @@ static void starpu_data_create_children(starpu_data_handle_t handle, unsigned nc
 		}
 
 		handle_child->mf_node = handle->mf_node;
+		handle->children[child] = handle_child;
 	}
 
 	/* this handle now has children */

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

@@ -228,7 +228,7 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 	}
 }
 
-static starpu_data_handle_t _starpu_data_handle_allocate(struct starpu_data_interface_ops *interface_ops)
+starpu_data_handle_t _starpu_data_handle_allocate(struct starpu_data_interface_ops *interface_ops)
 {
 	starpu_data_handle_t handle = (starpu_data_handle_t) calloc(1, sizeof(struct _starpu_data_state));
 

+ 4 - 1
src/datawizard/interfaces/data_interface.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2012  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -26,6 +26,9 @@ extern struct starpu_data_interface_ops _starpu_interface_matrix_ops;
 void _starpu_data_free_interfaces(starpu_data_handle_t handle)
 	STARPU_ATTRIBUTE_INTERNAL;
 
+extern
+starpu_data_handle_t _starpu_data_handle_allocate(struct starpu_data_interface_ops *interface_ops);
+
 extern void _starpu_data_interface_init(void) STARPU_ATTRIBUTE_INTERNAL;
 extern int _starpu_data_check_not_busy(starpu_data_handle_t handle) STARPU_ATTRIBUTE_INTERNAL;
 extern void _starpu_data_interface_shutdown(void) STARPU_ATTRIBUTE_INTERNAL;

+ 5 - 5
src/datawizard/memalloc.c

@@ -83,7 +83,7 @@ static void lock_all_subtree(starpu_data_handle_t handle)
 		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
 		{
-			lock_all_subtree(&handle->children[child]);
+			lock_all_subtree(handle->children[child]);
 		}
 	}
 }
@@ -104,7 +104,7 @@ static void unlock_all_subtree(starpu_data_handle_t handle)
 		for (i =0; i < handle->nchildren; i++)
 		{
 			unsigned child = handle->nchildren - 1 - i;
-			unlock_all_subtree(&handle->children[child]);
+			unlock_all_subtree(handle->children[child]);
 		}
 	}
 }
@@ -124,7 +124,7 @@ static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		unsigned res;
-		res = may_free_subtree(&handle->children[child], node);
+		res = may_free_subtree(handle->children[child], node);
 		if (!res) return 0;
 	}
 
@@ -208,8 +208,8 @@ static void transfer_subtree_to_node(starpu_data_handle_t handle, unsigned src_n
 		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
 		{
-			transfer_subtree_to_node(&handle->children[child],
-							src_node, dst_node);
+			transfer_subtree_to_node(handle->children[child],
+						 src_node, dst_node);
 		}
 	}
 }

+ 1 - 1
src/datawizard/reduction.c

@@ -34,7 +34,7 @@ void starpu_data_set_reduction_methods(starpu_data_handle_t handle,
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		/* make sure that the flags are applied to the children as well */
-		struct _starpu_data_state *child_handle = &handle->children[child];
+		starpu_data_handle_t child_handle = handle->children[child];
 		if (child_handle->nchildren > 0)
 			starpu_data_set_reduction_methods(child_handle, redux_cl, init_cl);
 	}

+ 2 - 2
src/datawizard/user_interactions.c

@@ -431,7 +431,7 @@ void starpu_data_advise_as_important(starpu_data_handle_t handle, unsigned is_im
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		/* make sure the intermediate children is advised as well */
-		struct _starpu_data_state *child_handle = &handle->children[child];
+		starpu_data_handle_t child_handle = handle->children[child];
 		if (child_handle->nchildren > 0)
 			starpu_data_advise_as_important(child_handle, is_important);
 	}
@@ -451,7 +451,7 @@ void starpu_data_set_sequential_consistency_flag(starpu_data_handle_t handle, un
 	for (child = 0; child < handle->nchildren; child++)
 	{
 		/* make sure that the flags are applied to the children as well */
-		struct _starpu_data_state *child_handle = &handle->children[child];
+		starpu_data_handle_t child_handle = handle->children[child];
 		if (child_handle->nchildren > 0)
 			starpu_data_set_sequential_consistency_flag(child_handle, flag);
 	}

+ 2 - 2
src/datawizard/write_back.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -78,6 +78,6 @@ void starpu_data_set_wt_mask(starpu_data_handle_t handle, uint32_t wt_mask)
 	{
 		unsigned child;
 		for (child = 0; child < handle->nchildren; child++)
-			starpu_data_set_wt_mask(&handle->children[child], wt_mask);
+			starpu_data_set_wt_mask(handle->children[child], wt_mask);
 	}
 }