瀏覽代碼

Add missing partitioning optimization: we don't need to unpartition when accessing read-only and the ancestor is already partitioned read-only

Samuel Thibault 7 年之前
父節點
當前提交
b2975770e2
共有 1 個文件被更改,包括 20 次插入9 次删除
  1. 20 9
      src/datawizard/filters.c

+ 20 - 9
src/datawizard/filters.c

@@ -880,7 +880,7 @@ static void _starpu_data_partition_access_look_up(starpu_data_handle_t ancestor,
 	/* Then unpartition ancestor if needed */
 	if (ancestor->partitioned &&
 			/* Not the right children, unpartition ourself */
-			((target && ancestor->active_children != target->siblings) ||
+			((target && write && ancestor->active_children != target->siblings) ||
 			/* We are partitioned and we want to write or some child
 			 * is writing and we want to read, unpartition ourself*/
 			(!target && (write || !ancestor->readonly))))
@@ -898,16 +898,27 @@ static void _starpu_data_partition_access_look_up(starpu_data_handle_t ancestor,
 		return;
 	}
 
-	/* Then partition ancestor towards target */
+	/* Then partition ancestor towards target, if needed */
 	if (ancestor->partitioned)
 	{
-		_STARPU_DEBUG("ancestor %p is already partitioned RO, turn RW\n", ancestor);
-		/* Already partitioned, normally it's already for the target */
-		STARPU_ASSERT(ancestor->active_children == target->siblings);
-		/* And we are here just because we haven't partitioned rw */
-		STARPU_ASSERT(ancestor->readonly && write);
-		/* So we just need to upgrade ro to rw */
-		starpu_data_partition_readwrite_upgrade_submit(ancestor, target->nsiblings, target->siblings);
+		/* That must be readonly, otherwise we would have unpartitioned it */
+		STARPU_ASSERT(ancestor->readonly);
+		if (write)
+		{
+			_STARPU_DEBUG("ancestor %p is already partitioned RO, turn RW\n", ancestor);
+			/* Already partitioned, normally it's already for the target */
+			STARPU_ASSERT(ancestor->active_children == target->siblings);
+			/* And we are here just because we haven't partitioned rw */
+			STARPU_ASSERT(ancestor->readonly && write);
+			/* So we just need to upgrade ro to rw */
+			starpu_data_partition_readwrite_upgrade_submit(ancestor, target->nsiblings, target->siblings);
+		}
+		else
+		{
+			_STARPU_DEBUG("ancestor %p is already partitioned RO, but not to target, partition towards target\n", ancestor);
+			/* So we just need to upgrade ro to rw */
+			starpu_data_partition_readonly_submit(ancestor, target->nsiblings, target->siblings);
+		}
 	}
 	else
 	{