The LabVIEW graphical programming paradigm makes parallel programming easy, even for novice users. Two separate tasks that are not dependent on one another for data run in parallel without the need for any extra programming.
Figure 1 shows a simple data acquisition routine. The top section of code consists of an analog voltage input task, and the bottom code is a digital output task.
Figure 1. In LabVIEW, two sections of code with no data dependencies will run independently in parallel.
These two independent data acquisition tasks must share the same CPU on a single-core processor. On a multicore processor, each thread can run on its own processor, greatly improving the execution speed.
When using data parallelism in an application, it is important to ensure that the two tasks do not have any shared resources that could create a bottleneck, such as the code in Figure 2.
Figure 2. If one task depends on another for data, then the two tasks cannot run independently.
In this program, the two tasks share data; the digital task is forced to wait until the analog task has already started. Although this code appears to be parallel, it is not truly parallel because the two tasks share data. It is important to be aware of this pitfall when programming applications using task parallelism.