EECS Berkeley EE249 LabVIEW Framework. Hugo A. Andrade Principal Architect LabVIEW Platform & Real Time Group

Similar documents
EE249 Lab September 30 h, 2008 Hugo A. Andrade

LabVIEW Programming for a Multicore Environment. Stefan Kreuzer Applications Engineer National Instruments

Graphical System Design:

Parallel Programming Multicore systems

Introduction to LabVIEW and NI Hardware Platform

Designing Real-Time Control Applications Using LabVIEW and CompactRIO. Developer Days 2009

LabVIEW Basics I: Introduction Course

CHAPTER 3 LabVIEW REAL TIME APPLICATION DEVELOPMENT REFERENCES: [1] NI, Real Time LabVIEW. [2] R. Bishop, LabVIEW 2009.

Integrating Data Acquisition and Instrument Control with Your Scilab Scripts

Tips for Code Re-Use. Rejwan Ali, Marketing Engineer NI Africa and Oceania

Benefits of Programming Graphically in NI LabVIEW

Benefits of Programming Graphically in NI LabVIEW

Developing Measurement and Control Applications with the LabVIEW FPGA Pioneer System

LabVIEW 2009 Real-Time & FPGA 最新技術剖析. National Instruments 美商國家儀器 行銷部技術經理吳維翰

Graphical System Design. David Fuller LabVIEW R&D Section Manager

FPGA design with National Instuments

Agenda. Programming FPGAs Why Are They Useful? NI FPGA Hardware Common Applications for FPGAs How to Learn More

LabVIEW programming II

LabVIEW programming II

ni.com What s New in 2013

Graphical System Design Platform. NI LabVIEW. Test and Measurement Industrial Measurements and Control Embedded Design. ni.

High-Level Synthesis with LabVIEW FPGA

What You ll Do Today. Learn LabVIEW fundamentals Acquire temperature signal Output warning light based on alarm level Write data to file

PC-based data acquisition I

Simplify System Complexity

What You ll Do Today. Learn LabVIEW fundamentals Acquire temperature signal Output warning light based on alarm level Write data to file

Graphical System Design

LabVIEW Graphical Programming

LabVIEW FPGA in Hardware-in-the-Loop Simulation Applications

Improving the Performance of your LabVIEW Applications

COTS Technology for High Energy Physics Instrumentation Dr. James Truchard President, CEO, and Cofounder National Instruments

LabVIEW programming I

LabVIEW Graphical Development Hands-On Seminar

Software-Defined Test Fundamentals. Understanding the Architecture of Modular, High-Performance Test Systems

Taking Advantage of Multicore Technology. Jeff Meisel, Real-Time and Embedded Group, National Instruments

NI Smart Cameras PRODUCT FLYER CONTENTS. Have a question? Contact Us.

Running OPAL-RT s ehs on National Instruments crio: Sub-microsecond power-electronic simulation

Communication Systems Design in Practice

Final Exam Study Guide

Introduction to Embedded Systems

Simplify System Complexity

FlexRIO. FPGAs Bringing Custom Functionality to Instruments. Ravichandran Raghavan Technical Marketing Engineer. ni.com

How Real-Time Testing Improves the Design of a PMSM Controller

ni.com Integrating EPICS and LabVIEW

Virtual Instrumentation With LabVIEW

SE300 SWE Practices. Lecture 10 Introduction to Event- Driven Architectures. Tuesday, March 17, Sam Siewert

Communication Systems Design in Practice

Today. 4/5/11 Physics 262 Lecture 10 Questions about Exams Homework. Lab: Continue project. Lecture. Review your exams and review practice exam again.

David R. Mackay, Ph.D. Libraries play an important role in threading software to run faster on Intel multi-core platforms.

Mounzer saleh Applications engineer Tel:

Measurement & Automation Explorer (MAX) View and control your devices and software

Developing Measurement and Analysis System using MATLAB

Data Communication in LabVIEW

Lecture 1 Introduction to Microprocessors

Graphical System Design for Machine Control

Increase Your Test Capabilities with Reconfigurable FPGA Technology

NI Linux Real-Time. Fanie Coetzer. Field Sales Engineer SA North. ni.com

National Instruments Approach

Simulation in LabVIEW. Hans-Petter Halvorsen, M.Sc.

MOIS Overview. 1. Developer Walkthrough

Best Practices for Architecting Embedded Applications in LabVIEW Jacques Cilliers Applications Engineering

Model-Based Design for effective HW/SW Co-Design Alexander Schreiber Senior Application Engineer MathWorks, Germany

Introduction to Automating Standalone Instruments

ni.com/training Quizzes LabVIEW Core 1 ni.com/training Courses Skills learned: LabVIEW environment Certifications Skills tested: LabVIEW environment

Using COTS Hardware with EPICS Through LabVIEW A Status Report. EPICS Collaboration Meeting Fall 2011

Building a Next Generation Data Logging System

VALLIAMMAI ENGINEERING COLLEGE

The Internet of Things and Factory of Future

ni.com Best Practices for Architecting Embedded Applications in LabVIEW

New Software-Designed Instruments

LabVIEW Release Notes

Don t Think You Need an FPGA? Think Again!

ni.com Preparing for the CLAD Exam

Analytical Instrumentation

NI LabView READ THIS DOCUMENT CAREFULLY AND FOLLOW THE INSTRIUCTIONS IN THE EXERCISES

Graphical System Design For Large Scale Deployments. Bhavin Desai Technical Consultant

Analytical Instrumentation

Virtual Instrumentation With LabVIEW

LabVIEW programming I

Approach to Enable Real-Time HPC. President, CEO and Cofounder National Instruments

Application State Machine

LabVIEW Graphical Development Platform. Part I An Open Platform for Long-Term Continuity

Control System Design and Rapid Prototyping Using Simulink Chirag Patel Sr. Application Engineer Modeling and Simulink MathWorks India

Simplifying the Development and Debug of 8572-Based SMP Embedded Systems. Wind River Workbench Development Tools

Create Without Limits: Add the Power of User-Programmable FPGAs to Your Test Applications

Dept. of Electrical, Computer and Biomedical Engineering. Data Acquisition Systems and the NI LabVIEW environment

Short Term Courses (Including Project Work)

LabVIEW control solutions on Mac. Christophe Salzmann. Ecole Polytechnique Fédérale de Lausanne - Switzerland

Data Acquisition Laboratory

How to validate your FPGA design using realworld

Integrated Simulation and Hardware-test Environment for Microcontroller Development

FYS Data acquisition & control. Introduction. Spring 2018 Lecture #1. Reading: RWI (Real World Instrumentation) Chapter 1.

ReconOS: An RTOS Supporting Hardware and Software Threads

Essential Technologies for Industrial Machine Design and Prototyping

Tomasz Włostowski Beams Department Controls Group Hardware and Timing Section. Developing hard real-time systems using FPGAs and soft CPU cores

Chapter 4: Multi-Threaded Programming

System-level Synthesis of Dataflow Applications for FPGAbased Distributed Platforms

Tasks and Objectives: Certified LabVIEW Architect

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD QUESTION BANK

DSP/BIOS Kernel Scalable, Real-Time Kernel TM. for TMS320 DSPs. Product Bulletin

Transcription:

EECS Berkeley EE249 LabVIEW Framework Hugo A. Andrade Principal Architect LabVIEW Platform & Real Time Group

Agenda Overview of NI Tools LabVIEW Intro Framework Parallel programming From multi-core to many-core

National Instruments Profile Leaders in Computer-Based Measurement and Automation Strong Track Record of Growth and Profitability Asia 21% Europe 31% Americas 48% $740 MM Revenue in FY2007 Past nine consecutive years voted Fortune s 100 Best Companies to Work For in America Headquartered in Austin, Texas More than 4,000 employees; operations in 40+ countries

Diversity of Customers Customers are mainly domain experts, scientists and engineers Top 100 customers 35% of revenue More than 25,000 customers in more than 90 countries 95% of Fortune 500 manufacturing companies have adopted Virtual Instrumentation

Diversity of Industries Telecom Automotive Semiconductors Electronics Computers ATE Military/Aerospace Advanced Research Petrochemical Food Processing Textiles

Virtual Instrumentation

Virtual Instrumentation Hardware and Driver Software Application Software

Virtual Instrumentation Applications Analysis and Design Simulation Signal and Image Processing Embedded System Programming (PC, DSP, FPGA, Microcontroller) A single graphical development platform Prototyping And more Control Automatic Controls and Dynamic Systems Mechatronics and Robotics And more Measurement/Test Circuits and Electronics Measurements and Instrumentation Design Prototype Deploy

LabVIEW Graphical Development System Graphical Programming Environment Compile code for multiple OS and devices Useful in a broad range of applications

LabVIEW LabVIEW Background and Intro Facets Measurement and Automation (Instrument Control, I/O, DAQ, etc. General purpose computing environment for scientists and engineers Modeling Environment Framework for Domain Experts Embedded Development Environment Framework for Parallel Programming Techniques

LabVIEW 8.6 Multiple Programming Models Distributed Multi-core Systems

LabVIEW Virtual Instrument Front Panel Block Diagram

Introduction to LabVIEW and Dataflow 14

The G (LabVIEW) Language Model Homogenous dataflow language Structured case (switch, select), loops, timed specs Structured dataflow Turing complete Run-time scheduling Inherently parallel language Synthesizable language Direct compilation to software binaries on host processors Embedded Processors (via C) To FPGAs (via VHDL)

Section Outline: LabVIEW and Dataflow 1. Introduction to the LabVIEW environment 2. Functions and hierarchy 3. Dataflow and parallelism

What is LabVIEW? Programming language: graphical programming based on structured dataflow Complete development environment: project explorer, debugging tools, source code control, and more 17

Parts of a LabVIEW Application Block diagram shows graphical source code Front panel contains graphical user interface (GUI) items (connected to source code) 18

Block Diagram: Source Code Block diagram can contain functions, structures, and constants Analogous to functions, subroutines, flow control elements, and constants in text-based languages Terminals represent inputs and outputs 19

3 Types of Functions (from the Functions Palette) Express VIs: interactive VIs with configurable dialog page (blue border) Standard VIs: modularized VIs customized by wiring (customizable) Functions: fundamental operating elements of LabVIEW; no front panel or block diagram (yellow)

What Types of Functions are Available? Input and Output Signal and Data Simulation Acquire and Generate Real Signals with DAQ Instrument I/O Assistant (Serial & GPIB) ActiveX for communication with other programs Analysis Signal Processing Statistics Advanced Math and Formulas Continuous Time Solver Storage File I/O Express Functions Palette

Cross-Platform Graphical Programming Graphical Source Code Compiled Code (binary) 22

LabVIEW Deployed Wireless Sensors Smart Cameras Embedded (FPGA) Wireless Networked I/O Handheld PC Boards Industrial Computer (PXI) Touch Panel Tektronix Open Windows Oscilloscopes Portable Workstation 23

Block Diagram: Functions Palette Contains programming structures and functions Contains specialized IP, including math libraries built on Intel Math Kernel Library (MKL) 24

Front Panel: Controls Palette Controls (inputs): menus, text entry, selectors, buttons, etc. Indicators (outputs): graphs, LEDs, charts, and other displays 25

Hierarchy in LabVIEW A LabVIEW subvi is a VI that is called inside of another VI A subvi s inputs and outputs (parameters) are exposed and accessed on the block diagram Similar to a function or subroutine in text-based programming 26

Dataflow Programming Block diagram execution Dependent on the flow of data Block diagram does NOT execute left to right Node executes when data is available to ALL input terminals Nodes supply data to all output terminals when done

Dataflow and Parallel Execution Dataflow programming means inherent parallelism in your application Parallel code sections in a dataflow program can be easily visualized 30

Dataflow and Parallel Execution Program massively parallel hardware with LabVIEW FPGA Same approach as programming CPUs, only code executes directly in hardware 31

Simple LabVIEW G Demo National National Instruments Confidential

Abstraction Increasing Levels of Hardware Abstraction System-on-Chip (SoC) Very Large Scale ICs (VLSI) Integrated Circuits (IC) Transistors Vacuum Tubes System complexity

Abstraction Increasing Levels of Software Abstraction System design platform Object Oriented Lang. (C++) Procedural Lang. (C) Assembly language Machine code System complexity

High-Level Development Tools Data Flow C Code Textual Math Modeling Statechart Graphical System Design Platform Linux Macintosh Windows Real-Time FPGA Micro Desktop Platform Embedded Platform

LabVIEW Targets Scalable from distributed network to sensors Sensor DSP/MPU FPGA Handheld Vision System Embedded Controllers Industrial Controllers (PXI) Portable PC

LabVIEW on crio - HW CompactRIO Real-Time Processor Reconfigurable FPGA Industrial I/O Modules Industrial I/O Modules with built-in signal conditioning for direct connection to sensors/actuators Reconfigurable FPGA for high-speed and custom I/O timing, triggering, control Real-Time Processor for deterministic, stand-alone operation and advanced analysis

LabVIEW on crio Logical Diagram Windows PC LabVIEW Real-Time System Reconfigurable FPGA Windows User Interface Host VI Network Communication Normal Priority VI Inter-Thread Communication Time-Critical Interface VI FPGA Interface LabVIEW FPGA VI Enterprise Data Storage LabVIEW for Windows LabVIEW Real-Time LabVIEW FPGA

LabVIEW on crio SW and Some Ideas AI 0 Pin SPI FPGA PCI(e) RT CPU Ethernet Host CPU Elemental IO DMA FIFO Network Variable FPGA Loop RT Loop Host Loop

High-Level Development Tools Data Flow C Code Textual Math Modeling Statechart Graphical System Design Platform Linux Macintosh Windows Real-Time FPGA Micro Desktop Platform Embedded Platform

LabVIEW as a Framework Demo Express VI Demo Vision Assistant Metal example Demo Motion Assistant

Textual Math in LabVIEW Integrate existing scripts with LabVIEW for faster development Interactive, easy-to-use, hands-on learning environment Develop algorithms, explore mathematical concepts, and analyze results using a single environment Freedom to choose the most effective syntax, whether graphical or textual within one VI Supported Math Tools: MathScript script node Mathematica software Maple software MathSoft software MATLAB software Xmath software MATLAB is a registered trademark of The MathWorks, Inc.

Math with the MathScript Node Implement equations and algorithms textually Input and Output variables created at the border Generally compatible with popular m-file script language Terminate statements with a semicolon to disable immediate output (Functions»Programming» Structures»MathScript) Prototype your equations in the interactive MathScript Window.

The Interactive MathScript Window Rapidly develop and test algorithms Share Scripts and Variables with the Node View /Modify Variable content in 1D, 2D, and 3D Output Window Variable Workspace View/Modify Variable Contents m-file Script User Commands (LabVIEW»Tools»MathScript Window)

Developing Applications with the NI LabVIEW Statechart Module

What are Statecharts? System Inputs Outputs Statecharts are visual representations of reactive (event-based) systems.

Differences between Statecharts and FSMs Both contain the same basic concepts: States Transitions Statechart adds additional concepts: Hierarchy Concurrency Event-based paradigm Based on the UML statechart diagram specification Pseudostates & Connectors H Button Press

Reactive Systems Communication systems Digital protocols Control applications Sequential logic Batch processing Event response Non-linear control State Machines User-interface implementation System modeling for virtual prototyping (simulation)

Statechart Benefits Abstraction Simple semantics to represent complex systems System-level view Self-documenting

Machine & Process Control hierarchy concurrency

FPGA Logic hierarchy

User Interfaces history

Statechart Benefits Abstraction Simple semantics to represent complex systems System-level view Self-documenting Scalability Easily extend applications Open software platform Automatic Code Generation LabVIEW Embedded Technology

LabVIEW Simulation Module Develop dynamic systems such as motor controllers and hydraulic simulators with LabVIEW Implement your dynamic systems with real-time I/O using built-in LabVIEW data acquisition functions Simulate linear, nonlinear, and discrete systems with a wide array of solvers Deploy dynamic systems to real-time hardware with the NI LabVIEW Real-Time Module Translate models from The MathWorks, Inc. Simulink into LabVIEW with built-in utility

The Design Process 1. Modeling Identify a mathematical representation of the plant 2. Control Design Choose a control method and design a controller 3. Simulation Employ a point-by-point approach to simulate the system timing with a solver 4. Tuning and Verification Introduce real-world nonlinearities, tune, and verify the control algorithm 5. Deployment Implement the finalized control system

The Simulation Loop Input Node Main Loop Output Node Built in Differential Equation Solver allows continuous-time system Similar to a While Loop with a predefined time period Installed with Simulation Module Double-click Input Node to configure simulation parameters Create an indicator on the Output Node to display Simulation errors

Simulation Loop Parameters Drag left node to show current parameters and provide inputs for run-time simulation configuration Double-click Input Node to configure simulation parameters

High-Level Development Tools Data Flow C Code Textual Math Modeling Statechart Graphical System Design Platform Linux Macintosh Windows Real-Time FPGA Micro Desktop Platform Embedded Platform

Targets and Deployment LabVIEW Real-time LabVIEW FPGA LabVIEW Microprocessor SDK LabVIEW PDA and related

Evolution of LabVIEW Backend Technologies Intermediate Code Compiler Hardware Target None (Machine Code) LabVIEW Real-Time Wintel PowerPC VHDL OEM Synthesis PAR FPGA None (Object Library) LabVIEW DSP DSP C Any Any 32-bit MPU

LabVIEW for Parallel Programming Overview of LabVIEW Multithreading Parallel Programming Techniques Real-Time Considerations Resources

Impact on Engineers and Scientists Engineering and scientific applications are typically run on dedicated systems (i.e. little multitasking).

Creating Multithreaded Applications Engineers and scientists must use threads to benefit from multicore processors.

Multithreading Programs in LabVIEW Automatic threading LabVIEW clumping algorithm automatically assigns code to threads based on parallelism Most existing programs will run faster on a Multicore system with no alteration Manual threading Force section of code to execute in a single thread 64

Automatic Multithreading LabVIEW divides a program into multiple threads (originally introduced in 1998 with LabVIEW 5.0) Oversimplification shown below; parallel code paths execute in separate threads to run on parallel hardware thread thread thread

LabVIEW Execution System 1 2 3 1. LabVIEW compiler analyzes diagram and assigns code pieces to clumps 2. Information about which pieces of code can run simultaneously are stored in a run queue 3. If block diagram contains enough parallelism, it will simultaneously execute in all system threads thread thread thread thread # of threads scales based on # of CPUs

Multithreaded Software Stack Support Software Stack Development tool Support provided on the operating system of choice; tool facilitates correct threading and optimization Example: Multithreaded nature of LabVIEW and structures that provide optimization Libraries Thread-safe, re-entrant libraries Example: BLAS libraries Device drivers Operating system Drivers designed for optimal multithreaded performance Operating system supports multithreading and multitasking and can load balance tasks Example: NI-DAQmx driver software Example: Support for Windows, Mac OS, Linux OS, and real-time operating systems

Manual Threading with Timed Structures Code within timed structure executes in a single thread Threads can be assigned a relative priority Set processor affinity 69

Parallel Programming Techniques to Improve Performance on Multicore Systems Task Parallelism Data Parallelism Pipelining

Task Parallelism 1) Look for tasks that can be run in parallel 2) Architect code to reflect this parallelism Eliminate data dependencies LabVIEW automatically identifies parallel code and can split into multiple threads! 71

Task Parallelism Multiple tasks, same data Multiple data-independent tasks

Task Parallelism Demo

Data Parallelism 1) Look for large data sets that can be processed in two or more chunks independently 2) Architect code: Split the data apart Process the data in parallel Combine the individual results into one overall result

Data Parallelism Data Set CPU Core Signal Processing Result

Data Parallelism You can speed up processor-intensive operations on large data sets on multicore systems. Data Set CPU Core Signal Processing CPU Core CPU Core CPU Core Signal Processing Signal Processing Signal Processing Combine Results

Data Parallelism Demo

Pipelining Strategy Many applications involve sequential, multistep algorithms that are executed over and over again Applying pipelining can increase performance 2 4 2 4 Acquire 1 Filter Analyze Log 3 Acquire 1 Filter Analyze Log 3 time t 0 t 3 t 4 t 7

Pipelining Strategy CPU Core Acquire Acquire Acquire Acquire CPU Core Filter Filter Filter Filter CPU Core Analyze Analyze Analyze Analyze CPU Core Log Log Log Log t 0 t 1 t 2 t 3 time

Pipelining in LabVIEW Sequential Pipelined? Note: Queues may also be used to pipeline data between different loops or

Pipelining Demo

Multicore Challenges and Debugging Reentrancy and execution highlighting Thread synchronization Execution tracing Performance counters Data transfer considerations 83

Reentrancy All VIs in LabVIEW can bet set to be reentrant Allows for each subvi to use separate memory space All subvis that will be executed multiple times in parallel need to be set as reentrant 84

Thread Synchronization No guarantee that an OS will schedule threads in the correct sequence without synchronization primitives Order of events may change at each execution due to the way the threads are scheduled First execution Thread 1 Thread 2 Thread 3 Second execution Thread 2 Thread 3 Thread 1 Third execution Thread 3 Thread 1 Thread 2 86

Code Synchronization with Dataflow Dataflow paradigm ensures synchronization thread thread Parallel code paths are synchronized and order of execution is determined by LabVIEW wires Dataflow is a key enabler for Multicore programming 87

Synchronization in LabVIEW When low-level synchronization is required, use synchronization mechanisms including: Queues Notifiers Semaphores Rendezvous Occurrences 88

Execution Tracing On real-time systems, trace debugging can show thread activity at the OS level Thread activity on each core is displayed by selecting a particular CPU 89

Performance Counters Performance counters provide detailed system information (CPU usage, memory usage, and cache hits/misses) LabVIEW can call into Windows performance counters Example utilities: Windows Perfmon Intel s VTune

Data Transfer Considerations Carefully consider system memory architecture when programming for Multicore Avoid transferring overly large data sets between cores (relative to cache size) Very small memory transfers can cause repeated cache coherency updates 91

Physical Processor Layout Distance between processors and quality of processor connections can have a large effect Transferring data over system bus is much slower than accessing a shared cache Core 0 Core 1 Core 2 Core 3 L2 Cache L2 Cache Shared Cache Example: Dual-Core, Dual Processor System System Bus System Memory Source: Tian and Shih, Software Techniques for Shared-Cache Multi-Core Systems, Intel Software Network

Deterministic Real-Time Systems LabVIEW 8.5 adds Symmetric Multiprocessing (SMP) for real-time systems.

Assigning Tasks to Specific Cores In LabVIEW 8.5, users can reserve a core and then assign time critical code to run on it

Affinity, pools, threads, CPUs, etc. System Threads Timed-Structure Threads System Auto load balancing CPU Pool Thread-Structure Affinity Mask Timed Structures Auto load balancing CPU Pool Pool Affinity Mask Pool Affinity Mask Up to 32 CPUs

Execution Trace Toolkit LabVIEW Real-Time Only Thread view VI view (function view) Multicore support Debugging flags (memory manager collisions, mutex collisions, priority inheritance, ISRs, etc.) Trace Activity Sorting

Resources www.ni.com/multicore