Explorar el Código

We now store what is the mask associated to each worker, so that we can test if
a worker can execute a task that was explicitely attributed to that worker.

Cédric Augonnet hace 15 años
padre
commit
272db710fc
Se han modificado 4 ficheros con 24 adiciones y 2 borrados
  1. 14 2
      src/core/task.c
  2. 3 0
      src/core/topology.c
  3. 5 0
      src/core/workers.c
  4. 2 0
      src/core/workers.h

+ 14 - 2
src/core/task.c

@@ -115,8 +115,20 @@ int starpu_submit_task(struct starpu_task *task)
 
 	STARPU_ASSERT(task);
 
-	if (task->cl && !worker_exists(task->cl->where))
-		return -ENODEV;
+	if (task->cl)
+	{
+		uint32_t where = task->cl->where;
+		if (!worker_exists(where))
+			return -ENODEV;
+
+		/* In case we require that a task should be explicitely
+		 * executed on a specific worker, we make sure that the worker
+		 * is able to execute this task.  */
+		if (task->execute_on_a_specific_worker 
+			&& !worker_may_execute_task(task->workerid, where))
+			return -ENODEV;
+	}
+
 
 	/* internally, StarPU manipulates a job_t which is a wrapper around a
  	* task structure */

+ 3 - 0
src/core/topology.c

@@ -198,6 +198,7 @@ static int init_machine_config(struct machine_config_s *config,
 		
 		config->workers[config->nworkers + cudagpu].id = devid;
 		config->workers[config->nworkers + cudagpu].perf_arch = arch; 
+		config->workers[config->nworkers + cudagpu].worker_mask = CUDA;
 		config->worker_mask |= CUDA;
 	}
 
@@ -231,6 +232,7 @@ static int init_machine_config(struct machine_config_s *config,
 		config->workers[config->nworkers + spu].perf_arch = STARPU_GORDON_DEFAULT;
 		config->workers[config->nworkers + spu].id = spu;
 		config->workers[config->nworkers + spu].worker_is_running = 0;
+		config->workers[config->nworkers + spu].worker_mask = GORDON;
 		config->worker_mask |= GORDON;
 	}
 
@@ -264,6 +266,7 @@ static int init_machine_config(struct machine_config_s *config,
 		config->workers[config->nworkers + core].arch = STARPU_CORE_WORKER;
 		config->workers[config->nworkers + core].perf_arch = STARPU_CORE_DEFAULT;
 		config->workers[config->nworkers + core].id = core;
+		config->workers[config->nworkers + core].worker_mask = CORE;
 		config->worker_mask |= CORE;
 	}
 

+ 5 - 0
src/core/workers.c

@@ -42,6 +42,11 @@ inline uint32_t may_submit_core_task(void)
 	return (CORE & config.worker_mask);
 }
 
+inline uint32_t worker_may_execute_task(unsigned workerid, uint32_t where)
+{
+	return (where & config.workers[workerid].worker_mask);
+}
+
 /*
  * Runtime initialization methods
  */

+ 2 - 0
src/core/workers.h

@@ -63,6 +63,7 @@ struct worker_s {
 	struct machine_config_s *config;
         pthread_mutex_t mutex;
 	enum starpu_archtype arch; /* what is the type of worker ? */
+	uint32_t worker_mask; /* what is the type of worker ? */
 	enum starpu_perf_archtype perf_arch; /* in case there are different models of the same arch */
 	pthread_t worker_thread; /* the thread which runs the worker */
 	int id; /* which core/gpu/etc is controlled by the workker ? */
@@ -135,6 +136,7 @@ unsigned machine_is_running(void);
 inline uint32_t worker_exists(uint32_t task_mask);
 inline uint32_t may_submit_cuda_task(void);
 inline uint32_t may_submit_core_task(void);
+inline uint32_t worker_may_execute_task(unsigned workerid, uint32_t where);
 
 void bind_thread_on_cpu(struct machine_config_s *config, unsigned coreid);