06-11-2015 08:24 PM
I'm using LabVIEW 2014.
Reading through the many posts on VI Reentrancy, I am still left with one fairly basic question about VI reentrancy:
Let's say I have a VI which i want to set to 'Reentrant' (Shared or Preallocated), in order to execute several copies simultaneously.
Let's say this VI is typical, containing numerous subVIs (which themselves call numerous subVIs and so on).
If I want to see maximum-performance parallel execution of all copies of my VI (avoiding bottlenecks of multiple instances waiting to use the same subVI), am I required to visit every one of the subVIs in the calling heirarchy, and manually set its execution state to reentrant? And its subVIs too, and so on?
OnceI get down to the level of the built-in LabVIEW functions, I assume multiple instances of the same (built-in LabVIEW) function will execute within each reentrant VI in parallel (e.g. as inline code) without causing bottlenecks? Is this true for every built-in function offered by LabVIEW (e.g. signal processing, datacommunications etc)?
06-11-2015 10:22 PM
06-11-2015 11:22 PM
Thanks Mike, you have created some good content there.
06-12-2015 12:46 AM
@AQ1 wrote:
If I want to see maximum-performance parallel execution of all copies of my VI (avoiding bottlenecks of multiple instances waiting to use the same subVI)...
It's also worth pointing out that this is not as clear cut as more reentrant=better performance. Running multiple VIs has costs (memory allocation, thread switching, etc.) and those could be higher than the gains.
Generally, you should consider making a VI reentrant if:
There may be others, but the point is that the decision on making a VI reentrant should be based either on functionality or on actual data. Don't just go and make all the VIs reentrant hoping for a performance increase. In my case I almost always need the reentrancy for functionality, because I want state in multiple copies.
02-03-2016 02:25 AM
Keep in mind that if a VI uses shift register to store values, so its execution mode needs to be set to non-reentrant.
02-03-2016 06:01 AM
> Keep in mind that if a VI uses shift register to store values, so its execution mode needs to be set to non-reentrant.
This can be done, if you keep in mind the limitations.
For example, the following code works in a pre-allocated reentrant vi.
This vi gets the Control Index of an indicator on First Call, and returns it in subsequent calls.
[Get/Set by Control Index - the best thing for large systems since the cluster (IMHO).]
I was recently reading a 2009 post on Darren's blog about removing the while loop by using Feedback Nodes.
Here is a no-loop version:
steve
02-03-2016 08:12 AM
02-04-2016 04:59 AM
You are right Mike - that "no loop" code doesn't avoid the calculation each iteration.
This version works as intended:
steve