Browse Source

Fix usage of STARPU_ANY_WORKER

Samuel Thibault 4 years ago
parent
commit
1efe5d08a6

+ 0 - 2
include/starpu_perfmodel.h

@@ -35,8 +35,6 @@ extern "C"
 struct starpu_task;
 struct starpu_data_descr;
 
-#define STARPU_NARCH STARPU_ANY_WORKER
-
 /**
    todo
 */

+ 1 - 0
include/starpu_worker.h

@@ -68,6 +68,7 @@ enum starpu_worker_archtype
 	STARPU_MIC_WORKER=3,        /**< Intel MIC device */
 	STARPU_MPI_MS_WORKER=5,     /**< MPI Slave device */
 	STARPU_MAX_WORKER=5,        /**< maximum value of STARPU_*_WORKER */
+	STARPU_NARCH = (STARPU_MAX_WORKER+1), /**< Number of arch types */
 	STARPU_ANY_WORKER=255       /**< any worker, used in the hypervisor */
 };
 

+ 1 - 1
src/core/perfmodel/perfmodel_history.c

@@ -53,7 +53,7 @@ static int current_arch_comb;
 static int nb_arch_combs;
 static starpu_pthread_rwlock_t arch_combs_mutex;
 static int historymaxerror;
-static char ignore_devid[STARPU_ANY_WORKER];
+static char ignore_devid[STARPU_NARCH];
 
 /* How many executions a codelet will have to be measured before we
  * consider that calibration will provide a value good enough for scheduling */

+ 1 - 1
src/core/workers.c

@@ -205,7 +205,7 @@ void _starpu__workers_c__register_kobs(void)
 	/* TODO */
 }
 
-struct starpu_driver_info starpu_driver_info[STARPU_MAX_WORKER+1];
+struct starpu_driver_info starpu_driver_info[STARPU_NARCH];
 
 void starpu_driver_info_register(enum starpu_worker_archtype archtype, const struct starpu_driver_info *info)
 {

+ 1 - 1
src/core/workers.h

@@ -458,7 +458,7 @@ struct starpu_driver_info {
 };
 
 /** Device driver information, indexed by enum starpu_worker_archtype */
-extern struct starpu_driver_info starpu_driver_info[STARPU_MAX_WORKER+1];
+extern struct starpu_driver_info starpu_driver_info[STARPU_NARCH];
 
 void starpu_driver_info_register(enum starpu_worker_archtype archtype, const struct starpu_driver_info *info);
 

+ 4 - 4
src/sched_policies/heteroprio.c

@@ -37,7 +37,7 @@
 #define DBL_MAX __DBL_MAX__
 #endif
 
-#define STARPU_NB_TYPES (STARPU_MAX_WORKER+1)
+#define STARPU_NB_TYPES STARPU_NARCH
 
 /* A bucket corresponds to a Pair of priorities
  * When a task is pushed with a priority X, it will be stored
@@ -112,7 +112,7 @@ struct _starpu_heteroprio_data
 
 static int starpu_heteroprio_types_to_arch(enum starpu_worker_archtype arch)
 {
-	if (arch > STARPU_MAX_WORKER)
+	if (arch >= STARPU_NARCH)
 		return 0;
 	return STARPU_WORKER_TO_MASK(arch);
 }
@@ -174,7 +174,7 @@ static inline void default_init_sched(unsigned sched_ctx_id)
 	enum starpu_worker_archtype type;
 
 	// By default each type of devices uses 1 bucket and no slow factor
-	for (type = 0; type <= STARPU_MAX_WORKER; type++)
+	for (type = 0; type < STARPU_NARCH; type++)
 		if (starpu_worker_get_count_by_type(type) > 0)
 			starpu_heteroprio_set_nb_prios(sched_ctx_id, type, max_prio-min_prio+1);
 
@@ -183,7 +183,7 @@ static inline void default_init_sched(unsigned sched_ctx_id)
 	for(prio=min_prio ; prio<=max_prio ; prio++)
 	{
 		// By default each type of devices uses 1 bucket and no slow factor
-		for (type = 0; type <= STARPU_MAX_WORKER; type++)
+		for (type = 0; type < STARPU_NARCH; type++)
 			if (starpu_worker_get_count_by_type(type) > 0)
 				starpu_heteroprio_set_mapping(sched_ctx_id, type, prio, prio);
 	}

+ 3 - 3
src/sched_policies/modular_ez.c

@@ -112,8 +112,8 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 		nummaxids = starpu_worker_get_count() + starpu_combined_worker_get_count();
 		if (starpu_memory_nodes_get_count() > nummaxids)
 			nummaxids = starpu_memory_nodes_get_count();
-		if (STARPU_ANY_WORKER > nummaxids)
-			nummaxids = STARPU_ANY_WORKER;
+		if (STARPU_NARCH > nummaxids)
+			nummaxids = STARPU_NARCH;
 
 		if (sched == 0)
 			decide_flags = flags & STARPU_SCHED_SIMPLE_DECIDE_MASK;
@@ -154,7 +154,7 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 			/* Count available architecture types */
 			enum starpu_worker_archtype type;
 			nbelow = 0;
-			for (type = STARPU_CPU_WORKER; type < STARPU_ANY_WORKER; type++)
+			for (type = 0; type < STARPU_NARCH; type++)
 			{
 				if (starpu_worker_get_count_by_type(type))
 				{

+ 2 - 0
src/util/fstarpu.c

@@ -82,6 +82,7 @@ static const intptr_t fstarpu_opencl_worker = STARPU_OPENCL_WORKER;
 static const intptr_t fstarpu_mic_worker = STARPU_MIC_WORKER;
 static const intptr_t fstarpu_max_worker = STARPU_MAX_WORKER;
 static const intptr_t fstarpu_any_worker = STARPU_ANY_WORKER;
+static const intptr_t fstarpu_narch = STARPU_NARCH;
 
 static const intptr_t fstarpu_nmaxbufs = STARPU_NMAXBUFS;
 
@@ -176,6 +177,7 @@ intptr_t fstarpu_get_constant(char *s)
 	else if (!strcmp(s, "FSTARPU_MIC_WORKER"))	{ return fstarpu_mic_worker; }
 	else if (!strcmp(s, "FSTARPU_MAX_WORKER"))	{ return fstarpu_max_worker; }
 	else if (!strcmp(s, "FSTARPU_ANY_WORKER"))	{ return fstarpu_any_worker; }
+	else if (!strcmp(s, "FSTARPU_NARCH"))	{ return fstarpu_narch; }
 
 	else if (!strcmp(s, "FSTARPU_NMAXBUFS"))	{ return fstarpu_nmaxbufs; }