浏览代码

Factorize the code to detect whether prefetch should be used or not

Cédric Augonnet 15 年之前
父节点
当前提交
e49ca9715c

+ 1 - 6
src/core/policies/deque-modeling-policy-data-aware.c

@@ -19,7 +19,6 @@
 
 
 static unsigned nworkers;
 static unsigned nworkers;
 static struct starpu_jobq_s *queue_array[STARPU_NMAXWORKERS];
 static struct starpu_jobq_s *queue_array[STARPU_NMAXWORKERS];
-static int use_prefetch = 0;
 
 
 static double alpha = 1.0;
 static double alpha = 1.0;
 static double beta = 1.0;
 static double beta = 1.0;
@@ -168,7 +167,7 @@ static int _dmda_push_task(struct starpu_jobq_s *q __attribute__ ((unused)) , st
 
 
 	update_data_requests(queue_array[best], task);
 	update_data_requests(queue_array[best], task);
 	
 	
-	if (use_prefetch)
+	if (_starpu_get_prefetch_flag())
 		_starpu_prefetch_task_input_on_node(task, queue_array[best]->memory_node);
 		_starpu_prefetch_task_input_on_node(task, queue_array[best]->memory_node);
 
 
 	if (prio) {
 	if (prio) {
@@ -212,10 +211,6 @@ static void initialize_dmda_policy(struct starpu_machine_config_s *config,
 {
 {
 	nworkers = 0;
 	nworkers = 0;
 
 
-	use_prefetch = starpu_get_env_number("STARPU_PREFETCH");
-	if (use_prefetch == -1)
-		use_prefetch = 0;
-
 	const char *strval_alpha = getenv("STARPU_SCHED_ALPHA");
 	const char *strval_alpha = getenv("STARPU_SCHED_ALPHA");
 	if (strval_alpha)
 	if (strval_alpha)
 		beta = atof(strval_alpha);
 		beta = atof(strval_alpha);

+ 1 - 10
src/core/policies/deque-modeling-policy.c

@@ -20,7 +20,6 @@
 
 
 static unsigned nworkers;
 static unsigned nworkers;
 static struct starpu_jobq_s *queue_array[STARPU_NMAXWORKERS];
 static struct starpu_jobq_s *queue_array[STARPU_NMAXWORKERS];
-static int use_prefetch = 0;
 
 
 static starpu_job_t dm_pop_task(struct starpu_jobq_s *q)
 static starpu_job_t dm_pop_task(struct starpu_jobq_s *q)
 {
 {
@@ -129,7 +128,7 @@ static int _dm_push_task(struct starpu_jobq_s *q __attribute__ ((unused)), starp
 
 
 	j->predicted = model_best;
 	j->predicted = model_best;
 
 
-	if (use_prefetch)
+	if (_starpu_get_prefetch_flag())
 		_starpu_prefetch_task_input_on_node(task, queue_array[best]->memory_node);
 		_starpu_prefetch_task_input_on_node(task, queue_array[best]->memory_node);
 
 
 	if (prio) {
 	if (prio) {
@@ -174,14 +173,6 @@ static void initialize_dm_policy(struct starpu_machine_config_s *config,
 {
 {
 	nworkers = 0;
 	nworkers = 0;
 
 
-	use_prefetch = starpu_get_env_number("STARPU_PREFETCH");
-	if (use_prefetch == -1)
-		use_prefetch = 0;
-
-#ifdef STARPU_VERBOSE
-	fprintf(stderr, "Using prefetch ? %s\n", use_prefetch?"yes":"no");
-#endif
-
 	_starpu_setup_queues(_starpu_init_fifo_queues_mechanisms, init_dm_fifo, config);
 	_starpu_setup_queues(_starpu_init_fifo_queues_mechanisms, init_dm_fifo, config);
 }
 }
 
 

+ 5 - 0
src/core/policies/sched_policy.c

@@ -32,6 +32,11 @@ static struct starpu_sched_policy_s policy;
 
 
 static int use_prefetch = 0;
 static int use_prefetch = 0;
 
 
+int _starpu_get_prefetch_flag(void)
+{
+	return use_prefetch;
+}
+
 /*
 /*
  *	Predefined policies
  *	Predefined policies
  */
  */

+ 2 - 0
src/core/policies/sched_policy.h

@@ -56,6 +56,8 @@ void _starpu_init_sched_policy(struct starpu_machine_config_s *config);
 void _starpu_deinit_sched_policy(struct starpu_machine_config_s *config);
 void _starpu_deinit_sched_policy(struct starpu_machine_config_s *config);
 //void _starpu_set_local_queue(struct starpu_jobq_s *jobq);
 //void _starpu_set_local_queue(struct starpu_jobq_s *jobq);
 
 
+int _starpu_get_prefetch_flag(void);
+
 int _starpu_push_task(starpu_job_t task);
 int _starpu_push_task(starpu_job_t task);
 struct starpu_job_s *_starpu_pop_task(void);
 struct starpu_job_s *_starpu_pop_task(void);
 struct starpu_job_s *_starpu_pop_task_from_queue(struct starpu_jobq_s *queue);
 struct starpu_job_s *_starpu_pop_task_from_queue(struct starpu_jobq_s *queue);