09-19-2016 08:33 AM
I've inherited some code for Labview 2012, and it's running slower than the users would like. I've determined that by changing a certain subvi to preallocated clone, it speeds up the execution greatly. However, I want to make sure that I'm not getting myself into trouble with it.
I've attached a simplified snippet. Basically, the Values array is composed to temperatures, pressures, flow rates, calculated values, etc. The subvi consists of a case statement with a number of different calculations which modify the output. The map array determines which indexes of Values are being used for the inputs & outputs.
My question is:
If the first iteration of the main loop modifies an index of the Values array which is then used as in input for the second iteration, will Labiew use the newest value, or based on the cloning will it use the older one?
I will not be running anything in parallelized loops.
Thanks,
Jacob
Solved! Go to Solution.
09-19-2016 09:21 AM
You are storing the array in the shift register and passing a version of that into the subVI. So it will use the latest value of the array.
All the Preallocated Clone does is create a copy of the VI everywhere it is used. Each have their own memory space and can operate in parallel.
The non-reentrant only allows for a single copy of the VI, meaning it can only have one caller at a time. If being called at multiple places, then whoever got there last must wait for the VI to finish running before it can use it.
The other reentrant option is Shared Clone, which creates a "clone pool". This is similar to the preallocated clone except that the clones are only created when needed. This causes a little more latency, but is more memory efficient.
09-19-2016 09:26 AM
On every iteration it will be the same instance of sub-vi.
09-19-2016 10:11 AM
Thanks, crossrulz.
09-19-2016 10:29 AM
Your main question already got answered, but as a side note if you're looking to speed up those loops even more, you can try either changing the SubVI to have inlining enabled, or change its priority to "Subroutine", or both.
Both of those options have restrictions based on the contents of the SubVI though, so one or both of them might not even be an option.
09-19-2016 10:36 AM - edited 09-19-2016 10:57 AM
@jacobdiemer wrote:I've inherited some code for Labview 2012, and it's running slower than the users would like. I've determined that by changing a certain subvi to preallocated clone, it speeds up the execution greatly.
For more general advice, feel free to go over our recent NI-Weeek talk about benchmarking an optimization.