LabVIEW Compiler Design

Publisher:Yuexiang888Latest update time:2011-06-30 Keywords:LabVIEW Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Compiler programming is a complex topic that requires a lot of expertise even for experienced software engineers.

NI LabVIEW software is a multi-disciplinary graphical programming environment that incorporates concepts including data flow, object-oriented, and event-driven programming. LabVIEW is also multi-platform and works well with a variety of operating systems (OSs), chipsets, embedded devices, and field programmable gate arrays (FPGAs). The LabVIEW compiler is a sophisticated system that has evolved dramatically over the past 20 years. Explore the NI LabVIEW compiler process and recent compiler innovations.

LabVIEW Compiler Process

The first step in compiling a VI is to expand the class, which is responsible for resolving implicit classes into types suitable for terminal output and checking for syntax errors. After class expansion, the VI is converted from the edit model to a dataflow intermediate representation (DFIR) graph that can be used by the compiler. The compiler performs several transformations, such as dead code removal, optimizations, and preparation for code generation during the decomposition of the DFIR graph. The DFIR is then converted into a low-level virtual machine (LLVM) intermediate representation (IR), and a series of scans are run on the IR to facilitate further optimization and throttling - ultimately - into machine code.

DFIR provides a high-level intermediate representation

DFIR is a hierarchical, block diagram code, graph-based IR. Similar to G-code, DFIR consists of many nodes with endpoints that can be connected to other endpoints. Some nodes, such as block diagrams, contain graphs, which can in turn contain other nodes.

Figure 1 shows the initial DFIR for a simple VI. When LabVIEW first creates a DFIR for a VI, it is a direct translation of the G-code, and the nodes in the DFIR graph have a one-to-one correspondence like the nodes in the G-code. As the compiler executes, DFIR nodes may be moved, partially separated, or added, yet the compiler will still preserve the original features, such as the inherent parallelism of the LabVIEW code.

View an initial DFIR graph of a simple VI www.elecfans.com

Figure 1. Viewing the initial DFIR graph of a simple VI

DFIR provides two significant advantages to the LabVIEW compiler:

1. DFIR separates the editor from the compiler representation - Before DFIR, LabVIEW had a single VI representation that was shared by the editor and compiler. This prevented the compiler from modifying the representation during compilation and made it difficult to introduce compiler optimizations. DFIR introduces a series of optimizations and decompositions that can greatly improve the performance of LabVIEW code, requiring only that the block diagram nodes and wires be disconnected and moved.

2. DFIR as a common connection point between the front-end and back-end of multiple compilers - Today, LabVIEW can handle many distinct tasks. Similarly, LabVIEW also provides users with multiple algorithmic modes, such as LabVIEW MathScript, C integration, simulation diagrams, and statecharts. DFIR provides a common IR that is generated by the front-end and used by the back-end, making it easier to reuse different combinations.

DFIR decomposition and optimization

Once in the DFIR, the VI runs a series of decomposition transformations to reduce or normalize the DFIR graph. After the DFIR graph is fully decomposed, the DFIR optimization pass begins. There are more than 30 decompositions and optimizations that can improve the performance of LabVIEW code. Take a close look at the simple VI shown in Figures 2 and 3, which is called the Trim Whitespace VI (Trim Whitespace.vi) from vi.lib.

2.png

Figure 2. This is the VI before any DFIR decomposition.

Trim Whitespace.vi Structure diagram definition www.elecfans.com

Figure 3. The above is the definition of the Trim Whitespace.vi structure diagram

First, Trim Whitespace.vi is inlined into the calling VI, as shown in Figure 4. Now, the unreachable code and dead code removal operations can simplify the code. The first case structure will always execute the same branch because the input is a constant value. Therefore, the remaining branches can be moved along with the entire second case structure because they are never executed. Loop invariant code motion moves the Match Pattern primitive out of the loop box, ensuring that it is only executed once, as shown in Figure 5.

Figure 4. The subVI is inlined into the calling routine, resulting in a DFIR graph equivalent to this G-code.

5.png

Figure 5. DFIR graph generated by an optimized execution [page]

DFIR backend transformation

After the DFIR graph is decomposed and optimized, the back-end transforms are executed. These transforms evaluate and annotate the DFIR graph in preparation for the final reduction to LLVM IR. The clumping routine is responsible for grouping nodes into clusters that can be run in parallel. The substitution routine identifies when allocated data can be reused and when a copy must be made. After the substitution routine runs, the allocator reserves the memory space required for the VI to execute. Finally, the code generator is responsible for converting the DFIR graph into executable machine instructions for the target processor.

LLVM provides a low-level intermediate representation

LLVM is a general-purpose, high-performance, open-source framework originally invented as a research project at Illinois State University. LLVM is widely used in academic research and industry because of its flexibility, simple API, and lack of licensing restrictions. In LabVIEW 2010, the LabVIEW code generator uses LLVM to generate target machine code. After creating the code stream from the DFIR graph, LabVIEW visits each instruction and creates an equivalent LLVM representation. The software activates various optimization passes, and finally, the LLVM just-in-time (JIT) framework creates executable machine instructions in memory. LabVIEW can now use LLVM to perform instruction synthesis, jump threading, scalar replacement of aggregates, conditional expansion, tail call elimination, loop invariant code removal, dead code elimination, and loop unrolling.

DFIR works with LLVM

DFIR is a high-level IR with parallelism, while LLVM is a low-level IR with awareness of the characteristics of the target machine. The two work together to optimize the LabVIEW code written by developers for the processor architecture so that they can be executed on the processor.

– Chris Wood

Chris Wood is a sensor software engineer working in LabVIEW at National Instruments. He holds a bachelor's degree in computer engineering from Texas A&M University.

– Craig Smith

Craig Smith is a principal software engineer at National Instruments. He holds bachelor's and master's degrees in computer science from Texas A&M University.

Keywords:LabVIEW Reference address:LabVIEW Compiler Design

Previous article:Design of Network Virtual Laboratory System Based on Virtual Instrument LabVIEW
Next article:Design of Engine Fuel Consumption Test System Based on LabVIEW

Recommended ReadingLatest update time:2024-11-17 04:33

Realization of USB real-time data acquisition and processing system based on LabVIEW
  Universal Serial Bus (USB) is a new type of data communication interface that is being used in more and more fields. Compared with traditional PCI cards and ISA cards, data acquisition cards based on USB interfaces have the advantages of plug-and-play, hot-swap, fast transmission speed, strong versatility, easy expan
[Test Measurement]
Realization of USB real-time data acquisition and processing system based on LabVIEW
Real-time data acquisition system based on LabVIEW and USB interface
1 Data acquisition system In engineering, computers with PCI, PXI, USB, parallel port and serial port are used to obtain test data, which is called PC-based data acquisition system. One of them is to directly obtain data and transmit it to the computer through a plug-in data acquisition card. In view of the hig
[Test Measurement]
Real-time data acquisition system based on LabVIEW and USB interface
LabVIEW in-depth exploration - performance comparison of local variables, attribute nodes and data flows
We know that in an independent VI, the value of an indicator can be changed through local variables, property nodes, and data flow. Local variables and property nodes can be used for both controllers and indicators. Data flow cannot directly transfer data between two indicators. The following three methods of tran
[Test Measurement]
LabVIEW in-depth exploration - performance comparison of local variables, attribute nodes and data flows
Design of Remote Power Quality Monitoring System Based on Network
0 Introduction With the systematization, intelligence, automation and networking of power system operation and management, remote real-time monitoring and automatic debugging of power grids are the inevitable trend of power system development. In recent years, with the continuous growth of people's demand f
[Power Management]
Using LabVIEW and NI Single-Board RIO to Build a Smart Grid Monitoring System
The smart grid unit we developed using NI Single-Board RIO is a reliable and cost-effective solution that is uniquely flexible and ideal for building automation systems. Using NI hardware and software platforms gives us a technical advantage, and NI also provides excellent local technical support during the system dev
[Test Measurement]
Using LabVIEW and NI Single-Board RIO to Build a Smart Grid Monitoring System
LabVIEW releases EXE containing shared variables and solves related problems
RT, the following error is reported during generation. Solution:
[Test Measurement]
LABVIEW in-depth exploration of the MDB database writing speed issue.
Recently in the LABVIEW group, I saw several discussions about using queues to write collected data into the database. The discussions were very lively, but they overlooked an important issue, which is the maximum write speed of the database. Once the number of samples per second exceeds a certain limit, no matter wha
[Test Measurement]
LABVIEW in-depth exploration of the MDB database writing speed issue.
Labview programming skills-----special effects production of text
Today I will introduce several methods for making special effects for Chinese characters in GUI. 1. How to change the color and font of part of the text: We know that it is easy to change the font and color of the text uniformly, but if you only change part of the font and color, you need some skills. 2. Sp
[Test Measurement]
Labview programming skills-----special effects production of text
Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号