Jump to content
Sign in to follow this  
bsvingen

Sub VI Inliner tool v1.0

Recommended Posts

Well, after discovering that an inline method already exists by default in LV (scripting), and with thanks to Jim Kring for pointing me to the traverse tool in LV8, the inline tool became much smaller and simpler.

Basicly what it does is to inline all sub VIs with __inline in their names (double underscore in front of inline. I don't know if this is the best option, but it works). It uses the NI tool to traverse the diagrams, while the main loop will recurssively loop through all sub VIs. inline VIs can therefore be inside other inline VIs, and the tool will just go through the complete hierarchy. It will not touch any locked files.

I could have added some statistics etc, but i have no use for that myself, so you have to add that if it is needed/wanted.

post-4885-1150641239.jpg?width=400

Download File:post-4885-1150641218.zip

Share this post


Link to post
Share on other sites

Here is an example of improvements in execution speed with inlining. In general inlining is useful when you have lots of small numerical formulas that have to be executed often, for instance when you have two or more arrays and have to do some more or less complex operations on array element basis. This is typical for most data analysis applications. With inline functions the code maintains the modularity (readability) while all the overhead associated with sub VI calls disapears completely. The increase in execution speed can be dramatic for some applications (several hundred percent), while for others no practical increase is seen.

When inlining, the the code becomes very unreadable, so it is only usefull to gain execution speed when the code or sub-parts of the code is finished. A copy of the un-inlined code must therefore be stored for later modifications.

Here is the execution speed before inlining. The inline sub VI has the same execution speed as an ordinary sub vi (they are identical :) ). The one stored/compiled as subroutine performs more than twice as good as the other two.

post-4885-1150670403.jpg?width=400

After inlining, the picture is different. Now the inlined code perform almost twice as good as the subroutine, and about 350% better than an ordinary sub VI. This is the effect of one single inline function. For more complicated formulas where the code needs to be broken down into several sub VIs, the improvement will be even more. (Actually the equations in this example are so simple that faster execution speed is obtained by feeding the arrays directly, but that is beside the point and only shows that too simple examples are not allways the best examples :D )

post-4885-1150670621.jpg?width=400

Download File:post-4885-1150670897.zip

Share this post


Link to post
Share on other sites

bsvingen,

Thanks very much for posting both your final solution and the benchmarks. Very significant.

Lastly, did you ever do any of your work in LV 7? Obviously the 8.0 Traverse tool/method will not work for 7 (then again, I didn't try to revert it to 7, but I suspect it won't.) There are still a very significant portion of the LabVIEW community that still use 7.x and I think they would benefit from your solution if it was finalized with the diagram coloring method.

Again, thanks and good job!

Scratch my paragraph above, I had not yet seen this post for your LV 7.1.1 version so please forgive the above.

Thanks again & great job!

Share this post


Link to post
Share on other sites

Hey bsvingen

Nice work, very cool. I'll have a play with this and give you some feedback, the drop in execution time is quite impressive.

Share this post


Link to post
Share on other sites

My project use SubVIs from OpenG, NI Database Toolkit, and NI Report Toolkit, when I use it in a top VI, the Inliner open a lot of VIs (it seems that open all VIs that aren't Locked/PW protected but doesn't close them)

Maybe the Inliner can be modified to secure the code:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.