瀏覽代碼

- The data request structure does not contain handle + {src_node,dst_node}
anymore, instead we use the data replicate structure.
- The _starpu_create_data_request function now operates on data replicate
structures as well.

Cédric Augonnet 14 年之前
父節點
當前提交
c65bd29a96

+ 6 - 3
src/datawizard/coherency.c

@@ -197,7 +197,8 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 			starpu_data_request_t r_ram_to_dst;
 
 			/* XXX we hardcore 0 as the RAM node ... */
-			r_ram_to_dst = _starpu_create_data_request(handle, 0, requesting_node, requesting_node, mode, is_prefetch);
+			r_ram_to_dst = _starpu_create_data_request(handle, &handle->per_node[0],
+						&handle->per_node[requesting_node], requesting_node, mode, is_prefetch);
 
 			if (!is_prefetch)
 				r_ram_to_dst->refcnt++;
@@ -206,7 +207,8 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 			if (!r_src_to_ram)
 			{
 				reuse_r_src_to_ram = 0;
-				r_src_to_ram = _starpu_create_data_request(handle, src_node, 0, src_node, mode, is_prefetch);
+				r_src_to_ram = _starpu_create_data_request(handle, &handle->per_node[src_node],
+							&handle->per_node[0], src_node, mode, is_prefetch);
 			}
 			else {
 				reuse_r_src_to_ram = 1;
@@ -234,7 +236,8 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 			uint32_t handling_node =
 				_starpu_select_node_to_handle_request(src_node, requesting_node);
 
-			r = _starpu_create_data_request(handle, src_node, requesting_node, handling_node, mode, is_prefetch);
+			r = _starpu_create_data_request(handle, &handle->per_node[src_node],
+					&handle->per_node[requesting_node], handling_node, mode, is_prefetch);
 
 			_starpu_data_request_append_callback(r, callback_func, callback_arg);
 

+ 22 - 16
src/datawizard/data_request.c

@@ -61,21 +61,26 @@ void _starpu_deinit_data_request_lists(void)
 /* this should be called with the lock r->handle->header_lock taken */
 static void starpu_data_request_destroy(starpu_data_request_t r)
 {
-	r->handle->per_node[r->dst_node].request = NULL;
+	r->dst_replicate->request = NULL;
 
 	starpu_data_request_delete(r);
 }
 
 /* handle->lock should already be taken !  */
-starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, uint32_t handling_node, starpu_access_mode mode, unsigned is_prefetch)
+starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle,
+				struct starpu_data_replicate_s *src_replicate,
+				struct starpu_data_replicate_s *dst_replicate,
+				uint32_t handling_node,
+				starpu_access_mode mode,
+				unsigned is_prefetch)
 {
 	starpu_data_request_t r = starpu_data_request_new();
 
 	_starpu_spin_init(&r->lock);
 
 	r->handle = handle;
-	r->src_node = src_node;
-	r->dst_node = dst_node;
+	r->src_replicate = src_replicate;
+	r->dst_replicate = dst_replicate;
 	r->mode = mode;
 
 	r->handling_node = handling_node;
@@ -94,12 +99,12 @@ starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle, uin
 
 	_starpu_spin_lock(&r->lock);
 
-	handle->per_node[dst_node].request = r;
+	dst_replicate->request = r;
 
-	handle->per_node[dst_node].refcnt++;
+	dst_replicate->refcnt++;
 
 	if (mode & STARPU_R)
-		handle->per_node[src_node].refcnt++;
+		src_replicate->refcnt++;
 
 	r->refcnt = 1;
 
@@ -186,8 +191,8 @@ void _starpu_post_data_request(starpu_data_request_t r, uint32_t handling_node)
 
 	if (r->mode & STARPU_R)
 	{
-		STARPU_ASSERT(r->handle->per_node[r->src_node].allocated);
-		STARPU_ASSERT(r->handle->per_node[r->src_node].refcnt);
+		STARPU_ASSERT(r->src_replicate->allocated);
+		STARPU_ASSERT(r->src_replicate->refcnt);
 	}
 
 	/* insert the request in the proper list */
@@ -224,8 +229,8 @@ static void starpu_handle_data_request_completion(starpu_data_request_t r)
 	unsigned do_delete = 0;
 	starpu_data_handle handle = r->handle;
 
-	uint32_t src_node = r->src_node;
-	uint32_t dst_node = r->dst_node;
+	uint32_t src_node = r->src_replicate->memory_node;
+	uint32_t dst_node = r->dst_replicate->memory_node;
 
 	_starpu_update_data_state(handle, dst_node, r->mode);
 
@@ -242,10 +247,10 @@ static void starpu_handle_data_request_completion(starpu_data_request_t r)
 
 	r->completed = 1;
 	
-	handle->per_node[dst_node].refcnt--;
+	r->dst_replicate->refcnt--;
 
 	if (r->mode & STARPU_R)
-		handle->per_node[src_node].refcnt--;
+		r->src_replicate->refcnt--;
 
 	r->refcnt--;
 
@@ -288,13 +293,14 @@ static int starpu_handle_data_request(starpu_data_request_t r, unsigned may_allo
 
 	if (r->mode & STARPU_R)
 	{
-		STARPU_ASSERT(handle->per_node[r->src_node].allocated);
-		STARPU_ASSERT(handle->per_node[r->src_node].refcnt);
+		STARPU_ASSERT(r->src_replicate->allocated);
+		STARPU_ASSERT(r->src_replicate->refcnt);
 	}
 
 	/* perform the transfer */
 	/* the header of the data must be locked by the worker that submitted the request */
-	r->retval = _starpu_driver_copy_data_1_to_1(handle, r->src_node, r->dst_node, !(r->mode & STARPU_R), r, may_alloc);
+	r->retval = _starpu_driver_copy_data_1_to_1(handle, r->src_replicate->memory_node,
+			r->dst_replicate->memory_node, !(r->mode & STARPU_R), r, may_alloc);
 
 	if (r->retval == -ENOMEM)
 	{

+ 9 - 3
src/datawizard/data_request.h

@@ -36,8 +36,8 @@ LIST_TYPE(starpu_data_request,
 	unsigned refcnt;
 
 	starpu_data_handle handle;
-	uint32_t src_node;
-	uint32_t dst_node;
+	struct starpu_data_replicate_s *src_replicate;
+	struct starpu_data_replicate_s *dst_replicate;
 
 	uint32_t handling_node;
 
@@ -92,7 +92,13 @@ void _starpu_handle_all_pending_node_data_requests(uint32_t src_node);
 
 int _starpu_check_that_no_data_request_exists(uint32_t node);
 
-starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, uint32_t handling_node, starpu_access_mode mode, unsigned is_prefetch);
+starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle,
+				struct starpu_data_replicate_s *src_replicate,
+				struct starpu_data_replicate_s *dst_replicate,
+				uint32_t handling_node,
+				starpu_access_mode mode,
+				unsigned is_prefetch);
+
 starpu_data_request_t _starpu_search_existing_data_request(struct starpu_data_replicate_s *replicate, starpu_access_mode mode);
 int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_alloc);
 

+ 1 - 1
src/datawizard/user_interactions.c

@@ -30,7 +30,7 @@ int starpu_data_request_allocation(starpu_data_handle handle, uint32_t node)
 
 	STARPU_ASSERT(handle);
 
-	r = _starpu_create_data_request(handle, 0, node, node, 0, 1);
+	r = _starpu_create_data_request(handle, NULL, &handle->per_node[node], node, 0, 1);
 
 	/* we do not increase the refcnt associated to the request since we are
 	 * not waiting for its termination */

+ 2 - 2
src/datawizard/write_back.c

@@ -45,8 +45,8 @@ void _starpu_write_through_data(starpu_data_handle handle, uint32_t requesting_n
 				r = _starpu_search_existing_data_request(&handle->per_node[node], STARPU_R);
 				if (!r) {
 					/* there was no existing request so we create one now */
-					r = _starpu_create_data_request(handle, requesting_node,
-							node, handling_node, STARPU_R, 1);
+					r = _starpu_create_data_request(handle, &handle->per_node[requesting_node],
+							&handle->per_node[node], handling_node, STARPU_R, 1);
 					_starpu_post_data_request(r, handling_node);
 				}
 				else {