MultiProcessor Task Distribution

MPTasks and Illustrations

The task model is a mechanism to run an application efficiently using multicore. Cafe SDK provides MPTask functions to achieve the task model.


Figure 11: Task and Task Queue

In the task model shown in Figure 11, the operation of an application is divided into multiple, independent tasks. Those tasks are then placed into a task queue.


Figure 12: Task Acquisition

Each CPU core has a worker thread. The worker thread obtains tasks from the task queue to execute them.


Figure 13: Task Processing

In the MPTask function, the MPTask structure indicates a task, and the MPTaskQueue structure indicates a task queue. The task function and data are associated for each task.

To execute a task, the worker thread uses the task function to process the data.

Demo: Setup MPTaskQueue Model and Initiate Tasks on All Three Cores

The following demo uses tasks to calculate the sum of a data array.

$CAFE_ROOT/system/src/demo/os/mptask/mptask_simple.c

MPTask, Lightweight Synchronizer Usage

Demo: Using Spinlocks with MPTask

The following demo uses tasks to calculate the sum of each of the four data arrays. A spinlock globally protects the data modified in tasks.

$CAFE_ROOT/system/src/demo/os/mptask/spinlock_with_mptask.c

Demo: Using OSRendezvous with MPTask

The following demo uses tasks to sort a data array. OSRendezvous synchronizes tasks on cores.

$CAFE_ROOT/system/src/demo/os/mptask/rendezvous_with_mptask.c

MPTask Use Case in a Game

In this section, we demonstrate how to compute the movement of 1000 particles using tasks.


Figure 14: Initialization of Task and Task Queue

  1. The main core initializes a task queue, and then starts the sub-cores.
  2. The sub-cores wait until the task queue starts.
  3. The main core initializes tasks, and then places them in the task queue.
  4. One task computes the next position of one particle.


Figure 15: Task Processing in Application Main Loop

  1. The main loop of the application starts.
  2. The main core starts the task queue.
  3. The main core and two sub-cores process tasks until the task queue is empty.
  4. The main core waits for the task queue to enter the DONE state.
  5. The main core draws 1000 particles.
  6. To perform the same computation in the next frame, the main core resets the task queue and task status.
  7. The main core waits for vertical retrace before starting the next frame.
  8. Repeat steps 1-7 in every frame.

Revision History

2013/05/08 Automated cleanup pass.
2013/03/20 Converted to HTML.


CONFIDENTIAL