Data Flow Programming and LabVIEW Multicore Programming

Because NI LabVIEW is a data flow programming language, developers can write parallel applications that map directly to parallel hardware (such as multi-core processors and FPGAs) for maximum performance. This white paper discusses what data flow programming is and why NI LabVIEW is the first choice for multicore system programming.

为什么LabVIEW可用于多核编程

1. The free lunch is over

In recent years, the speed of the processor has encountered a bottleneck. Moore's Law shows that the number of transistors in a chip doubles every 18 to 24 months. This has been consistent for the past 40 years, but the performance of the chip is no longer linear. In the past, chip manufacturers have increased the performance of their chips by increasing the clock speed of the processor, from 100MHz to 200MHz to the nearest GHz range.

But today, due to power and heat limitations, increasing the clock speed to increase performance does not work. Chip vendors are turning to another new chip architecture that integrates multiple processor cores on a single chip. Compared to single-core processors, programmers can use multi-core processors to do more tasks. In order to take full advantage of multi-core processors, programmers need to rethink the way they develop applications. Herb Sutter, a software designer at Microsoft, once said that "free lunches are over" for developers who want end users to simply upgrade their computers to faster processors and see immediate performance gains. In short, software development is like this for quite some time, but things are different now.

Figure 1 Moore's Law shows that processor speeds can't be faster, so chip makers such as Intel and AMD are turning to ways to integrate multiple cores on a single processor.

Figure 1 Moore's Law shows that processor speeds can't be faster, so chip makers such as Intel and AMD are turning to ways to integrate multiple cores on a single processor.

Programs that are executed sequentially will improve performance as the processor speeds up. Upgrading the computer to a faster CPU means that each individual instruction in a sequence will run faster. In order to continue to achieve performance gains in multi-core systems, you need to design an application that distributes tasks between cores, essentially developing parallel applications to replace sequential execution.

2. LabVIEW - a graphical data streaming programming language

The main advantage of developing an application in LabVIEW is that the language is intuitive and graphical. In LabVIEW, users solve engineering problems just like drawing a block diagram on paper. Modern multi-core processor technology makes LabVIEW a more suitable programming tool because of its ability to parallelize and execute tasks.

LabVIEW's data flow features make LabVIEW actuators try to execute programs in parallel if there are branches in the wire or if there are parallel sequences in the block diagram. In computer science terminology, this is called "potential parallelization" because you don't need to explicitly write parallel code based on the need to run in parallel, and the programming language itself will do some degree of parallelism.

From a single-core to a dual-core computer, in theory, the performance achieved should be twice as large. However, the extent to which this limit is close depends on the degree of parallelism in which the user application runs. LabVIEW programmers can easily represent their solutions in parallel. For ordinary LabVIEW applications, if you do not consider multi-core programming technology, you can get 25% to 35% performance improvement compared to the original program without rewriting the code, which is due to ordinary LabVIEW. The parallel nature of the program.

Figure 2 is an example of a simple application. Among them, the branch in LabVIEW code simplifies two analysis tasks - a filter operation and a fast Fourier transform (FFT) - so that they can be executed in parallel on a dual-core machine. The performance test code is not shown in the chart. It first runs "for loop" once in single-core mode (turns off one of the cores) and then runs in dual-core mode. Because both tasks are computationally intensive, the performance improvement achieved with task parallelization is 1.8 times higher.

Figure 2 A typical LabVIEW application that demonstrates the inherent parallelism of data flow programming.

Figure 2 A typical LabVIEW application that demonstrates the inherent parallelism of data flow programming.

Text-based programming languages ​​such as C, etc., use special tags in code to represent parallelized code, creating parallel tasks (that is, creating separate threads). Managing these multi-threaded applications will be a challenge.

In C, users must manage synchronization using lock operations, mutexes, atomic operations, and other advanced programming techniques. When multithreading becomes difficult to track debugging, the usual programming pitfalls arise as follows:

• Inefficiency due to too many threads.

• Deadlocks—Threads are waiting for some and cannot be processed.

• Competitiveness—The timing of code runs is not properly managed. When data is needed, the data is either unprepared or overwritten.
• Memory conflicts — issues related to memory management in the code.

With these challenges in developing with C, LabVIEW programmers can achieve greater efficiencies than ever before.

3. LabVIEW is supported by real-time SMP and is at the top of the “MulTIcore Ready” software layer.

Intel defines four levels of software that users need to evaluate to determine the availability of multicore systems. Parallel programs do not run faster on multicore systems if the application libraries and device drivers used are not designed for multicore or if the operating system is not load balanced across multiple cores.

Why LabVIEW can be used for multicore programming

Figure 3 Software Level Description of “MulTIcore Ready”

An example of a device driver software layer is the NI-DAQmx driver software. Traditional NI-DAQ is "thread safe", meaning that when an NI-DAQ function is called, the entire library function blocks calls from other threads.

From the first point of view, this is very logical, because NI-DAQ is used to control hardware, and hardware is generally considered to be an exclusive resource. NI-DAQmx is an improved design of the new DAQ driver that is reentrant, meaning that multiple DAQ tasks can run in a truly parallel manner without blocking threads.

With this approach, the driver can run multiple independent tasks on the same device, such as analog and digital inputs/outputs.

Operating systems, as the underlying software hierarchy, many real-time operating system (RTOS) vendors do not currently support automatic thread load balancing across multiple processor cores.

LabVIEW 8.5 extends the LabVIEW Real-Time Module to bring the automatic multi-threaded scheduler on the desktop to deterministic real-time systems, also known as symmetric multitasking (SMP).

4 Conclusion

If you need faster measurement speeds or need to improve the loop rate in your control application, consider how you can implement parallel applications. LabVIEW 8.5 adds more features to the multithreading feature, which was first introduced in version 5 of 1998. With LabVIEW software, users can take advantage of the software environment they provide due to their data flow programming features, multi-core support for embedded platform development with LabVIEW Real-TIme tools, and top-down software layers designed for multicore. Is the first choice for parallel programming.

Outdoor Front-service Iron Case Led Wall

Outdoor Front-Service Iron Case Led Wall,Led Display Billboards,Digital Led Display,Advertising Led Wall Media Production

Guangzhou Cheng Wen Photoelectric Technology Co., Ltd. , https://www.cwledwall.com