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

In Place Element Structure

LabVIEW 2009 Help

Edition Date: June 2009

Part Number: 371361F-01

»View Product Info

Use the In Place Element structure to control how the LabVIEW compiler performs common operations, such as operating on an element of an array and placing the resulting value back into the same array index, and to increase memory and VI efficiency. Many LabVIEW operations require LabVIEW to copy and maintain data values in memory, thereby decreasing execution speed and increasing memory usage. The In Place Element structure performs common LabVIEW operations without LabVIEW making multiple copies of the data values in memory. Instead, the In Place Element structure operates on data elements in the same memory location and returns those elements to the same location in the array, cluster, variant, or waveform. Because LabVIEW returns the data elements to the same location in memory, the LabVIEW compiler does not have to make extra copies of the data in memory.

The In Place Element structure uses border nodes, or nodes that are attached to the border of the In Place Element structure, to perform operations on data. Right-click the border of the In Place Element structure and select the appropriate border node for the operation you want to perform. Each border node consists of a terminal on the left and right side of the structure. When you move or delete a border node, LabVIEW automatically moves or deletes the corresponding node on the opposite side of the structure. Select an element on the left side of the structure, operate on the element within the structure, and wire the resulting value to the right side of the structure to replace the value in the existing location.

Using the In Place Element Structure to Increase Efficiency

The In Place Element structure can execute a variety of common LabVIEW operations more efficiently than traditional LabVIEW programming methods. The following block diagram shows a situation in which you can use the In Place Element structure to improve the execution and memory efficiency of a VI:

In the above example, LabVIEW indexes an array of 32-bit unsigned integers, increments the third element of the array, and replaces the element in the same location of the array. To replace the new value in the same array, the Replace Array Subset function requires you to wire the array and array index values to the array and index inputs of the function. When you run the above VI, LabVIEW makes a new copy of the array and stores the copy in memory. Use the In Place Element structure to avoid making extra copies of the array and index values, as shown in the following block diagram.

In the above example, the Array Index / Replace Elements border node of the In Place Element structure indexes an array of 32-bit unsigned integers, increments the third element of the array, and replaces the element in the same location in the array, similar to the first example block diagram. However, in this instance, LabVIEW does not have to create or store extra copies of the array values in memory. The In Place Element structure requires you to replace each indexed element of the array in the array with the node on the right side of the structure. Because the structure requires you to replace the array element and the LabVIEW compiler knows which element to replace, LabVIEW does not have to create or store extra copies of the array or array elements in memory.

Caveats and Recommendations for the In Place Element Structure

The following list describes some of the caveats and recommendations to consider when you use the In Place Element structure:

  • When you unbundle a cluster with the Unbundle / Bundle Elements border node of the In Place Element structure, you cannot unbundle any cluster element more than one time. For example, if the cluster you are unbundling contains another cluster and you unbundle an element of the subcluster, you cannot also unbundle the entire subcluster because you already unbundled one of the elements of the subcluster.
  • Do not use more than one border node for a single array, cluster, variant, or waveform. Operate on each individual item with a single border node. If you use more than one border node for a single array, cluster, variant, or waveform, a copy of the entire array, cluster, variant, or waveform is placed in memory, which negates the positive performance effects of the In Place Element structure.
  • Because variants can contain data of multiple types, you must wire the data type of the data you want to replace from the variant to the data type input of the Variant To / From Element border node. If the variant does not contain data of the type wired to the data type input, the VI returns an error.
  • You can place an In Place Element structure inside another In Place Element structure. Nested In Place Element structures allow you to access elements of multiple complex data types. For example, if you want to access an element of an array within a cluster, use the outer In Place Element structure to unbundle the cluster, and use the inner In Place Element structure to access an element of the array.
  • Consider using the Mark As Modifier shortcut menu option on nodes of the In Place Element structure to indicate that LabVIEW will modify the value of the data you wire to the node. For example, dynamic dispatch terminals can execute any implementation of a dynamic dispatch subVI in a class hierarchy. The parent implementation of the dynamic dispatch VI might have no operation and does not modify the data; however, a child implementation might modify the data. If you wire the parent implementation to the node and select the Mark As Modifier option, you can indicate that LabVIEW will modify the value wired to a dynamic dispatch terminal at some point in the class hierarchy. Using the Mark As Modifier option then optimizes performance by minimizing the number of copies of the data LabVIEW creates.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit