Browse Source

Minor code cleanups

Cédric Augonnet 14 years ago
parent
commit
ddb5759a50

+ 8 - 7
src/datawizard/coherency.c

@@ -89,12 +89,13 @@ uint32_t _starpu_select_src_node(starpu_data_handle handle)
 }
 
 /* this may be called once the data is fetched with header and STARPU_RW-lock hold */
-void _starpu_update_data_state(starpu_data_handle handle, uint32_t requesting_node, starpu_access_mode mode)
+void _starpu_update_data_state(starpu_data_handle handle,
+				struct starpu_data_replicate_s *requesting_replicate,
+				starpu_access_mode mode)
 {
 	unsigned nnodes = _starpu_get_memory_nodes_count();
 
 	/* the data is present now */
-	struct starpu_data_replicate_s *requesting_replicate = &handle->per_node[requesting_node];
 	requesting_replicate->requested = 0;
 
 	if (mode & STARPU_W) {
@@ -160,7 +161,7 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 	if (dst_replicate->state != STARPU_INVALID)
 	{
 		/* the data is already available so we can stop */
-		_starpu_update_data_state(handle, requesting_node, mode);
+		_starpu_update_data_state(handle, dst_replicate, mode);
 		_starpu_msi_cache_hit(requesting_node);
 		_starpu_spin_unlock(&handle->header_lock);
 
@@ -214,15 +215,14 @@ int _starpu_fetch_data_on_node(starpu_data_handle handle, uint32_t requesting_no
 				r_ram_to_dst->refcnt++;
 
 			r_src_to_ram = _starpu_search_existing_data_request(ram_replicate, mode);
+
+			reuse_r_src_to_ram = r_src_to_ram?1:0;
+
 			if (!r_src_to_ram)
 			{
-				reuse_r_src_to_ram = 0;
 				r_src_to_ram = _starpu_create_data_request(handle, src_replicate,
 							ram_replicate, src_node, mode, is_prefetch);
 			}
-			else {
-				reuse_r_src_to_ram = 1;
-			}
 
 			/* we chain both requests */
 			r_src_to_ram->next_req[r_src_to_ram->next_req_count++]= r_ram_to_dst;
@@ -430,6 +430,7 @@ int _starpu_fetch_task_input(struct starpu_task *task, uint32_t mask)
 				_starpu_allocate_interface(handle, src_interface, local_memory_node);
 
 				size_t size = _starpu_data_get_size(handle);
+#warning TODO create a replicate struct here:
 				mc = _starpu_memchunk_init(handle, size, src_interface, interface_size, 1);
 			}
 

+ 3 - 1
src/datawizard/coherency.h

@@ -158,7 +158,9 @@ int _starpu_fetch_data_on_node(struct starpu_data_state_t *state, uint32_t reque
 				void (*callback_func)(void *), void *callback_arg);
 void _starpu_release_data_on_node(struct starpu_data_state_t *state, uint32_t default_wt_mask, unsigned memory_node);
 
-void _starpu_update_data_state(struct starpu_data_state_t *state, uint32_t requesting_node, starpu_access_mode mode);
+void _starpu_update_data_state(starpu_data_handle handle,
+				struct starpu_data_replicate_s *requesting_replicate,
+				starpu_access_mode mode);
 
 uint32_t _starpu_get_data_refcnt(struct starpu_data_state_t *state, uint32_t node);
 

+ 4 - 4
src/datawizard/data_request.c

@@ -229,12 +229,11 @@ 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_replicate->memory_node;
-	uint32_t dst_node = r->dst_replicate->memory_node;
-
-	_starpu_update_data_state(handle, dst_node, r->mode);
+	_starpu_update_data_state(handle, r->dst_replicate, r->mode);
 
 #ifdef STARPU_USE_FXT
+	uint32_t src_node = r->src_replicate->memory_node;
+	uint32_t dst_node = r->dst_replicate->memory_node;
 	size_t size = _starpu_data_get_size(handle);
 	STARPU_TRACE_END_DRIVER_COPY(src_node, dst_node, size, r->com_id);
 #endif
@@ -293,6 +292,7 @@ static int starpu_handle_data_request(starpu_data_request_t r, unsigned may_allo
 
 	if (r->mode & STARPU_R)
 	{
+		STARPU_ASSERT(r->src_replicate);
 		STARPU_ASSERT(r->src_replicate->allocated);
 		STARPU_ASSERT(r->src_replicate->refcnt);
 	}

+ 7 - 5
src/datawizard/memalloc.c

@@ -243,14 +243,16 @@ static void reuse_mem_chunk(unsigned node, starpu_data_handle new_data, starpu_m
 
 	if (!mc->data_was_deleted)
 	{
-		old_data->per_node[node].allocated = 0;
-		old_data->per_node[node].automatically_allocated = 0;
+		struct starpu_data_replicate_s *old_replicate = &old_data->per_node[node];
+		old_replicate->allocated = 0;
+		old_replicate->automatically_allocated = 0;
 	}
 
-	new_data->per_node[node].allocated = 1;
-	new_data->per_node[node].automatically_allocated = 1;
+	struct starpu_data_replicate_s *new_replicate = &new_data->per_node[node];
+	new_replicate->allocated = 1;
+	new_replicate->automatically_allocated = 1;
 
-	memcpy(new_data->per_node[node].interface, mc->interface, old_data->ops->interface_size);
+	memcpy(new_replicate->interface, mc->interface, old_data->ops->interface_size);
 
 	mc->data = new_data;
 	mc->data_was_deleted = 0;