LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementation Issues of Open VI Reference & Call By Reference Node

Hi NI fellows,

I need to know the following thing about the implementation of Open VI Reference. If I open multiple references of the same VI in re-entrant mode (0x08), does Labview actually open multiple copies of the same VI or is only one copy of the VI opened? If only one copy is opened, what when does the data space allocation take place? Is dataspace allocated at Open VI Reference call or Call By Reference Node call?

--
Tomi Maila
0 Kudos
Message 1 of 8
(3,370 Views)

Hello Tomi,

First, I'll give you the quick answers to your questions.  The entire VI doesn't get copied for reentrant VIs, only its dataspace.  That is of course until you start opening other components.  That said, the cloned data spaces for your reentrant copies do get created by the Open VI Reference when you provide the 0x08 flag.  The way LabVIEW handles multiple front panels / block diagrams of cloned reentrant VIs changed drastically between versions 7.1 and 8.0, so I won't get into that unless you have follow-up questions and supply which LabVIEW version you're using.

Now I have a question for you.  The help for the options input of Open VI Reference (which you undoubtedly had to look at to find the admitedly esoteric "0x08" flag) also explains it saying, "Prepare for reentrant run. Reserves the target VI so it cannot be edited and if the target VI is reentrant, allocates a dedicated parallel data space for this VI reference..."  I was just wondering if you'd read this or not.  I myself am at least as guilty as anyone for asking questions before referring to the help sometimes, but if you did read it, I'd be interested to know if there's anything we can do to make it more clear.

Thanks!

0 Kudos
Message 2 of 8
(3,354 Views)

That said, the cloned data spaces for your reentrant copies do get created by the Open VI Reference when you provide the 0x08 flag.

So when I create a reference a singel data space is created if I understood it correctly. But I can make simultaneous calls to the same reference by wiring the same reference to multiple call by reference node instances. Do the additional data spaces get allocated when the call is made?

The way LabVIEW handles multiple front panels / block diagrams of cloned reentrant VIs changed drastically between versions 7.1 and 8.0, so I won't get into that unless you have follow-up questions and supply which LabVIEW version you're using.

I am using 8.0.1 but the software should also work on 7.1. Can you provide at least some guidelines on how the dataspace is allocated in both cases, it doesn't have to be detailed.

The reason I am asking the question is to find out how to optimise time critical process of dynamical calls to implement object oriented dynamic member functions. I need these to simplify implementation of an interpreter I am working on. I have a C++ implementation up and running but I'd like to use Labview because of better support for data visualisation. If you are implementing OO in LV 9, I'd be pleased to know. In that case you can contact me also directly, my email address is in my profile.

Now I have a question for you.  The help for the options input of Open VI Reference (which you undoubtedly had to look at to find the admitedly esoteric "0x08" flag) also explains it saying, "Prepare for reentrant run. Reserves the target VI so it cannot be edited and if the target VI is reentrant, allocates a dedicated parallel data space for this VI reference..."  I was just wondering if you'd read this or not.  I myself am at least as guilty as anyone for asking questions before referring to the help sometimes, but if you did read it, I'd be interested to know if there's anything we can do to make it more clear.

I'd be happy to help. The thing is that I have no idea what happens when 0x08 flag is not used. The way memory is allocated in normal case is not described anywhere. Then it doesn't make sence to tell how things are done with 0x08 flag, if one doesn't have anything to compare it with. It would be more clear to me if the normal function would be clearly described. Then when using the 0x08 you would tell the difference to the standard mode.

The second issue which is not clear is the thing that since reentrant VI can be called simultaneously from multiple instances using the same reference, how the dataspace allocation is done. This is what I asked above already. Does it make a difference is I use 0x08 option or not to call multiple instances of the same re-entrant VI.

Thanks!

--
Tomi Maila
0 Kudos
Message 3 of 8
(3,346 Views)

 


That said, the cloned data spaces for your reentrant copies do get created by the Open VI Reference when you provide the 0x08 flag.

So when I create a reference a singel data space is created if I understood it correctly. But I can make simultaneous calls to the same reference by wiring the same reference to multiple call by reference node instances. Do the additional data spaces get allocated when the call is made?



No, but I think I finally I see where the confusion is.  The cloned data spaces are created by the Open VI Reference function.  The Call By Reference Node does not do this.  If you ran a VI that opened a reference to a reentrant VI, and sent that reference to three Call By Reference Nodes, the same single instance would run three times, serially, just like a regular subVI.  To get the behavior you want, you would need to use three Open VI References (or put one in a for loop or something), then use those references for your Call By Reference Nodes.


 


I am using 8.0.1 but the software should also work on 7.1. Can you provide at least some guidelines on how the dataspace is allocated in both cases, it doesn't have to be detailed.



The behavior is the same between 7.1 and 8.0.1 in this regard.  The differences show up when you start trying to open the front panels or block diagrams of reentrant VIs.  Most notably, when you open a front panel of a running reentrant VI in LabVIEW 7.1, you get the "actual" VI and the front panel never updates with the values being sent to that particular call.  Further, reentrant VIs are not debuggable.  Both these limitations are no longer present in 8.0.

Thank you for the help feedback, I have passed that along as well (ID#3WO6JR1W).

Message 4 of 8
(3,335 Views)
When reentrant VI reference is opened and then ran let say three times, what will happen to front panel values and shift register values between the runs. Will their values be reinitialized to their default values each time or will their value pass from one run to the next. If the values last for the next run, then this is of course not really reentrant way of calling the function any more (and I cannot use it as I do now).

So the only way to really run VI in reentrant mode dynamically is to repeat the following steps for each call separately:
  1. open vi reference in mode 0x08
  2. call by reference node
The problem with the above mentioned method to call reentrant VI is that opening VI refenrence is quite slow. I propably would be faster if some common parts of opening the reference could be made for all the calls together. Now, I assume, Labview needs to do the following tasks each time it opens a VI reference
  1. Determine the full path of the VI to be opened
  2. See if the VI with the same name is already in the memory
  3. Create a dataspace for the VI (and front panels etc...)
The first two steps are redundant, and it would be faster if those steps were done only once.

I have an additional question. When I open VI by reference, I have to use the path of the VI. I can create multiple VIs with the same name if they are in different position of the library hierarchy (lvlib). Does open VI reference distinguish between these VI's with the same name but different namespace the same way as Labview distinguishes between the VIs when called by placing the VI on the block diagram.
--
Tomi Maila
0 Kudos
Message 5 of 8
(3,330 Views)
Yes, that's right, if you open the reference only once, the dynamic calls all access the only clone that's been created, and therefore you get no benefits / behaviors of it being reentrant.
 
I do not know the mechanics of exactly what steps LabVIEW does each time you open a VI reference, what steps we might optimize out when we can, or how long each of these steps takes relative to one another.  If you are concerned about this, you might try filing a product suggestion here:
 
 
And yes, VIs can have the same file name on disk but different fully-qualified names and be opened simultaneously by Open VI Reference.
0 Kudos
Message 6 of 8
(3,312 Views)
Jeff B wrote: "And yes, VIs can have the same file name on disk but different fully-qualified names and be opened simultaneously by Open VI Reference."

Only in LV 8, right?

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 7 of 8
(3,308 Views)
Correct, only in LabVIEW 8.0 and later.
 
-D
Message 8 of 8
(3,297 Views)