From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If i use a sub-vi 3 times simultaneously in my main program. Do i need to create that many of those sub-vi's and the VI's inside the that sub-VI.

In my main VI, I am calling a sub vi to do math on the data. I am doing this process simulataneously on the data collected from three channels. I created three sub vi's with same functionality but with different names so that they can be called separetly at the same time. My question is do I also need to create that many copies of the sub-vi's which I am calling inside the Sub-VI used to do math on the data collected from channels?
0 Kudos
Message 1 of 11
(2,776 Views)
Simple answer is yes, you would need copies of the subvis also. LabVIEW can only have one copy of a certain named VI in memory at a time.

Unless...

You make the VI Reentrant. Setting a VI to reentrant causes LabVIEW to open each instance of the VI in it's own data space, so it acts the same as having differently named VI that are the same. You set this by going into the VI properties, select the Execution catagory and checking the "Reentrant Execution" checkbox. You wold also need to do this on any subvis you want to run as separate copies. The propertiy is not inherited.


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 11
(2,776 Views)
if i make my sub vi's as reentrant, do I lose any process speed, in other words are there any limitation for using the reentrant execution? and thanks for your reply.
0 Kudos
Message 3 of 11
(2,776 Views)
As far as I know, making a subvi reentrant would have no performance difference over having multiple VIs with different names. Maybe an app eng could verify this.

Each time a reentrant VI is called from a new location in the code, it creates a separate area for it in LabVIEWs dataspace, the same as calling a new subvi would do.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 11
(2,776 Views)
No!

You may pick some up.

What you will loose is debugging.

The main "gotcha" is the seperate memory space issue mentioned earlier.

This means that if your sub-VI's use local storage (like shift register that store results from the last call for use in the next) are distict for each occurence of the sub-VI in a diagram.

Also, if your sub-VI use larege amounts of memory the use will be duplicated between each instance.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 11
(2,776 Views)
My "NO" was to Mudda Q.

I am the same page as Ed.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 11
(2,776 Views)
If the subvi does not contain data that are dependent on a previous run , such as local variable or shift register data, then there is no need to make the vi reentrant.
0 Kudos
Message 7 of 11
(2,776 Views)
If the sub-VI is CPU intensive,
and
you do not want one call of the sub-VI to delay another call to the sub-VI

Then re-entrancy is very useful.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 11
(2,776 Views)
In principle, Yes,
However, how much true that is depends on how LabView (R/D)developers are implementing it, and things have been changing between LabView versions, to different degrees, all the time.
0 Kudos
Message 9 of 11
(2,776 Views)
Yes sir!

From what I have read about LV 7.X and hyperthreading, two of these re-entrant sub-VI's can be executing simultaneously without having to resort to dual-proccessors.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 11
(2,776 Views)