LabWindows/CVI User Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI Tip: Compile LabWindows/CVI code with Clang Optimizing Compiler

Creating Optimized Code

The LabWindows/CVI compiler does not create optimized code. You can create optimized code by compiling LabWindows/CVI source code using an external optimizing compiler. To compile in an external compiler, you must set up a compiler configuration, which contains information about the external compiler and compiler options to use. You can specify a compiler configuration on an environment-wide or per-project basis.

Definition - Optimizing Compiler: using various optimization techniques, outputs code that minimizes or maximizes specific attributes of the executable program. Most commonly minimizes the time taken to execute the program and less commonly minimizes the amount of memory occupied. Examples of common optimization techniques can be found in this wikipedia article.

How to use the Clang External optimizing compiler

Third party optimizing compilers can be downloaded from Intel or Microsoft. The Clang 1.0 optimizing Compiler is the only external compiler that is installed with LabWindows/CVI 2010. To use this or any other external compiler with CVI, you must first create a configuration file (.ecc) for it. There is a template for the Clang compiler's configuration, so you can simply select this template from the Template Configuration ring. Once you have this configuration, it should be selectable in the compiler ring.

To create a configuration file (.ecc) from a template:

  1. Navigate to Options»Build Options.
  2. Click on the Build Process Options tab.
  3. In the Compiler for Release Configurations section select New from the Active xx-bit compiler ring.
  4. Name the configuration and the configuration file (image below).
  5. Select the Template Configuration as clang 1.0 (clang-cc.exe) (template) (image below).

select Clang.PNG

Now you can select your new compiler configuration and use the Clang optimizing compiler

Compiler added.PNG

Considerations for Creating Optimized Code

You can use an external compiler to compile code for a LabWindows/CVI project only if the project is in the release configuration. LabWindows/CVI always uses its own compiler to compile any debuggable code. Be sure to take a look at this list of other factors to consider when creating or editing a compiler configuration.

A bit about Clang and LLVM

Clang is the C language front end to the LLVM compiler, which is a free, open source optimizing compiler. "LLVM began as a research project at the University of Illinois, with the goal of providing a modern, SSA-based compilation strategy capable of supporting both static and dynamic compilation of arbitrary programming languages.  Since then, LLVM has grown to be an umbrella project consisting of a number of different subprojects, many of which are being used in production by a wide variety of commercial and open source projects as well as being widely used in academic research." -- read more about the LLVM project at www.llvm.org

Additional Resources

LabWindows/CVI Help on Creating Optimized Code

Did you find this tip useful? Rate this document or add a comment below.

If you give this a try, share your experience! Add a comment below.


National Instruments
Contributors