Browse Source

Add workerids and workerids_len task fields

Samuel Thibault 7 years ago
parent
commit
dc4e8a56ad

+ 1 - 0
ChangeLog

@@ -47,6 +47,7 @@ Small features:
     which allows to restrict where to execute a task. Also add
     which allows to restrict where to execute a task. Also add
     STARPU_TASK_WHERE to be used when calling starpu_task_insert().
     STARPU_TASK_WHERE to be used when calling starpu_task_insert().
   * Add SubmitOrder trace field.
   * Add SubmitOrder trace field.
+  * Add workerids and workerids_len task fields.
 
 
 Changes:
 Changes:
   * Vastly improve simgrid simulation time.
   * Vastly improve simgrid simulation time.

+ 10 - 0
doc/doxygen/chapters/320_scheduling.doxy

@@ -180,6 +180,16 @@ task->execute_on_a_specific_worker = 1;
 task->workerid = starpu_worker_get_by_type(STARPU_CUDA_WORKER, 0);
 task->workerid = starpu_worker_get_by_type(STARPU_CUDA_WORKER, 0);
 \endcode
 \endcode
 
 
+One can also specify a set worker(s) which are allowed to take the task, as an
+array of bit, for instance to allow workers 2 and 42:
+
+\code{.c}
+task->workerids = calloc(2,sizeof(uint32_t));
+task->workerids[2/32] |= (1 << (2%32));
+task->workerids[42/32] |= (1 << (42%32));
+task->workerids_len = 1;
+\endcode
+
 One can also specify the order in which tasks must be executed by setting the
 One can also specify the order in which tasks must be executed by setting the
 starpu_task::workerorder field. If this field is set to a non-zero value, it
 starpu_task::workerorder field. If this field is set to a non-zero value, it
 provides the per-worker consecutive order in which tasks will be executed,
 provides the per-worker consecutive order in which tasks will be executed,

+ 11 - 0
doc/doxygen/chapters/api/codelet_and_tasks.doxy

@@ -646,6 +646,17 @@ the configuration of a task allocated with starpu_task_create().
     details. This field is ignored if the field
     details. This field is ignored if the field
     starpu_task::execute_on_a_specific_worker is set to 0.
     starpu_task::execute_on_a_specific_worker is set to 0.
 
 
+\var unsigned starpu_task::workerids
+    Optional field. If the field
+    starpu_task::workerids_len is different from 0, this field indicates an
+    array of bits (stored as uint32_t values) which indicate the set of workers
+    which are allowed to execute the task. starpu_task::workerid takes
+    precedence over this.
+
+\var unsigned starpu_task::workerids_len
+    Optional field. This provides the number of uint32_t values in the
+    starpu_task::workerids array.
+
 \var starpu_task_bundle_t starpu_task::bundle
 \var starpu_task_bundle_t starpu_task::bundle
     Optional field. The bundle that includes this task. If no bundle
     Optional field. The bundle that includes this task. If no bundle
     is used, this should be <c>NULL</c>.
     is used, this should be <c>NULL</c>.

+ 2 - 0
include/starpu_task.h

@@ -189,6 +189,8 @@ struct starpu_task
 
 
 	unsigned workerid;
 	unsigned workerid;
 	unsigned workerorder;
 	unsigned workerorder;
+	uint32_t *workerids;
+	unsigned workerids_len;
 
 
 	int priority;
 	int priority;
 
 

+ 6 - 0
src/core/workers.c

@@ -342,6 +342,12 @@ int starpu_worker_can_execute_task_impl(unsigned workerid, struct starpu_task *t
 	cl = task->cl;
 	cl = task->cl;
 	if (!(task->where & _starpu_config.workers[workerid].worker_mask)) return 0;
 	if (!(task->where & _starpu_config.workers[workerid].worker_mask)) return 0;
 
 
+	if (task->workerids_len) {
+		size_t div = sizeof(*task->workerids) * 8;
+		if (workerid / div >= task->workerids_len || ! (task->workerids[workerid / div] & (1UL << workerid % div)))
+			return 0;
+	}
+
 	mask = 0;
 	mask = 0;
 	arch = _starpu_config.workers[workerid].arch;
 	arch = _starpu_config.workers[workerid].arch;
 	if (!task->cl->can_execute)
 	if (!task->cl->can_execute)