The main benefit of developing your application in LabVIEW is the intuitive, graphical nature of the language. In LabVIEW, you solve your engineering problem as if you were drawing a block diagram on paper. Modern multicore processors make LabVIEW an even more favorable choice as a programming tool because of its ability to express and execute tasks in parallel.
The dataflow nature of LabVIEW means that anytime there is a branch in a wire, or a parallel sequence on the block diagram, the underlying LabVIEW executable tries to execute in parallel. In computer science terms, this is called “implicit parallelism” because you do not have to specifically write code with the purpose of running it in parallel; the language takes care of a certain degree of parallelism on its own.
The theoretical performance benefit of moving from a single- to dual-core computer is a two times improvement. But how close you get to that limit is a function of how much you can make your program execute in parallel. LabVIEW programmers naturally represent their solutions in a parallel nature. Initial benchmarks of a common representation of LabVIEW applications, without regard to multicore programming techniques, show applications automatically achieving 25 to 35 percent performance improvements with no changes to their code, simply because of the natural parallelism in common LabVIEW programs.
Figure 2 is an example of a simple application in which one branch in the LabVIEW code facilitates two analysis tasks – a filter operation and a fast Fourier transform (FFT) – for parallel execution on a dual-core machine. Not shown on the diagram is benchmarking code that runs the “for loop” once in single-core mode by turning off one of the cores, and then in normal dual-core mode. Because both tasks are computationally intensive, the improvement based on this task parallelism is an increase of 1.8 times.
Figure 2. A Typical LabVIEW Application Demonstrating Inherent Parallelism Due to Dataflow Programming
Text-based languages such as C express parallel code using a special notation in the code that creates parallel tasks (that is, to create unique threads). Managing these multithreaded applications can be a challenge.
In C, you must manage synchronization through locks, mutexes, atomic actions, and other advanced programming techniques. When multiple threads become hard to follow, common programming pitfalls can arise, such as the following:
- Inefficiencies due to too many threads
- Deadlock – threads become stuck waiting and cannot proceed processing
- Race conditions – the timing of code execution is not correctly managed and data is either not available when it needs to be or the correct data has been overwritten
- Memory contention – a problem associated with managing memory usage in your code
Because of these development challenges in C, LabVIEW programmers get a greater increase in productivity than ever before.