Browse Source

Default modular worker queues to 2 tasks unless it's an heft scheduler

Heft schedulers need big worker queue fifos to be able to give at least
some work to CPUs. Other schedulers do not need that, and on the
contrary the eager scheduler should not run the risk of letting CPUs
take all tasks and leave nothing to GPUs.
Samuel Thibault 5 years ago
parent
commit
2af8c10dc9
1 changed files with 30 additions and 14 deletions
  1. 30 14
      src/sched_policies/modular_ez.c

+ 30 - 14
src/sched_policies/modular_ez.c

@@ -46,7 +46,8 @@
  * The current value of the ntasks_threshold is the best we found
  * The current value of the ntasks_threshold is the best we found
  * so far across several types of applications (cholesky, LU, stencil).
  * so far across several types of applications (cholesky, LU, stencil).
  */
  */
-#define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 30
+#define _STARPU_SCHED_NTASKS_THRESHOLD_HEFT 30
+#define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 2
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
 
 
 void starpu_sched_component_initialize_simple_scheduler(starpu_sched_component_create_t create_decision_component, void *data, unsigned flags, unsigned sched_ctx_id)
 void starpu_sched_component_initialize_simple_scheduler(starpu_sched_component_create_t create_decision_component, void *data, unsigned flags, unsigned sched_ctx_id)
@@ -78,19 +79,6 @@ void starpu_sched_component_initialize_simple_scheduler(starpu_sched_component_c
 			starpu_sched_ctx_set_max_priority(sched_ctx_id, INT_MAX);
 			starpu_sched_ctx_set_max_priority(sched_ctx_id, INT_MAX);
 	}
 	}
 
 
-	struct starpu_sched_component_prio_data prio_data =
-		{
-			.ntasks_threshold = starpu_get_env_number_default("STARPU_NTASKS_THRESHOLD", _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT),
-			.exp_len_threshold = starpu_get_env_float_default("STARPU_EXP_LEN_THRESHOLD", _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT),
-		};
-
-	struct starpu_sched_component_fifo_data fifo_data =
-		{
-			.ntasks_threshold = starpu_get_env_number_default("STARPU_NTASKS_THRESHOLD", _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT),
-			.exp_len_threshold = starpu_get_env_float_default("STARPU_EXP_LEN_THRESHOLD", _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT),
-		};
-
-
 	/* See what the component will decide */
 	/* See what the component will decide */
 	unsigned nbelow;
 	unsigned nbelow;
 	unsigned nummaxids;
 	unsigned nummaxids;
@@ -210,6 +198,34 @@ void starpu_sched_component_initialize_simple_scheduler(starpu_sched_component_c
 			starpu_sched_component_connect(last, decision_component);
 			starpu_sched_component_connect(last, decision_component);
 	}
 	}
 
 
+	/* Take default ntasks_threshold */
+	unsigned ntasks_threshold;
+	if (starpu_sched_component_is_heft(decision_component) ||
+	    starpu_sched_component_is_mct(decision_component)) {
+		/* These need more queueing to allow CPUs to take some share of the work */
+		ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_HEFT;
+	} else {
+		ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	}
+	/* But let user tune it */
+	ntasks_threshold = starpu_get_env_number_default("STARPU_NTASKS_THRESHOLD", ntasks_threshold);
+
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
+	exp_len_threshold = starpu_get_env_float_default("STARPU_EXP_LEN_THRESHOLD", exp_len_threshold);
+
+	struct starpu_sched_component_prio_data prio_data =
+		{
+			.ntasks_threshold = ntasks_threshold,
+			.exp_len_threshold = exp_len_threshold,
+		};
+
+	struct starpu_sched_component_fifo_data fifo_data =
+		{
+			.ntasks_threshold = ntasks_threshold,
+			.exp_len_threshold = exp_len_threshold,
+		};
+
+
 	/* Create one fifo+eager component pair per choice, below scheduling decision */
 	/* Create one fifo+eager component pair per choice, below scheduling decision */
 	struct starpu_sched_component *last_below[nbelow];
 	struct starpu_sched_component *last_below[nbelow];
 	memset(&last_below, 0, sizeof(last_below));
 	memset(&last_below, 0, sizeof(last_below));