|
One major concern with both the function parallel
models is that they have an upper limit to how many cores they can
support. This is the limit of how many parallel tasks it is possible to
find in the engine. The number of meaningful tasks is decreased by the
fact that threading very small tasks will yield negligible results. The
synchronous function parallel model imposes an additional limit – the
parallel tasks should have very little dependencies on each other. For
example it is not sensible to run a physics task in parallel with a
rendering task if the rendering needs the object coordinates from the
physics task.
The expected performance
of the model can be directly seen from the length of the longest path
of execution in the game loop. The length of this path of execution is
directly tied to the amount of parallelism in the loop. As this model
generally allows the least amount of parallelism of the three models,
the same can be expected from the model's performance.
As
the synchronous function parallel model assumes there are very few
connections between tasks that run in parallel, existing components do
not require many changes. For example if running the physics component
update is a task that can be run concurrently with the sound mixer,
neither component needs special support to operate.
Asynchronous function parallel model
Gabb
and Lake propose an alternative function parallel model. The difference
is that this model doesn't contain a game loop. Instead, the tasks that
drive the game forward update at their own pace, using the latest
information available. For example the rendering task might not wait
for the physics task to finish, but would just use the latest completed
physics update. By using this method it is possible to efficiently
parallelize tasks that are interdependent. Figure 2 shows an example of
the asynchronous function parallel model.

Figure 2. The asynchronous function parallel model enables
interdependent tasks to run in parallel. The rendering task does not
wait for the physics task to finish, but uses the latest complete
physics update.
As with the synchronous model, the
scalability of the asynchronous function parallel model is limited by
how many tasks it is possible to find from the engine. Fortunately the
communication between threads by only using the latest information
available effectively reduces the need for the threads to be truly
independent. Thus we can easily have a physics task run concurrently
with a rendering task – the rendering task would use a previous physics
update to get the coordinates for each object. Based on this, the
asynchronous model can support a larger amount of tasks, and therefore
a larger amount of processor cores, than the synchronous model.
|