Table of Contents
- Introduction
- Multitasking versus Multithreading
- Why NI LabVIEW for Multicore Programming?
- RPI Human Object Transport Vehicle (HOT-V) – Use Case for Multicore Programming with LabVIEW
- Classes that Can Benefit from LabVIEW for Multicore Programming
- Research that Can Benefit from LabVIEW for Multicore Programming
Introduction
In today’s increasingly intelligent and connected world, microprocessors are everywhere – in cars, microwave ovens, cellular phones, and even golf balls. With this trend of embedding intelligence in so many devices, there is a parallel trend of converging complexities, wherein microprocessor-based systems are expected to perform tasks from multiple domains. Consider a car audio-video telematics system as shown in Figure 1.

Figure 1. An Automotive Telematics System with Multiple Functions
Today’s typical telematics systems handle navigation data, cellular phone calls, and DVD video playback in addition to the typical audio functions of earlier versions. While this is a wonderful trend for consumers, this presents an interesting problem to educators worldwide. Their students must now not only be able to program microprocessor systems but also be able to implement algorithms from domains other than their own.
While this trend seemed surmountable with languages using a higher level of abstraction, there is another trend that is becoming apparent – saturating clock speeds. Figure 2 shows the history of clock speeds for the past decade. Processor clock speeds have reached a point of saturation at about 3.5 GHz. With increasing demands on processing, this has led to the inevitable shift in paradigm for processors – multicore systems.

Figure 2. Trend of Saturating Clock Speeds for Microprocessors
This presents another issue for educators worldwide – finding software platforms that can help teach students to use multicore processor systems that present the smallest learning curve to program such architectures.
Multitasking versus Multithreading
Single-core systems are by nature multitasking, whereas multicore systems can provide true multithreading. So what is the difference between multitasking and multithreading? To examine multitasking, consider a single-core system that has four applications running, each of which spawns its own thread or process.

Figure 3. Multitasking in Single Core Systems
Because the system has a single core, the operating system becomes the gatekeeper and assigns these four processes periodically to the core for execution as shown in Figure 3. If each process takes 25 units of time to execute, then the total execution time for all the four tasks is 100 units.
Now consider a system that has four cores as shown in Figure 4. In this case, the same four applications running on the system and each application spawns its own thread and each thread takes 25 units of time to execute. However, in this case, the operating system recognizes that there are four cores and four threads. So it maps each thread to one core and all the threads run simultaneously, providing true multithreading.

Figure 4. True Multithreading in a Four Core System
In this case, the total time for all the four threads to execute is 25 units of time. A similar analogy can be drawn for dual-core and X-core systems.
Why NI LabVIEW for Multicore Programming?
Wikipedia defines dataflow languages as follows:
“Dataflow languages contrast with the majority of programming languages, which use the imperative programming model. In imperative programming, the program is modeled as a series of operations, the data being effectively invisible. This distinction may seem minor, but the paradigm shift is fairly dramatic and allows dataflow languages to be spread out across multicore, multiprocessor systems for free.”
National Instruments LabVIEW is a completely graphical programming language based on the dataflow paradigm. Figure 5 shows an example of a LabVIEW VI (programs written in LabVIEW are called virtual instruments or VIs). A LabVIEW VI has two parts to it – a front panel where engineers can build a custom UI and a block diagram where engineers can create the functionality for the program.

Figure 5. A LabVIEW VI
LabVIEW natively offers a multithreaded architecture. The LabVIEW compiler automatically divides any user program into two threads – a user interface thread and an execution thread. This ensures a smoother response when building interactive, multithreaded systems.
Because LabVIEW is based on the graphical dataflow paradigm, it is inherently parallel, making it easy to use multicore architectures. While this seems intuitive, it was not that important 20 years ago when sequential programming was much more dominant because programmers needed to execute code line by line.

Figure 6. Parallel Programming in LabVIEW versus C
However, with the advent of multicore systems, this approach is not feasible for everyone.
As a parallel programming use case, consider a system for acquiring data from two data acquisition cards simultaneously. Now consider specifying the loop rates for these two acquisition tasks and using a real-time clock on hardware (similar to an FPGA). One form of implementation in both LabVIEW and a text-based language such as C is shown in Figure 6. Because LabVIEW is a graphical programming language based on the dataflow paradigm and is inherently parallel, engineers just need to drop in two parallel loops and specify their loop rates using dialog boxes. Performing the same task in C on the other hand, can be quite involved. Thus, it is easier to take advantage of multicore systems using the LabVIEW graphical programming environment.
RPI Human Object Transport Vehicle (HOT-V) – Use Case for Multicore Programming with LabVIEW
The mechatronics course at Rensselaer Polytechnic Institute (RPI) is a multidisciplinary course between mechanical, electrical, computer, and control engineering. The goal of the student team was to build a Human Object Transport Vehicle (HOT-V) similar to the Segway system to improve human mobility and accessibility. The students had to build this system from design to prototyping and deployment in one semester (about 13 weeks).
Because this project focused on design, prototyping, and deployment, it helped teach students the concept of embedded design from the ground up. They had to use an FPGA-based target to implement the final system. To meet the tight deadline on this project, the students chose to use the LabVIEW graphical programming environment and designed their algorithms and tested it. Figure 7 shows a part of their control system that they modeled in LabVIEW.

Figure 7. Control System for HOT-V
Team members then prototyped their design on a tethered prototype that was connected to the computer as shown in Figure 8.

Figure 8. The First Prototype
After verifying that their simulation and design worked on the prototype, the students built their actual HOT-V transport system on an FPGA-based system, NI CompactRIO. Key points to note here is that the students in this team were from multiple disciplines and the majority of them were not embedded and parallel programming experts. But they were still able to program the system and leverage the parallel properties of the FPGA because they used LabVIEW.

Figure 9. HOT-V Final Implementation
The final design used CompactRIO – a hardware prototyping platform that is powered by an FPGA in the backplane and has a real-time operating system controlling the system. The FPGA and the real-time operating system can both be programmed graphically. Figure 9 shows the final version as a result of the project.
Classes that Can Benefit from LabVIEW for Multicore Programming
Because LabVIEW is a complete language, professors can use it to teach programming concepts in any class that needs a programming language. Some of the classes that benefit from using LabVIEW to teach multicore programming concepts are as follows:
Computer Architecture Classes
- Professors can use LabVIEW to illustrate the differences between single-core and multicore architectures with real-world examples.
- Students can use LabVIEW to program actual applications on multicore systems for their projects without having to learn complex parallel programming architectures.
Introduction to Programming Classes
- Because multicore systems are becoming a reality, using LabVIEW in introduction to programming classes to teach parallel programming concepts is an effective and efficient method to introduce multicore programming concepts to freshmen.
Embedded Design Classes
- Embedded architectures such as FPGAs are inherently parallel and can benefit from the dataflow paradigm of LabVIEW. Professors can use LabVIEW in these classes to teach embedded design concepts from simulation to actual deployment.
Research that Can Benefit from LabVIEW for Multicore Programming
Any research area that includes a lot of data and multiple computations that need to happen simultaneously can benefit from LabVIEW and a multicore architecture. Two areas that can benefit largely from LabVIEW are:
Nanotechnology
- Nanotechnology systems are based on the concept of heavy redundancy. This means that for the same computation, there are more than one – usually three – units that perform the computation in parallel. This is because of the high failure rate of components possible at the nanolevel. Using multicore architectures to simulate nanosystems with LabVIEW is an effective and efficient method to reduce development time and deliver accurate results.
Biomedical Engineering
-
Biomedical engineering research is characterized by high-resolution, high-data-rate systems that are computationally intensive to deliver results. Also, biomedical engineers are typically not C or C++ experts, making it difficult to adopt multicore systems. LabVIEW can deliver the power they need to perform their computations on multicore systems without the hassle of having to learn a new programming language.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
