Calling Multiple Copies of the Same SubVI Simultaneously

Updated Nov 21, 2023

Reported In

Software

  • LabVIEW

Issue Details

I have multiple copies of the same SubVI which I need to call simultaneously. How can I do this?

Solution

When attempting to call two SubVIs simultaneously, there are two aspects to consider: reentrancy and synchronization.

By default, only one copy of a SubVI is open in the computer’s memory at any one time. LabVIEW has two alternative options for re-entrancy: Shared Reentrancy, which starts with only one copy of each SubVI in memory, but adds an additional copy whenever needed; and Pre-allocated Reentrancy, which checks before starting for the maximum number of each SubVI in the code, and allocates that many instances to memory in advance. To assist with deciding which of these options is the best for your application, check the comparison contained in the Reentrancy help page. The Reetrancy settings for a VI can be changed in the Execution page of the VI Properties menu.

When synchronizing the execution of two (or more) SubVIs, this can be done by placing the as many copies of the SubVI as needed in a Flat Sequence Structure, and wiring their inputs in parallel with one another, as shown below:

With either of the reentrancy execution methods, this code will execute both copies of the VI simultaneously, This can be scaled to as many copies of the same SubVI as needed by wiring each in parallel within the Flat Sequence Structure, and merging the error wires for all of them by expanding the Merge Errors function.