Samuel Thibault il y a 12 ans
Parent
commit
2240d43c8f

+ 75 - 4
src/sched_policies/node_mct.c

@@ -155,15 +155,86 @@ int starpu_sched_node_is_mct(struct starpu_sched_node * node)
 	return node->push_task == mct_push_task;
 }
 
+/* Alpha, Beta and Gamma are MCT-specific values, which allows the
+ * user to set more precisely the weight of each computing value.
+ * Beta, for example, controls the weight of communications between
+ * memories for the computation of the best node to choose. 
+ */
+#define _STARPU_SCHED_ALPHA_DEFAULT 1.0
+#define _STARPU_SCHED_BETA_DEFAULT 1.0
+#define _STARPU_SCHED_GAMMA_DEFAULT 1000.0
+
+#ifdef STARPU_USE_TOP
+static void param_modified(struct starpu_top_param* d)
+{
+	/* Just to show parameter modification. */
+	fprintf(stderr, "%s has been modified : %f\n",
+			d->name, *(double*) d->value);
+}
+#endif /* !STARPU_USE_TOP */
+
+#ifdef STARPU_USE_TOP
+static const float alpha_minimum=0;
+static const float alpha_maximum=10.0;
+static const float beta_minimum=0;
+static const float beta_maximum=10.0;
+static const float gamma_minimum=0;
+static const float gamma_maximum=10000.0;
+static const float idle_power_minimum=0;
+static const float idle_power_maximum=10000.0;
+#endif /* !STARPU_USE_TOP */
+
 struct starpu_sched_node * starpu_sched_node_mct_create(struct starpu_mct_data * params)
 {
 	struct starpu_sched_node * node = starpu_sched_node_create();
 
 	struct _starpu_mct_data * data = malloc(sizeof(*data));
-	data->alpha = params->alpha;
-	data->beta = params->beta;
-	data->gamma = params->gamma;
-	data->idle_power = params->idle_power;
+	if (params)
+	{
+		data->alpha = params->alpha;
+		data->beta = params->beta;
+		data->gamma = params->gamma;
+		data->idle_power = params->idle_power;
+	}
+	else
+	{
+		double alpha = _STARPU_SCHED_ALPHA_DEFAULT,
+		       beta = _STARPU_SCHED_BETA_DEFAULT,
+		       _gamma = _STARPU_SCHED_GAMMA_DEFAULT,
+		       idle_power = 0.0;
+
+		const char *strval_alpha = getenv("STARPU_SCHED_ALPHA");
+		if (strval_alpha)
+			alpha = atof(strval_alpha);
+
+		const char *strval_beta = getenv("STARPU_SCHED_BETA");
+		if (strval_beta)
+			beta = atof(strval_beta);
+
+		const char *strval_gamma = getenv("STARPU_SCHED_GAMMA");
+		if (strval_gamma)
+			_gamma = atof(strval_gamma);
+
+		const char *strval_idle_power = getenv("STARPU_IDLE_POWER");
+		if (strval_idle_power)
+			idle_power = atof(strval_idle_power);
+
+		data->alpha = alpha;
+		data->beta = beta;
+		data->gamma = _gamma;
+		data->idle_power = idle_power;
+	}
+
+#ifdef STARPU_USE_TOP
+	starpu_top_register_parameter_float("MCT_ALPHA", &data->alpha,
+					    alpha_minimum, alpha_maximum, param_modified);
+	starpu_top_register_parameter_float("MCT_BETA", &data->beta,
+					    beta_minimum, beta_maximum, param_modified);
+	starpu_top_register_parameter_float("MCT_GAMMA", &data->gamma,
+					    gamma_minimum, gamma_maximum, param_modified);
+	starpu_top_register_parameter_float("MCT_IDLE_POWER", &data->idle_power,
+					    idle_power_minimum, idle_power_maximum, param_modified);
+#endif /* !STARPU_USE_TOP */
 
 	node->data = data;
 

+ 3 - 2
src/sched_policies/tree_eager_prefetching.c

@@ -20,11 +20,12 @@
 
 #define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 2
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
-static unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
-static double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
 
 static void initialize_eager_prefetching_center_policy(unsigned sched_ctx_id)
 {
+	unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
+
 	_STARPU_DISP("Warning: you are running the default tree-eager-prefetching scheduler, which is not very smart. Make sure to read the StarPU documentation about adding performance models in order to be able to use the tree-heft scheduler instead.\n");
 
 	starpu_sched_ctx_create_worker_collection(sched_ctx_id, STARPU_WORKER_LIST);

+ 3 - 74
src/sched_policies/tree_heft.c

@@ -19,11 +19,6 @@
 #include <starpu_scheduler.h>
 #include <float.h>
 
-/* Alpha, Beta and Gamma are heft-specific values, which allows the
- * user to set more precisely the weight of each computing value.
- * Beta, for example, controls the weight of communications between
- * memories for the computation of the best node to choose. 
- */
 /* The two thresolds concerns the prio nodes, which contains queues
  * who can handle the priority of StarPU tasks. You can tune your
  * scheduling by benching those values and choose which one is the
@@ -31,62 +26,15 @@
  * The current value of the ntasks_threshold is the best we found
  * so far across several types of applications (cholesky, LU, stencil).
  */
-#define _STARPU_SCHED_ALPHA_DEFAULT 1.0
-#define _STARPU_SCHED_BETA_DEFAULT 1.0
-#define _STARPU_SCHED_GAMMA_DEFAULT 1000.0
 #define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 30
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
-static double alpha = _STARPU_SCHED_ALPHA_DEFAULT;
-static double beta = _STARPU_SCHED_BETA_DEFAULT;
-static double _gamma = _STARPU_SCHED_GAMMA_DEFAULT;
-static unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
-static double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
-
-#ifdef STARPU_USE_TOP
-static const float alpha_minimum=0;
-static const float alpha_maximum=10.0;
-static const float beta_minimum=0;
-static const float beta_maximum=10.0;
-static const float gamma_minimum=0;
-static const float gamma_maximum=10000.0;
-static const float idle_power_minimum=0;
-static const float idle_power_maximum=10000.0;
-#endif /* !STARPU_USE_TOP */
-
-static double idle_power = 0.0;
-
-#ifdef STARPU_USE_TOP
-static void param_modified(struct starpu_top_param* d)
-{
-#ifdef STARPU_DEVEL
-#warning FIXME: get sched ctx to get alpha/beta/gamma/idle values
-#endif
-	/* Just to show parameter modification. */
-	fprintf(stderr,
-		"%s has been modified : "
-		"alpha=%f|beta=%f|gamma=%f|idle_power=%f !\n",
-		d->name, alpha,beta,_gamma, idle_power);
-}
-#endif /* !STARPU_USE_TOP */
 
 static void initialize_heft_center_policy(unsigned sched_ctx_id)
 {
 	starpu_sched_ctx_create_worker_collection(sched_ctx_id, STARPU_WORKER_LIST);
-	const char *strval_alpha = getenv("STARPU_SCHED_ALPHA");
-	if (strval_alpha)
-		alpha = atof(strval_alpha);
-
-	const char *strval_beta = getenv("STARPU_SCHED_BETA");
-	if (strval_beta)
-		beta = atof(strval_beta);
-
-	const char *strval_gamma = getenv("STARPU_SCHED_GAMMA");
-	if (strval_gamma)
-		_gamma = atof(strval_gamma);
 
-	const char *strval_idle_power = getenv("STARPU_IDLE_POWER");
-	if (strval_idle_power)
-		idle_power = atof(strval_idle_power);
+	unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
 
 	const char *strval_ntasks_threshold = getenv("STARPU_NTASKS_THRESHOLD");
 	if (strval_ntasks_threshold)
@@ -96,17 +44,6 @@ static void initialize_heft_center_policy(unsigned sched_ctx_id)
 	if (strval_exp_len_threshold)
 		exp_len_threshold = atof(strval_exp_len_threshold);
 
-#ifdef STARPU_USE_TOP
-	starpu_top_register_parameter_float("HEFT_ALPHA", &alpha,
-					    alpha_minimum, alpha_maximum, param_modified);
-	starpu_top_register_parameter_float("HEFT_BETA", &beta,
-					    beta_minimum, beta_maximum, param_modified);
-	starpu_top_register_parameter_float("HEFT_GAMMA", &_gamma,
-					    gamma_minimum, gamma_maximum, param_modified);
-	starpu_top_register_parameter_float("HEFT_IDLE_POWER", &idle_power,
-					    idle_power_minimum, idle_power_maximum, param_modified);
-#endif /* !STARPU_USE_TOP */
-
 	
 /* The scheduling strategy look like this :
  *
@@ -145,15 +82,7 @@ static void initialize_heft_center_policy(unsigned sched_ctx_id)
 	struct starpu_sched_node * window_node = starpu_sched_node_prio_create(NULL);
 	t->root = window_node;
 
-	struct starpu_mct_data mct_data =
-		{
-			.alpha = alpha,
-			.beta = beta,
-			.gamma = _gamma,
-			.idle_power = idle_power,
-		};
-
-	struct starpu_sched_node * perfmodel_node = starpu_sched_node_mct_create(&mct_data);
+	struct starpu_sched_node * perfmodel_node = starpu_sched_node_mct_create(NULL);
 	struct starpu_sched_node * no_perfmodel_node = starpu_sched_node_eager_create(NULL);
 	struct starpu_sched_node * calibrator_node = starpu_sched_node_eager_create(NULL);
 	

+ 3 - 2
src/sched_policies/tree_prio_prefetching.c

@@ -19,11 +19,12 @@
 
 #define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 4
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
-static unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
-static double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
 
 static void initialize_prio_prefetching_center_policy(unsigned sched_ctx_id)
 {
+	unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
+
 	const char *strval_ntasks_threshold = getenv("STARPU_NTASKS_THRESHOLD");
 	if (strval_ntasks_threshold)
 		ntasks_threshold = atof(strval_ntasks_threshold);

+ 6 - 2
src/sched_policies/tree_random_prefetching.c

@@ -20,13 +20,14 @@
 
 #define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 2
 #define _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT 1000000000.0
-static unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
-static double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
 
 /* Random scheduler with fifo queues for its scheduling window and its workers. */
 
 static void initialize_random_fifo_prefetching_center_policy(unsigned sched_ctx_id)
 {
+	unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
+
 	const char *strval_ntasks_threshold = getenv("STARPU_NTASKS_THRESHOLD");
 	if (strval_ntasks_threshold)
 		ntasks_threshold = atof(strval_ntasks_threshold);
@@ -91,6 +92,9 @@ struct starpu_sched_policy _starpu_sched_tree_random_prefetching_policy =
 
 static void initialize_random_prio_prefetching_center_policy(unsigned sched_ctx_id)
 {
+	unsigned ntasks_threshold = _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT;
+	double exp_len_threshold = _STARPU_SCHED_EXP_LEN_THRESHOLD_DEFAULT;
+
 	const char *strval_ntasks_threshold = getenv("STARPU_NTASKS_THRESHOLD");
 	if (strval_ntasks_threshold)
 		ntasks_threshold = atof(strval_ntasks_threshold);