Browse Source

coherency: Do not collapse requests for different tasks

When we have a long list of data prefetches for various tasks, we might
not actually be able to reuse data, and thus the prefetch for the later
task will have been lost in collapsing. Also, priorities might be
different, so we'd rather let request lists keep all requests, and at
worse cancel redundant requests.
Samuel Thibault 4 years ago
parent
commit
485e996fdd
1 changed files with 11 additions and 6 deletions
  1. 11 6
      src/datawizard/coherency.c

+ 11 - 6
src/datawizard/coherency.c

@@ -405,16 +405,18 @@ int _starpu_determine_request_path(starpu_data_handle_t handle,
 /* handle->lock should be taken. r is returned locked. The node parameter
  * indicate either the source of the request, or the destination for a
  * write-only request. */
-static struct _starpu_data_request *_starpu_search_existing_data_request(struct _starpu_data_replicate *replicate, unsigned node, enum starpu_data_access_mode mode, enum starpu_is_prefetch is_prefetch)
+static struct _starpu_data_request *_starpu_search_existing_data_request(struct _starpu_data_replicate *replicate, unsigned node, enum starpu_data_access_mode mode, struct starpu_task *task, enum starpu_is_prefetch is_prefetch)
 {
 	struct _starpu_data_request *r;
 
-	r = replicate->request[node];
-
-	if (r)
+	for (r = replicate->request[node]; r; r = r->next_same_req)
 	{
 		_starpu_spin_checklocked(&r->handle->header_lock);
 
+		if (task && r->task && task != r->task)
+			/* Do not collapse requests for different tasks */
+			continue;
+
 		_starpu_spin_lock(&r->lock);
 
                 /* perhaps we need to "upgrade" the request */
@@ -439,9 +441,12 @@ static struct _starpu_data_request *_starpu_search_existing_data_request(struct
 
 		if (mode & STARPU_W)
 			r->mode = (enum starpu_data_access_mode) ((int) r->mode | (int)  STARPU_W);
+
+		/* We collapse with this request */
+		return r;
 	}
 
-	return r;
+	return NULL;
 }
 
 
@@ -658,7 +663,7 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
 #endif
 		r = _starpu_search_existing_data_request(hop_dst_replicate,
 				(mode & STARPU_R)?hop_src_node:hop_dst_node,
-							 mode, is_prefetch);
+							 mode, task, is_prefetch);
 
 		reused_requests[hop] = !!r;