Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Instrumentation Newsletter
NI Supported: Yes
Publish Date: May 6, 2008


Feedback


Yes No

Related Links - Developer Zone

Related Links - Products and Services

LabVIEW 8.5 Brings the Power of Multicore Processors to Engineers and Scientists

18 ratings | 4.06 out of 5
Read in | Print

Processor speeds have hit a wall in recent years.

 

Moore’s Law, which states that the number of transistors on a chip will double every 18 to 24 months, still holds true as it has for the last 40 years, but it no longer translates into a linear increase in performance. Previously, chip manufacturers increased processor clock speed to double chip performance – from 100 to 200 MHz and more recently into the multi-Gigahertz (GHz) range.

 

Today, however, increasing clock speeds for performance gains is not viable because of power consumption and heat dissipation constraints. Chip vendors have instead moved to entirely new chip architectures with multiple processor cores on a single chip. With multicore processors, programmers can complete more total work than with one core alone. However, to take advantage of multicore processors, programmers must reconsider how they develop applications. In the words of Herb Sutter, Microsoft software architect, the “free lunch is over” for developers who expect to see immediate software application performance gains when end users simply upgrade their computers to ones with faster processors. In short, programmers now have to work for continued performance improvements.

 

Sequential programs saw performance improvements as a result of processor clock speed increases; upgrading to a computer with a faster CPU meant that each individual instruction in a series would run faster. To continue seeing performance gains with multicore systems, developers need to design their applications to divide the work among cores – in essence develop a parallel application instead of a sequential one.

 

 

Figure 1. LabVIEW code is inherently parallel.

 

 

Fortunately, National Instruments LabVIEW software is well suited for engineers and scientists to fully exploit the processing power of multicore chips, for three primary reasons:

 

1. LabVIEW is a graphical, dataflow programming language. Developers can easily visualize parallel tasks in LabVIEW, making it possible to develop new applications and modify existing applications to take advantage of multicore processors. LabVIEW has been multithreaded since Version 5.0, and now, Version 8.5 introduces new enhancements for taking advantage of multicore processors.

 

2. LabVIEW brings multicore performance to embedded real-time hardware. LabVIEW 8.5 brings the automatic multitasking capability found on desktop operating systems such as Windows and Linux® – known as symmetric multiprocessing (SMP) – to deterministic, real-time systems.

 

3. LabVIEW sits on top of a “multicore-ready” software stack. Each layer of a LabVIEW application (for example, LabVIEW application code, low-level functions, and I/O drivers) is thread-safe to take advantage of multicore processors.

 

LabVIEW Is a Graphical, Dataflow Programming Language

 

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 code has a branch in a wire, or a parallel sequence on the block diagram, the underlying LabVIEW compiler tries to execute the code 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 graphical language of LabVIEW 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 parallel. Initial benchmarks of common LabVIEW applications, without regard to multicore programming techniques, show applications achieving 15 to 20 percent performance improvements with no changes to their code.

 

Figure 1 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. Because both tasks are computationally intensive, the improvement from executing on one core versus two cores is an increase of 1.8 times.

 

Developers using traditional text-based tools must use complex coding structures, called threads, to implement parallelism in these sequential languages. 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 – multiple threads try to access memory at the same time

 

After code development, another example of increased productivity is the ability to perform basic debugging in LabVIEW with highlight execution and probes, as shown in Figure 2.

When commenting on LabVIEW for multicore development, Scott Sirrine, lead product engineer at Eaton Corporation, said, “The fact that LabVIEW is a dataflow language with automatic multithreading presents two key advantages over other programming languages – development productivity and execution performance.”

 

Although LabVIEW takes care of many multicore development challenges, there are still cases in which you can further improve system performance by employing optimization strategies in the code.

 


[+] Enlarge Image

 

 

Figure 2. Increase your productivity in LabVIEW while debugging parallel code with highlight execution and probes.

 

 

Three example strategies include the following:

  • Task parallelism – dividing your program into parallel executing tasks
  • Pipelining – dividing sequential algorithms into equal stages that are split among multiple cores
  • Data parallelism – dividing large data sets into subsets and operating on them in parallel

 

You can find examples of each of these optimization techniques at ni.com/multicore.

 

LabVIEW Brings Multicore Performance to Real-Time Embedded Hardware

 

Engineers have historically relied on tools that are not optimized for the parallel programming required to take advantage of embedded multicore systems. LabVIEW 8.5 brings the automatic multithreading scheduler from the desktop – known as SMP – to deterministic, real-time systems.

 

 

 

 

Software Stack

The Meaning of “Multicore-Ready”

LabVIEW Support

Development tool

Support provided on the operating system of choice;  tool facilitates correct threading and optimization

ü  Yes

 

Example: Multithreaded nature of LabVIEW and structures that allow for optimization

Libraries

Thread-safe, reentrant libraries

ü  Yes

 

Example: BLAS math libraries

Device drivers

Drivers architected for optimal multithreaded performance

ü  Yes

 

Example: NI-DAQmx driver software

Operating system

Operating system supports multithreading and multitasking and can load balance tasks

ü  Yes

 

Example: Support for Windows, Mac OS, Linux, and LabVIEW Real-Time operating systems

 

Table 1. LabVIEW is ideal for parallel programming due in part to a top-to-bottom multicore-ready software stack.

 

 

The LabVIEW 8.5 Real-Time Module adds first-class multicore system support with the following features:

  • You can perform automatic load-balancing across multiple cores (SMP) on embedded real-time systems
  • For time-critical sections of code, you now can assign timed loops to specific processor cores (processor affinity) to isolate key sections of code in a timed loop structure from the rest of your application
  • With the Real-Time Execution Trace Toolkit 2.0, you can easily visualize the threads and processor cores upon which your VIs are running to fine-tune your real-time systems for optimal performance

 

LabVIEW Sits on Top of a “Multicore-Ready” Software Stack

Intel has defined four layers of the software stack that you should evaluate to determine readiness” for multicore development. These four layers are operating system, device drivers, applications/libraries, and development tools. Parallel programs do not run faster on multicore systems if the libraries and drivers you are using are not multicore-ready or if the operating system cannot load-balance tasks across multiple cores.

 

An example at the device driver software layer is NI-DAQmx driver softwareTraditional NI-DAQ (Legacy) is thread-safe, meaning the entire library blocks other threads from calling into it when an NI-DAQ function is called. At first glance, this behavior may appear logical because NI-DAQ is used to control hardware, which is often thought of as a single resource. NI-DAQmx, the reengineered modern DAQ driver, is reentrant – meaning multiple DAQ tasks can execute in parallel without blocking threads in a truly parallel fashion. With this approach, the driver assists your application in running multiple tasks in parallel on the same board, such as analog and digital I/O independently.

 


[+] Enlarge Image

 

Figure 3. Take advantage of LabVIEW 8.5 Real-Time support and visual debugging capabilities with the Real-Time Execution Trace Toolkit 2.0.

 

 

LabVIEW – The Ideal Parallel Programming Language

Most consumers will see some benefit from multicore systems with the improved ability to run multiple applications (e-mail, video, word processing, and more) at the same time, which is known as multitasking. However, this provides little benefit for a developer looking to optimize a single application.

 

Engineers and scientists looking for faster measurements for test, or improved loop rates in control applications, need to consider how they can implement parallel applications. With LabVIEW, you can take advantage of a software environment that is ideal for parallel programming because of the dataflow nature of the language, multicore support for embedded platforms developed with LabVIEW Real-Time, and a top-to-bottom multicore-ready software stack.

 

– Jeff Meisel 

Jeff Meisel is the product manager for the LabVIEW Real-Time Module. He holds a Bachelor of Science in computer engineering from Kansas State University.

 

Learn more about implementing solutions using these techniques in LabVIEW.  

 

 

Multicore-Related Features in LabVIEW 8.5

 

LabVIEW is already ahead of the game for programming multicore systems due to its inherent parallelism; however, key enhancements in Version 8.5 further optimize multicore performance.

 

Performance

  • Improved scheduling and thread control
  • Multicore support for LabVIEW Real-Time with real-time symmetric processing (SMP)

 

Algorithm and Memory Optimizations

  • BLAS algorithm compatibility for creating optimized math and signal processing applications
  • Improved memory management functions

 

Application Development

  • Trace-based visualization for debugging

 

 

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

 

This article first appeared in the Q3 2007 issue of Instrumentation Newsletter.

 

18 ratings | 4.06 out of 5
Read in | Print

Reader Comments | Submit a comment »

Very good article! Is there some multicore processor main board, that have been approved or certified to work best with LabVIEW 8.5 ? What hardware ( CPU, RAM,...) would give the best performance of LabVIEW 8.5 with PCI-6111 and PCI-6221 use at their full acquisition speed? Thank's Bernard
- Boulanger Bernard, Cégep Saint-Jean-sur-Richelieu. bernard.boulanger@cstjean.qc.ca - Aug 8, 2007

 

Legal
This material is protected under the copyright laws of the U.S. and other countries and any uses not in conformity with the copyright laws are prohibited, including but not limited to reproduction, DOWNLOADING, duplication, adaptation and transmission or broadcast by any media, devices or processes.