Преглед изворни кода

Don't stay stuck for too long pushing requests to GPUs

Samuel Thibault пре 8 година
родитељ
комит
d6d6378102
2 измењених фајлова са 9 додато и 0 уклоњено
  1. 8 0
      src/datawizard/data_request.c
  2. 1 0
      src/datawizard/datawizard.c

+ 8 - 0
src/datawizard/data_request.c

@@ -31,6 +31,7 @@
 #define MAX_PENDING_REQUESTS_PER_NODE 20
 #define MAX_PENDING_PREFETCH_REQUESTS_PER_NODE 10
 #define MAX_PENDING_IDLE_REQUESTS_PER_NODE 1
+#define MAX_PUSH_TIME 1000 /* Maximum time in us that we can afford pushing requests before going back to the driver loop, e.g. for checking GPU task termination */
 
 /* requests that have not been treated at all */
 static struct _starpu_data_request_prio_list data_requests[STARPU_MAXNODES];
@@ -584,6 +585,7 @@ static int __starpu_handle_node_data_requests(struct _starpu_data_request_prio_l
 	for (i = 0; i <= prefetch; i++)
 		_starpu_data_request_prio_list_init(&new_data_requests[i]);
 
+	double start = starpu_timing_now();
 	/* for all entries of the list */
 	while (!_starpu_data_request_prio_list_empty(&local_list))
 	{
@@ -612,6 +614,12 @@ static int __starpu_handle_node_data_requests(struct _starpu_data_request_prio_l
 		}
 
 		(*pushed)++;
+		if (starpu_timing_now() - start >= MAX_PUSH_TIME)
+		{
+			/* We have spent a lot of time doing requests, skip pushing more for now */
+			ret = -EBUSY;
+			break;
+		}
 	}
 
 	/* Push back requests we didn't handle on the proper list */

+ 1 - 0
src/datawizard/datawizard.c

@@ -44,6 +44,7 @@ int ___starpu_datawizard_progress(unsigned memory_node, unsigned may_alloc, unsi
 
 	if (ret || push_requests)
 	{
+		/* Some transfers have finished, or the driver requests to really push more */
 		unsigned pushed;
 		if (_starpu_handle_node_data_requests(memory_node, may_alloc, &pushed) == 0)
 		{