Improving the Performance of Your NI LabVIEW Applications

download Improving the Performance of Your NI LabVIEW Applications

of 45

Transcript of Improving the Performance of Your NI LabVIEW Applications

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    1/45

    Improving the Performance of Your

    NI LabVIEW A lications

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    2/45

    Improving Performance in

    LabVIEW

    Optimization Tools Optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    3/45

    Optimization Cycle

    OptimizeBenchmark mprove e c ency

    Improve speed

    va uate per ormance

    Identify problem areas

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    4/45

    Why Should You Profile Your VIs?

    80 percent of the execution time is

    s ent in 20 ercent of the code

    The 80/20 rule of software performance

    Performance improvements are most

    effective in the 20 percent

    Guessing which 20 percent is difficult

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    5/45

    Improving Performance in

    LabVIEW

    Optimization Tools Optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    6/45

    Windows Task Manager

    Gives user a rough idea of

    whether memory or CPU is

    the bottleneck

    Can be hel ful inidentifying memory leaks

    ViewSelect Columns

    allows you to add additional

    stats

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    7/45

    Perfmon

    Allows you to monitor

    Processors

    Disk I/O

    Network Tx/Rx

    Memor /Pa in

    Access by typing

    perfmon into the

    Windows Run dialog

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    8/45

    Benchmarking Code Execution

    Timing Template (data dep) LabVIEW Shipping Example

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    9/45

    Benchmarking Code Execution

    Code

    Calibration

    Analysis

    Benchmark Project LabVIEW Real-Time Shipping Example

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    10/45

    VI Profiler

    Timing and memory statistics for VIsToolsProfilePerformance and Memory

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    11/45

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    12/45

    LabVIEW Desktop Execution Trace

    Toolkit

    Multiple

    Detailed

    execution

    traces

    Thread and VI

    information,

    and Memory

    VIs

    ess ons Measurement

    of execution

    time

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    13/45

    Benchmarking Summary

    OS Level

    Task Manager, Perfmon

    LabVIEW Level VI Profiler, Benchmark VIs

    VI Level

    LabVIEW Desktop Execution Trace Toolkit

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    14/45

    Improving Performance in

    LabVIEW

    Optimization Tools Optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    15/45

    VI Components

    Panel

    Diagram

    Code

    Data

    Control/indicator values

    Default data

    Block diagram constant data

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    16/45

    VIs in Memory

    When a VI is loaded into memory

    We always load the data

    We load the code if it matches our platform

    , , ,We load the panel and diagram only if we need to

    (for instance, we need to recompile the VI)

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    17/45

    Panel and Diagram Data

    Front panel controls and indicators need their owncopy of the data to display, called operate data

    This VI uses about 8 KB of data if the panel is open,

    and about 4 KB otherwise

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    18/45

    LabVIEW Terminology

    Panel data is called Operate Data

    Controls and indicators have their own copy of the

    data, so that front panel editing of data does not

    interfere with com utations in the dia ram Diagram data is called Execution Data

    Every wire represents a buffer of data

    Transfer Data is used to copy between them

    Avoids multithreading issues

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    19/45

    Memory Performance

    The following features affect the impact

    memory allocation has on your application:

    Wire Semantics and In Placeness

    Passing values to subVIs

    Shift registers

    Front panel indicators

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    20/45

    Wire Semantics

    Every wire is a buffer Branches typically create copies

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    21/45

    Optimizations by LabVIEW

    The theoretical 5 copies become 1 copy operation

    Copy

    Output is in place with input

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    22/45

    The In Place Algorithm

    Determines when a copy needs to be made

    Weighs arrays and clusters higher than other

    types

    Does not know the size of an array or cluster

    Relies on the sequential aspects of the

    program

    Branches may require copies

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    23/45

    Bottom Up

    In-place information is propagated bottom up

    Branched wire

    Increments array in place

    Copy becauseof increment No copies required

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    24/45

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    25/45

    Allows you to explicitly modify data in place

    The In-Place Element Structure

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    26/45

    Types of Border Nodes

    Array index/replace element

    Array split/replace subarray

    Unbundle/bundle

    Variant to/from G data

    Simple in place relationship

    Data value reference

    read/write

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    27/45

    Operate on each element of an array of waveforms

    Example of In Place Optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    28/45

    Make the First SubVI In Place

    changes into

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    29/45

    SubVI 2 Is Made In Place

    Chan es into

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    30/45

    SubVI 3 Is Made In Place

    Changes into

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    31/45

    Final Result: Dots Are Hidden

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    32/45

    Type Coercion

    Changing the data type of a wire to match

    the required data type

    Dots indicate automatic coercion

    Coercion Dot

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    33/45

    Passing Values to SubVIs

    SubVI does not always have to make a copy

    Best when

    Inputs are required

    In uts and out uts are not in structuresInputs and outputs are in place

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    34/45

    Passing Values to SubVIs

    Parameters within structures causeunnecessary copies

    ove

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    35/45

    Shift Registers

    Single left input always in place with rightoutput

    Even better when the body is in place

    Always In Place

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    36/45

    Building Arrays

    There are a number of ways to build arrays

    and some are better than others

    Reallocates array memory on

    every loop iteration

    No compile time optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    37/45

    Building Arrays

    There are a number of ways to build arrays

    and some are better than others

    Keep graphics

    below the text

    and to the right.

    Memory allocated at load time

    Values populated in place

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    38/45

    Building Arrays

    There are a number of ways to build arrays

    and some are better than others

    Memory preallocated

    Indexing tunnel eliminates

    need for copies

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    39/45

    Build Array Ordering

    Appending to the end of an array is much

    beginning

    If you need to insert items at the beginning,

    insert at the end instead and use a single

    Reverse Array when finished

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    40/45

    Demo Effects of Memory

    Optimization

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    41/45

    Improving Performance in

    LabVIEW

    Purpose ofOptimization

    Profiling Tools Memory

    Optimization

    Decrease memory usage, increase speed 80/20 Rule

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    42/45

    Improving Performance in

    LabVIEW

    Purpose ofOptimization

    Profiling Tools Memory

    Optimization

    Windows Tools (Task Manager, perfmon) VI Profiler

    Real-Time Execution Trace Toolkit

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    43/45

    Improving Performance in

    LabVIEW

    Purpose ofOptimization

    Profiling Tools Memory

    Optimization

    Hide the dots Take advantage of in placeness

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    44/45

    Next Steps

    LabVIEW Help

    In LabVIEW

    ni.com/multicore

    ni.com/devzone

    On the Web

  • 8/10/2019 Improving the Performance of Your NI LabVIEW Applications

    45/45

    Next Steps

    Visitni.com/training

    Identify your current expertise level and

    desired level

    Register or appropriate courses