Browse Source

When evicting a partitioned data, notify children of the deallocation

Samuel Thibault 12 years ago
parent
commit
64a94f053d
1 changed files with 18 additions and 6 deletions
  1. 18 6
      src/datawizard/memalloc.c

+ 18 - 6
src/datawizard/memalloc.c

@@ -210,6 +210,23 @@ static void transfer_subtree_to_node(starpu_data_handle_t handle, unsigned src_n
 	}
 }
 
+static void notify_handle_children(starpu_data_handle_t handle, struct _starpu_data_replicate *replicate, unsigned node)
+{
+	unsigned child;
+
+	replicate->allocated = 0;
+
+	/* XXX why do we need that ? */
+	replicate->automatically_allocated = 0;
+
+	for (child = 0; child < handle->nchildren; child++)
+	{
+		/* Notify children that their buffer has been deallocated too */
+		starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
+		notify_handle_children(child_handle, &child_handle->per_node[node], node);
+	}
+}
+
 static size_t free_memory_on_node(struct _starpu_mem_chunk *mc, unsigned node)
 {
 	size_t freed = 0;
@@ -244,12 +261,7 @@ static size_t free_memory_on_node(struct _starpu_mem_chunk *mc, unsigned node)
 		mc->ops->free_data_on_node(mc->chunk_interface, node);
 
 		if (handle)
-		{
-			replicate->allocated = 0;
-
-			/* XXX why do we need that ? */
-			replicate->automatically_allocated = 0;
-		}
+			notify_handle_children(handle, replicate, node);
 
 		freed = mc->size;