|Home > Converting existing code to OpenCL > Parallel processing techniques in OpenCL > Compute values per frame|
If your application requires continuous updates of data elements and there are dependencies between them, try breaking the computations into discrete units and perform one iteration per image frame displayed.
For example, the following figure shows an application that runs a continuous physics simulation of a flag.
The flag is made up of a grid of nodes that are connected to the neighboring nodes. These nodes are shown in the following figure.
The simulation runs as a series of iterations. In one iteration, all the nodes are updated and the image is redrawn.
The following operations are performed in each iteration:
In this case, splitting the computations into iterations also splits the dependencies. The data required for one frame is computed in the previous frame.
Some types of simulation require many iterations for relatively small movements. If this is the case, try computing multiple iterations before drawing frames.