Task dependency and task scheduling

In ALF programming model, task dependency is used to make sure multiple tasks can be run in a specific order when the order is critical. Some common dependency scenarios are listed here:

After you have created a task, you can use the function alf_task_depends_on to specify the task's dependency with an existing task. The ALF runtime considers a task's dependency and the number of requested accelerators for scheduling.

The ALF framework does not detect circular dependency. For a task that depends on other tasks, you must define the dependencies before any work block is added to the task. If a circular dependency is present in the task definitions, the application hangs.

A task that depends on other tasks cannot be processed until all the dependent tasks finish. Tasks are created in immediate mode. After a task has been created and its dependencies are satisfied, the task can be scheduled to run.

For an example of how to use task dependency, see Task dependency example.

Task instance

A task can be scheduled to run on multiple accelerators. Each task running on an accelerator is a task instance. If a task is created without the ALF_TASK_ATTR_SCHED_FIXED attribute, the ALF runtime can load and unload an instance of a task to and from an accelerator anytime.

The ALF runtime posts an event after a task instance is started on an accelerator or unloaded from an accelerator. You can choose to register an event handler for this event, see Task events.

Fixed task mapping

For task scheduling, you can explicitly require the runtime to start a fixed number of task instances for a specific task. This is known as fixed task mapping. To do this, you need to :
  1. Provide the number of task instances at task creation time through the alf_task_create interface
  2. Set the ALF_TASK_ATTR_SCHED_FIXED task attribute
In this case, the runtime makes sure all the task instances are started before work blocks are assigned to them.