Selaa lähdekoodia

Adding a prefetch field in the task' structure to optimize unneeded prefetching calls, and adapting default threshold values for some predefined hierarchical schedulers.

Marc Sergent 11 vuotta sitten
vanhempi
commit
76691542fa

+ 2 - 0
include/starpu_task.h

@@ -171,6 +171,7 @@ struct starpu_task
 	double flops;
 
 	unsigned scheduled;
+	unsigned prefetched;
 };
 
 #define STARPU_TASK_INITIALIZER 			\
@@ -198,6 +199,7 @@ struct starpu_task
 	.hypervisor_tag = 0,				\
 	.flops = 0.0,					\
 	.scheduled = 0,					\
+	.prefetched = 0,					\
 	.dyn_handles = NULL,				\
 	.dyn_interfaces = NULL,				\
 	.name = NULL                        		\

+ 1 - 1
src/core/sched_policy.c

@@ -164,7 +164,7 @@ struct starpu_sched_policy *_starpu_select_sched_policy(struct _starpu_machine_c
 		return selected_policy;
 
 	/* If no policy was specified, we use the greedy policy as a default */
-	return &_starpu_sched_eager_policy;
+	return &_starpu_sched_tree_eager_prefetching_policy;
 }
 
 void _starpu_init_sched_policy(struct _starpu_machine_config *config, struct _starpu_sched_ctx *sched_ctx, struct starpu_sched_policy *selected_policy)

+ 1 - 0
src/core/task.c

@@ -81,6 +81,7 @@ void starpu_task_init(struct starpu_task *task)
 	task->flops = 0.0;
 
 	task->scheduled = 0;
+	task->prefetched = 0;
 
 	task->dyn_handles = NULL;
 	task->dyn_interfaces = NULL;

+ 1 - 3
src/datawizard/coherency.c

@@ -658,6 +658,7 @@ static void _starpu_set_data_requested_flag_if_needed(struct _starpu_data_replic
 
 int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)
 {
+	STARPU_ASSERT(!task->prefetched);
 	unsigned nbuffers = task->cl->nbuffers;
 	unsigned index;
 
@@ -671,9 +672,6 @@ int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node)
 
 		struct _starpu_data_replicate *replicate = &handle->per_node[node];
 		
-		if (replicate->state != STARPU_INVALID)
-			continue;
-
 		prefetch_data_on_node(handle, replicate, mode);
 
 		_starpu_set_data_requested_flag_if_needed(replicate);

+ 8 - 6
src/sched_policies/node_sched.c

@@ -470,12 +470,14 @@ double starpu_sched_node_transfer_length(struct starpu_sched_node * node, struct
  */
 void starpu_sched_node_prefetch_on_node(struct starpu_sched_node * node, struct starpu_task * task)
 {
-       if (starpu_get_prefetch_flag() && (node->properties >= STARPU_SCHED_NODE_SINGLE_MEMORY_NODE))
-       {
-               int worker = starpu_bitmap_first(node->workers_in_ctx);
-               unsigned memory_node = starpu_worker_get_memory_node(worker);
-               starpu_prefetch_task_input_on_node(task, memory_node);
-       }
+	if (starpu_get_prefetch_flag() && (!task->prefetched)
+		&& (node->properties >= STARPU_SCHED_NODE_SINGLE_MEMORY_NODE))
+	{
+		int worker = starpu_bitmap_first(node->workers_in_ctx);
+		unsigned memory_node = starpu_worker_get_memory_node(worker);
+		starpu_prefetch_task_input_on_node(task, memory_node);
+		task->prefetched = 1;
+	}
 }
 
 /* The default implementation of the room function is a recursive call to its fathers.

+ 2 - 0
src/sched_policies/tree_eager.c

@@ -19,6 +19,8 @@
 
 static void initialize_eager_center_policy(unsigned sched_ctx_id)
 {
+	_STARPU_DISP("Warning: you are running the default tree-eager 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);
 	struct starpu_sched_tree *t = starpu_sched_tree_create(sched_ctx_id);
  	t->root = starpu_sched_node_fifo_create(NULL);

+ 4 - 1
src/sched_policies/tree_eager_prefetching.c

@@ -17,13 +17,16 @@
 #include <starpu_sched_node.h>
 #include <starpu_scheduler.h>
 
-#define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 4
+#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)
 {
+	_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);
 	const char *strval_ntasks_threshold = getenv("STARPU_NTASKS_THRESHOLD");
 	if (strval_ntasks_threshold)
 		ntasks_threshold = atof(strval_ntasks_threshold);

+ 1 - 1
src/sched_policies/tree_heft.c

@@ -33,7 +33,7 @@
 #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 15000000
+#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;

+ 1 - 1
src/sched_policies/tree_random_prefetching.c

@@ -17,7 +17,7 @@
 #include <starpu_sched_node.h>
 #include <starpu_scheduler.h>
 
-#define _STARPU_SCHED_NTASKS_THRESHOLD_DEFAULT 4
+#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;