123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- int workerids[3] = {1, 3, 10};
- int id_ctx = starpu_sched_ctx_create("dmda", workerids, 3, "my_ctx");
- starpu_sched_ctx_set_task_context(id);
- starpu_task_submit(task);
- \endcode
- Note: Parallel greedy and parallel heft scheduling policies do not support the existence of several disjoint contexts on the machine.
- Combined workers are constructed depending on the entire topology of the machine, not only the one belonging to a context.
- \section ModifyingAContext Modifying A Context
- A scheduling context can be modified dynamically. The applications may
- change its requirements during the execution and the programmer can
- add additional workers to a context or remove if no longer needed. In
- the following example we have two scheduling contexts
- <c>sched_ctx1</c> and <c>sched_ctx2</c>. After executing a part of the
- tasks some of the workers of <c>sched_ctx1</c> will be moved to
- context <c>sched_ctx2</c>.
- \code{.c}
- int workerids[3] = {1, 3, 10};
- starpu_sched_ctx_add_workers(workerids, 3, sched_ctx2);
- starpu_sched_ctx_remove_workers(workerids, 3, sched_ctx1);
- \endcode
- \section SubmittingTasksToAContext Submitting Tasks To A Context
- The application may submit tasks to several contexts either
- simultaneously or sequnetially. If several threads of submission
- are used the function <c>starpu_sched_ctx_set_context</c> may be called just
- before <c>starpu_task_submit</c>. Thus StarPU considers that
- the current thread will submit tasks to the coresponding context.
-
- When the application may not assign a thread of submission to each
- context, the id of the context must be indicated by using the
- function <c>starpu_task_submit_to_ctx</c> or the field <c>STARPU_SCHED_CTX</c>
- for starpu_task_insert().
- \section DeletingAContext Deleting A Context
- When a context is no longer needed it must be deleted. The application
- can indicate which context should keep the resources of a deleted one.
- All the tasks of the context should be executed before doing this.
- Thus, the programmer may use either a barrier and then delete the context
- directly, or just indicate
- that other tasks will not be submitted later on to the context (such that when
- the last task is executed its workers will be moved to the inheritor)
- and delete the context at the end of the execution (when a barrier will
- be used eventually).
- \code{.c}
- starpu_sched_ctx_set_inheritor(sched_ctx2, sched_ctx1);
- for (i = 0; i < ntasks; i++)
- starpu_task_submit_to_ctx(task[i],sched_ctx2);
- starpu_sched_ctx_finished_submit(sched_ctx1);
- starpu_task_wait_for_all();
- starpu_sched_ctx_delete(sched_ctx2);
- starpu_sched_ctx_delete(sched_ctx1);
- \endcode
- \section EmptyingAContext Emptying A Context
- A context may have no resources at the begining or at a certain
- moment of the execution. Task can still be submitted to these contexts
- and they will be executed as soon as the contexts will have resources. A list
- of tasks pending to be executed is kept and when workers are added to
- the contexts these tasks start being submitted. However, if resources
- are never allocated to the context the program will not terminate.
- If these tasks have low
- priority the programmer can forbid the application to submit them
- by calling the function <c>starpu_sched_ctx_stop_task_submission()</c>.
- \section ContextsSharingWorkers Contexts Sharing Workers
- Contexts may share workers when a single context cannot execute
- efficiently enough alone on these workers or when the application
- decides to express a hierarchy of contexts. The workers apply an
- alogrithm of ``Round-Robin'' to chose the context on which they will
- ``pop'' next. By using the function
- <c>starpu_sched_ctx_set_turn_to_other_ctx</c>, the programmer can impose
- the <c>workerid</c> to ``pop'' in the context <c>sched_ctx_id</c>
- next.
- */
|