Browse Source

Fix the write-through mechanism by making it synchronous. This is not the best
solution in terms of performance, but at least this should be working as
expected. A way to make it asynchronous again is to block the rw-lock
protecting the handle until all async transfers are done.

Cédric Augonnet 14 years ago
parent
commit
3e719c4c87
1 changed files with 13 additions and 7 deletions
  1. 13 7
      src/datawizard/write_back.c

+ 13 - 7
src/datawizard/write_back.c

@@ -26,9 +26,6 @@ void _starpu_write_through_data(starpu_data_handle handle, uint32_t requesting_n
 		return;
 	}
 
-	while (_starpu_spin_trylock(&handle->header_lock))
-		_starpu_datawizard_progress(requesting_node, 1);
-
 	/* first commit all changes onto the nodes specified by the mask */
 	uint32_t node;
 	for (node = 0; node < STARPU_MAXNODES; node++)
@@ -37,13 +34,22 @@ void _starpu_write_through_data(starpu_data_handle handle, uint32_t requesting_n
 			/* we need to commit the buffer on that node */
 			if (node != requesting_node) 
 			{
-				create_request_to_fetch_data(handle, &handle->per_node[node],
-								STARPU_R, 1, NULL, NULL);
+				while (_starpu_spin_trylock(&handle->header_lock))
+					_starpu_datawizard_progress(requesting_node, 1);
+
+				starpu_data_request_t r;
+				r = create_request_to_fetch_data(handle, &handle->per_node[node],
+								STARPU_R, 0, NULL, NULL);
+
+			        _starpu_spin_unlock(&handle->header_lock);
+
+			        /* If no request was created, the handle was already up-to-date on the
+			         * node */
+			        if (r)
+        				_starpu_wait_data_request_completion(r, 1);
 			}
 		}
 	}
-
-	_starpu_spin_unlock(&handle->header_lock);
 }
 
 void starpu_data_set_wt_mask(starpu_data_handle handle, uint32_t wt_mask)