|
@@ -522,7 +522,13 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
|
|
|
#endif
|
|
|
|
|
|
if (dst_replicate->mc)
|
|
|
+ {
|
|
|
+ if (is_prefetch == STARPU_TASK_PREFETCH)
|
|
|
+ /* Make sure it stays there */
|
|
|
+ dst_replicate->mc->nb_tasks_prefetch++;
|
|
|
+
|
|
|
_starpu_memchunk_recently_used(dst_replicate->mc, requesting_node);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
_starpu_spin_unlock(&handle->header_lock);
|
|
@@ -567,6 +573,9 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
|
|
|
if (_starpu_allocate_memory_on_node(handle, dst_replicate, is_prefetch) == 0)
|
|
|
{
|
|
|
_starpu_update_data_state(handle, dst_replicate, mode);
|
|
|
+ if (is_prefetch == STARPU_TASK_PREFETCH)
|
|
|
+ /* Make sure it stays there */
|
|
|
+ dst_replicate->mc->nb_tasks_prefetch++;
|
|
|
|
|
|
_starpu_spin_unlock(&handle->header_lock);
|
|
|
|
|
@@ -645,9 +654,17 @@ struct _starpu_data_request *_starpu_create_request_to_fetch_data(starpu_data_ha
|
|
|
STARPU_ASSERT(r->next_req_count <= STARPU_MAXNODES);
|
|
|
}
|
|
|
}
|
|
|
- else if (!write_invalidation)
|
|
|
- /* The last request will perform the callback after termination */
|
|
|
- _starpu_data_request_append_callback(r, callback_func, callback_arg);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (is_prefetch == STARPU_TASK_PREFETCH)
|
|
|
+ /* Make last request add the prefetch count on the mc to keep the data
|
|
|
+ * there until the task gets to execute. */
|
|
|
+ r->nb_tasks_prefetch++;
|
|
|
+
|
|
|
+ if (!write_invalidation)
|
|
|
+ /* The last request will perform the callback after termination */
|
|
|
+ _starpu_data_request_append_callback(r, callback_func, callback_arg);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (reused_requests[hop])
|
|
@@ -785,7 +802,12 @@ static int idle_prefetch_data_on_node(starpu_data_handle_t handle, int node, str
|
|
|
return _starpu_fetch_data_on_node(handle, node, replicate, mode, 1, STARPU_IDLEFETCH, 1, NULL, NULL, prio, "idle_prefetch_data_on_node");
|
|
|
}
|
|
|
|
|
|
-static int prefetch_data_on_node(starpu_data_handle_t handle, int node, struct _starpu_data_replicate *replicate, enum starpu_data_access_mode mode, int prio)
|
|
|
+static int task_prefetch_data_on_node(starpu_data_handle_t handle, int node, struct _starpu_data_replicate *replicate, enum starpu_data_access_mode mode, int prio)
|
|
|
+{
|
|
|
+ return _starpu_fetch_data_on_node(handle, node, replicate, mode, 1, STARPU_TASK_PREFETCH, 1, NULL, NULL, prio, "task_prefetch_data_on_node");
|
|
|
+}
|
|
|
+
|
|
|
+static int STARPU_ATTRIBUTE_UNUSED prefetch_data_on_node(starpu_data_handle_t handle, int node, struct _starpu_data_replicate *replicate, enum starpu_data_access_mode mode, int prio)
|
|
|
{
|
|
|
return _starpu_fetch_data_on_node(handle, node, replicate, mode, 1, STARPU_PREFETCH, 1, NULL, NULL, prio, "prefetch_data_on_node");
|
|
|
}
|
|
@@ -911,7 +933,7 @@ int starpu_prefetch_task_input_on_node_prio(struct starpu_task *task, unsigned t
|
|
|
int node = _starpu_task_data_get_node_on_node(task, index, target_node);
|
|
|
|
|
|
struct _starpu_data_replicate *replicate = &handle->per_node[node];
|
|
|
- prefetch_data_on_node(handle, node, replicate, mode, prio);
|
|
|
+ task_prefetch_data_on_node(handle, node, replicate, mode, prio);
|
|
|
|
|
|
_starpu_set_data_requested_flag_if_needed(handle, replicate);
|
|
|
}
|
|
@@ -988,7 +1010,7 @@ int starpu_prefetch_task_input_for_prio(struct starpu_task *task, unsigned worke
|
|
|
int node = _starpu_task_data_get_node_on_worker(task, index, worker);
|
|
|
|
|
|
struct _starpu_data_replicate *replicate = &handle->per_node[node];
|
|
|
- prefetch_data_on_node(handle, node, replicate, mode, prio);
|
|
|
+ task_prefetch_data_on_node(handle, node, replicate, mode, prio);
|
|
|
|
|
|
_starpu_set_data_requested_flag_if_needed(handle, replicate);
|
|
|
}
|
|
@@ -1223,7 +1245,17 @@ void _starpu_fetch_task_input_tail(struct starpu_task *task, struct _starpu_job
|
|
|
local_replicate = get_replicate(handle, mode, workerid, node);
|
|
|
_starpu_spin_lock(&handle->header_lock);
|
|
|
if (local_replicate->mc)
|
|
|
+ {
|
|
|
local_replicate->mc->diduse = 1;
|
|
|
+ if (task->prefetched)
|
|
|
+ {
|
|
|
+ /* Allocations or transfer prefetchs should have been done by now and marked
|
|
|
+ * this mc as needed for us.
|
|
|
+ * Now that we added a reference for the task, we can relieve that. */
|
|
|
+ STARPU_ASSERT(local_replicate->mc->nb_tasks_prefetch > 0);
|
|
|
+ local_replicate->mc->nb_tasks_prefetch--;
|
|
|
+ }
|
|
|
+ }
|
|
|
_starpu_spin_unlock(&handle->header_lock);
|
|
|
|
|
|
_STARPU_TASK_SET_INTERFACE(task , local_replicate->data_interface, descrs[index].index);
|