ソースを参照

Add workerids and workerids_len task fields

Samuel Thibault 7 年 前
コミット
dc4e8a56ad
共有5 個のファイルを変更した30 個の追加0 個の削除を含む
  1. 1 0
      ChangeLog
  2. 10 0
      doc/doxygen/chapters/320_scheduling.doxy
  3. 11 0
      doc/doxygen/chapters/api/codelet_and_tasks.doxy
  4. 2 0
      include/starpu_task.h
  5. 6 0
      src/core/workers.c

+ 1 - 0
ChangeLog

@@ -47,6 +47,7 @@ Small features:
     which allows to restrict where to execute a task. Also add
     STARPU_TASK_WHERE to be used when calling starpu_task_insert().
   * Add SubmitOrder trace field.
+  * Add workerids and workerids_len task fields.
 
 Changes:
   * 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);
 \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
 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,

+ 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
     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
     Optional field. The bundle that includes this task. If no bundle
     is used, this should be <c>NULL</c>.

+ 2 - 0
include/starpu_task.h

@@ -189,6 +189,8 @@ struct starpu_task
 
 	unsigned workerid;
 	unsigned workerorder;
+	uint32_t *workerids;
+	unsigned workerids_len;
 
 	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;
 	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;
 	arch = _starpu_config.workers[workerid].arch;
 	if (!task->cl->can_execute)