Explorar el Código

heteroprio: simplify code by using starpu's functions and correct mistakes

Ludovic PAILLAT hace 3 años
padre
commit
de2c592021
Se han modificado 3 ficheros con 11 adiciones y 27 borrados
  1. 1 1
      include/starpu_worker.h
  2. 1 13
      src/core/workers.c
  3. 9 13
      src/sched_policies/heteroprio.c

+ 1 - 1
include/starpu_worker.h

@@ -267,7 +267,7 @@ int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
 int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
 
 /**
-   Return true if task has a codelet for this worker type
+   Return true if worker type can execute this task
 */
 unsigned starpu_worker_type_can_execute_task(enum starpu_worker_archtype worker_type, const struct starpu_task *task);
 

+ 1 - 13
src/core/workers.c

@@ -2378,19 +2378,7 @@ int starpu_worker_get_devids(enum starpu_worker_archtype type, int *devids, int
 
 unsigned starpu_worker_type_can_execute_task(enum starpu_worker_archtype worker_type, const struct starpu_task *task)
 {
-	switch(worker_type)
-	{
-		case STARPU_CPU_WORKER:
-			return task->cl->cpu_funcs[0] != NULL;
-		case STARPU_CUDA_WORKER:
-			return task->cl->cuda_funcs[0] != NULL;
-		case STARPU_OPENCL_WORKER:
-			return task->cl->opencl_funcs[0] != NULL;
-		case STARPU_MPI_MS_WORKER:
-			return task->cl->mpi_ms_funcs[0] != NULL;
-		default:
-			return 0;
-	}
+	return (STARPU_WORKER_TO_MASK(worker_type) & task->where) != 0;
 }
 
 void starpu_worker_get_name(int id, char *dst, size_t maxlen)

+ 9 - 13
src/sched_policies/heteroprio.c

@@ -1108,7 +1108,7 @@ static void starpu_autoheteroprio_fetch_task_data(struct _starpu_heteroprio_data
 	}
 	for(arch_ind = 0; arch_ind < ignored_archs; ++arch_ind)
 	{
-		if(fscanf(autoheteroprio_file, "%*u") != 1)
+		if(fscanf(autoheteroprio_file, "%u", &arch_type) != 1)
 		{
 			fclose(autoheteroprio_file);
 			_STARPU_MSG("[HETEROPRIO][INITIALIZATION] Warning, autoheteroprio's data file is missing an architecture id\n");
@@ -1142,7 +1142,7 @@ static void starpu_autoheteroprio_fetch_task_data(struct _starpu_heteroprio_data
 	}
 	for(arch_ind = 0; arch_ind < ignored_archs; ++arch_ind)
 	{
-		if(fscanf(autoheteroprio_file, "%*f %*f") != 2)
+		if(fscanf(autoheteroprio_file, "%lf %lf", &avg_arch_busy_time, &avg_arch_free_time) != 2)
 		{
 			fclose(autoheteroprio_file);
 			_STARPU_MSG("[HETEROPRIO][INITIALIZATION] Warning, autoheteroprio's data file is missing an architecture average times id\n");
@@ -2644,25 +2644,21 @@ static void order_priorities(struct _starpu_heteroprio_data *hp)
 }
 
 // used to get the name of a codelet, considering a codelet grouping strategy
-static const char *_heteroprio_get_codelet_name(enum autoheteroprio_codelet_grouping_strategy strategy, const struct starpu_codelet *cl)
+static const char *_heteroprio_get_codelet_name(enum autoheteroprio_codelet_grouping_strategy strategy, struct starpu_codelet *cl)
 {
+	const char *name = NULL;
 	switch(strategy)
 	{
 		case BY_PERF_MODEL_OR_NAME:
-			if(cl->model && cl->model->symbol)
-				return cl->model->symbol;
-			else
-				return cl->name ? cl->name : AUTOHETEROPRIO_NO_NAME;
+			name = _starpu_codelet_get_model_name(cl);
 			break;
 
 		case BY_NAME_ONLY:
-			return cl->name ? cl->name : AUTOHETEROPRIO_NO_NAME;
-			break;
-
-		default:
-			return AUTOHETEROPRIO_NO_NAME;
+			name = _starpu_codelet_get_name(cl);
 			break;
 	}
+
+	return name ? name : AUTOHETEROPRIO_NO_NAME;
 }
 
 // used by get_task_auto_priority for knowing if a submitted codelet equals an other
@@ -2724,7 +2720,7 @@ static int get_task_auto_priority(struct _starpu_heteroprio_data *hp, const stru
 	unsigned arch;
 	for(arch=0;arch<STARPU_NARCH;++arch)
 	{
-		archs[arch] = (starpu_heteroprio_types_to_arch(arch) & task->where) != 0;
+		archs[arch] = starpu_worker_type_can_execute_task(arch, task);
 	}
 
 	starpu_autoheteroprio_add_task(hp, name, archs);