ソースを参照

memalloc: Also make starpu_data_can_evict check for the may_free_subtree tests

Samuel Thibault 4 年 前
コミット
eedef9cde1
共有1 個のファイルを変更した14 個の追加1 個の削除を含む
  1. 14 1
      src/datawizard/memalloc.c

+ 14 - 1
src/datawizard/memalloc.c

@@ -265,7 +265,7 @@ static int lock_all_subtree(starpu_data_handle_t handle)
 	return 1;
 }
 
-static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
+static unsigned may_free_handle(starpu_data_handle_t handle, unsigned node)
 {
 	/* we only free if no one refers to the leaf */
 	uint32_t refcnt = _starpu_get_data_refcnt(handle, node);
@@ -284,6 +284,15 @@ static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
 				return 0;
 	}
 
+	/* no problem was found */
+	return 1;
+}
+
+static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
+{
+	if (!may_free_handle(handle, node))
+		return 0;
+
 	/* look into all sub-subtrees children */
 	unsigned child;
 	for (child = 0; child < handle->nchildren; child++)
@@ -560,6 +569,10 @@ int starpu_data_can_evict(starpu_data_handle_t handle, unsigned node, enum starp
 		/* We have not finished executing the tasks this was prefetched for */
 		return 0;
 
+	if (!may_free_handle(handle, node))
+		/* Somebody refers to it */
+		return 0;
+
 	return 1;
 }