|
For more on this topic see Using task parallelism in multicore LabView.
In today's world of multicore processors and multithreaded applications, programmers need to think constantly about how to best harness the power of cutting-edge CPUs when developing their applications. Although structuring parallel code in traditional text-based languages can be difficult both to program and visualize, graphical development environments such as National Instruments LabVIEW are increasingly allowing engineers and scientists to cut their development times and quickly implement their ideas.
Because NI LabVIEW is inherently parallel (based on dataflow), programming multithreaded applications is typically a very simple task. Independent tasks on the block diagram automatically execute in parallel with no extra work required from the programmer. But what about pieces of code that are not independent? When implementing inherently serial applications, what can be done to harness the power of multicore CPUs?
Introduction to Pipelining
One widely accepted technique for improving the performance of serial software tasks is pipelining. Simply put, pipelining is the process of dividing a serial task into concrete stages that can be executed in assembly-line fashion.
Consider the following example: suppose you are manufacturing cars on an automated assembly line. Your end task is building a complete car, but you can separate this into three concrete stages: building the frame, putting the parts inside (such as the engine), and painting the car when finished.
Assume that the building the frame, installing parts, and painting take one hour each. Therefore, if you built just one car at a time each car would take three hours to complete (see Figure 1 below).

Figure 1. In this example (non-pipelined), building a car takes 3 hours to complete.
How can this process be improved? What if we set up one station for frame building, another for part installation, and a third for painting. Now, while one car is being painted, a second car can have parts installed, and a third car can be under frame construction.
How Pipelining Improves Performance
Although each car still takes three hours to finish using our new process, we can now produce one car each hour rather than one every three hours—a 3x improvement in throughput of the car manufacturing process. Note that this example has been simplified for demonstration purposes; see the Important Concerns section on the next page for additional details on pipelining.

(Click to enlarge)
Figure 2. Pipelining can greatly increase the throughput of your application.
Basic Pipelining in LabVIEW
The same pipelining concept as visualized in the car example can be applied to any LabVIEW application in which you are executing a serial task. Essentially, you can use LabVIEW shift registers and feedback nodes to make an "assembly line" out of any given program. The following conceptual illustration shows how a sample pipelined application might run on several CPU cores:

(Click to enlarge)
Figure 3. Timing diagram for a pipelined application running on several CPU cores.
|