瀏覽代碼

Move nb_tasks_prefetch to the replicate

This will be simpler to access for chunk replacement policies
Samuel Thibault 4 年之前
父節點
當前提交
4c74a80013

+ 4 - 4
src/datawizard/coherency.c

@@ -527,7 +527,7 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
 			{
 				if (is_prefetch == STARPU_TASK_PREFETCH)
 					/* Make sure it stays there */
-					dst_replicate->mc->nb_tasks_prefetch++;
+					dst_replicate->nb_tasks_prefetch++;
 
 				_starpu_memchunk_recently_used(dst_replicate->mc, requesting_node);
 			}
@@ -579,7 +579,7 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
 				{
 					if (is_prefetch == STARPU_TASK_PREFETCH)
 						/* Make sure it stays there */
-						dst_replicate->mc->nb_tasks_prefetch++;
+						dst_replicate->nb_tasks_prefetch++;
 
 					_starpu_memchunk_recently_used(dst_replicate->mc, requesting_node);
 				}
@@ -1220,8 +1220,8 @@ void _starpu_fetch_task_input_tail(struct starpu_task *task, struct _starpu_job
 				 * Now that we added a reference for the task, we can relieve that.  */
 				/* Note: the replicate might have been evicted in between, thus not 100% sure
 				 * that our prefetch request is still recorded here.  */
-				if (local_replicate->mc->nb_tasks_prefetch > 0)
-					local_replicate->mc->nb_tasks_prefetch--;
+				if (local_replicate->nb_tasks_prefetch > 0)
+					local_replicate->nb_tasks_prefetch--;
 			}
 		}
 		_starpu_spin_unlock(&handle->header_lock);

+ 6 - 0
src/datawizard/coherency.h

@@ -82,6 +82,12 @@ struct _starpu_data_replicate
 	uint32_t requested;
 	struct _starpu_data_request *request[STARPU_MAXNODES];
 
+	/** The number of prefetches that we made for this replicate for various tasks
+	 * This is also the number of tasks that we will wait to see use the mc before
+	 * we attempt to evict it.
+	 */
+	unsigned nb_tasks_prefetch;
+
         /** Pointer to memchunk for LRU strategy */
 	struct _starpu_mem_chunk * mc;
 };

+ 1 - 1
src/datawizard/data_request.c

@@ -416,7 +416,7 @@ static void starpu_handle_data_request_completion(struct _starpu_data_request *r
 	{
 		if (dst_replicate->mc)
 			/* Make sure it stays there for the task.  */
-			dst_replicate->mc->nb_tasks_prefetch += r->nb_tasks_prefetch;
+			dst_replicate->nb_tasks_prefetch += r->nb_tasks_prefetch;
 
 		STARPU_ASSERT(dst_replicate->refcnt > 0);
 		dst_replicate->refcnt--;

+ 1 - 0
src/datawizard/filters.c

@@ -295,6 +295,7 @@ static void _starpu_data_partition(starpu_data_handle_t initial_handle, starpu_d
 			{
 				//child_replicate->initialized = 0;
 			}
+			//child_replicate->nb_tasks_prefetch = 0;
 
 			/* update the interface */
 			void *initial_interface = starpu_data_get_interface_on_node(initial_handle, node);

+ 12 - 10
src/datawizard/interfaces/data_interface.c

@@ -320,6 +320,7 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 		replicate->memory_node = node;
 		//replicate->relaxed_coherency = 0;
 		//replicate->refcnt = 0;
+		//replicate->nb_tasks_prefetch = 0;
 
 		if ((int) node == home_node)
 		{
@@ -367,23 +368,24 @@ _starpu_data_initialize_per_worker(starpu_data_handle_t handle)
 	for (worker = 0; worker < nworkers; worker++)
 	{
 		struct _starpu_data_replicate *replicate;
-		unsigned node;
+		//unsigned node;
 		replicate = &handle->per_worker[worker];
-		replicate->allocated = 0;
-		replicate->automatically_allocated = 0;
+		//replicate->allocated = 0;
+		//replicate->automatically_allocated = 0;
 		replicate->state = STARPU_INVALID;
-		replicate->refcnt = 0;
+		//replicate->refcnt = 0;
 		replicate->handle = handle;
-		replicate->requested = 0;
+		//replicate->requested = 0;
+		//replicate->nb_tasks_prefetch = 0;
 
-		for (node = 0; node < STARPU_MAXNODES; node++)
-		{
-			replicate->request[node] = NULL;
-		}
+		//for (node = 0; node < STARPU_MAXNODES; node++)
+		//{
+		//	replicate->request[node] = NULL;
+		//}
 
 		/* Assuming being used for SCRATCH for now, patched when entering REDUX mode */
 		replicate->relaxed_coherency = 1;
-		replicate->initialized = 0;
+		//replicate->initialized = 0;
 		replicate->memory_node = starpu_worker_get_memory_node(worker);
 
 		_STARPU_CALLOC(replicate->data_interface, 1, interfacesize);

+ 2 - 3
src/datawizard/memalloc.c

@@ -581,7 +581,7 @@ static size_t try_to_throw_mem_chunk(struct _starpu_mem_chunk *mc, unsigned node
 		/* Hasn't been used yet, avoid evicting it */
 		return 0;
 
-	if (mc->nb_tasks_prefetch && is_prefetch >= STARPU_TASK_PREFETCH)
+	if (is_prefetch >= STARPU_TASK_PREFETCH && handle->per_node[node].nb_tasks_prefetch)
 		/* We have not finished executing the tasks this was prefetched for */
 		return 0;
 
@@ -888,7 +888,7 @@ restart:
 		if (!mc->wontuse && is_prefetch >= STARPU_PREFETCH)
 			/* Do not evict something that we might reuse, just for a prefetch */
 			continue;
-		if (mc->nb_tasks_prefetch && is_prefetch >= STARPU_TASK_PREFETCH)
+		if (is_prefetch >= STARPU_TASK_PREFETCH && mc->data->per_node[node].nb_tasks_prefetch)
 			/* Do not evict something that we will reuse, just for a task prefetch */
 			continue;
 		if (mc->footprint != footprint || _starpu_data_interface_compare(handle->per_node[node].data_interface, handle->ops, mc->data->per_node[node].data_interface, mc->ops) != 1)
@@ -1331,7 +1331,6 @@ static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_repli
 	mc->size_interface = interface_size;
 	mc->remove_notify = NULL;
 	mc->diduse = 0;
-	mc->nb_tasks_prefetch = 0;
 	mc->wontuse = 0;
 
 	return mc;

+ 0 - 6
src/datawizard/memalloc.h

@@ -65,12 +65,6 @@ LIST_TYPE(_starpu_mem_chunk,
 	/** Was this chunk marked as "won't use"? */
 	unsigned wontuse:1;
 
-	/** The number of prefetches that we made for this mc for various tasks
-	 * This is also the number of tasks that we will wait to see use this mc before
-	 * we attempt to evict it.
-	 */
-	unsigned nb_tasks_prefetch;
-
 	/** the size of the data is only set when calling _starpu_request_mem_chunk_removal(),
 	 * it is needed to estimate how much memory is in mc_cache, and by
 	 * free_memory_on_node() which is called when the handle is no longer