Parcourir la source

src/datawizard/interfaces/data_interface.c: modify _starpu_data_unregister() to not fetch the data if there
is no valid copy of the data. This can happen when a data is invalidated (in mpi, the data which was needed
for a local computation is sent back to its owner) and then unregistered.

Nathalie Furmento il y a 11 ans
Parent
commit
f08f953c72
1 fichiers modifiés avec 31 ajouts et 6 suppressions
  1. 31 6
      src/datawizard/interfaces/data_interface.c

+ 31 - 6
src/datawizard/interfaces/data_interface.c

@@ -557,9 +557,37 @@ int _starpu_data_check_not_busy(starpu_data_handle_t handle)
 	return 0;
 }
 
+static
+void _starpu_check_if_valid_and_fetch_data_on_node(starpu_data_handle_t handle, struct _starpu_data_replicate *replicate)
+{
+	unsigned node;
+	unsigned nnodes = starpu_memory_nodes_get_count();
+	int valid = 0;
+
+	for (node = 0; node < nnodes; node++)
+	{
+		if (handle->per_node[node].state != STARPU_INVALID)
+		{
+			/* we found a copy ! */
+			valid = 1;
+		}
+	}
+	if (valid)
+	{
+		int ret = _starpu_fetch_data_on_node(handle, replicate, STARPU_R, 0, 0, NULL, NULL);
+		STARPU_ASSERT(!ret);
+		_starpu_release_data_on_node(handle, 0, &handle->per_node[handle->home_node]);
+	}
+	else
+	{
+		_starpu_spin_lock(&handle->header_lock);
+		if (!_starpu_notify_data_dependencies(handle))
+			_starpu_spin_unlock(&handle->header_lock);
+	}
+}
+
 static void _starpu_data_unregister_fetch_data_callback(void *_arg)
 {
-	int ret;
 	struct _starpu_unregister_callback_arg *arg = (struct _starpu_unregister_callback_arg *) _arg;
 
 	starpu_data_handle_t handle = arg->handle;
@@ -568,8 +596,7 @@ static void _starpu_data_unregister_fetch_data_callback(void *_arg)
 
 	struct _starpu_data_replicate *replicate = &handle->per_node[arg->memory_node];
 
-	ret = _starpu_fetch_data_on_node(handle, replicate, STARPU_R, 0, 0, NULL, NULL);
-	STARPU_ASSERT(!ret);
+	_starpu_check_if_valid_and_fetch_data_on_node(handle, replicate);
 
 	/* unlock the caller */
 	STARPU_PTHREAD_MUTEX_LOCK(&arg->mutex);
@@ -618,8 +645,7 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 			{
 				/* no one has locked this data yet, so we proceed immediately */
 				struct _starpu_data_replicate *home_replicate = &handle->per_node[home_node];
-				int ret = _starpu_fetch_data_on_node(handle, home_replicate, STARPU_R, 0, 0, NULL, NULL);
-				STARPU_ASSERT(!ret);
+				_starpu_check_if_valid_and_fetch_data_on_node(handle, home_replicate);
 			}
 			else
 			{
@@ -630,7 +656,6 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 			}
 			STARPU_PTHREAD_MUTEX_DESTROY(&arg.mutex);
 			STARPU_PTHREAD_COND_DESTROY(&arg.cond);
-			_starpu_release_data_on_node(handle, 0, &handle->per_node[home_node]);
 		}
 
 		/* If this handle uses a multiformat interface, we may have to convert