06-21-2007 11:00 AM
06-21-2007 11:25 AM
Why don't you attach your VI and let us play with it? 🙂
06-21-2007 12:09 PM
06-21-2007 12:29 PM
06-21-2007 01:41 PM
@AnthonV wrote:
Maybe there is something to be said for the compiler not to 'err on the safe side'.
Not really. It's much better for such an error to slow down your application then for it to produce wrong results and I can find all kinds of examples. Inplaceness is complicated and it's possible that what you're seeing here is a missed corner in the algorithm.
For a couple of threads demonstrating the complexity (and explaining some more) you can have a look here and here.
06-21-2007 03:17 PM - edited 06-21-2007 03:17 PM
Message Edited by altenbach on 06-21-2007 01:18 PM
06-21-2007 08:08 PM
06-21-2007 08:26 PM - edited 06-21-2007 08:26 PM
@AnthonV wrote:
There is obviously some other code that isn't shown here that is executed when the flag is set so what you suggest won't work for me unfortunately. I'm selecting specific elements of the array and checking the flag, if it is set I reset it and perform some operation on the rest of the element, place it back into the array and then bundle it back.
See, you do all operations within a single array element! There is absolutely no need to constantly unbundle and rebundle the array from the parent cluster. Just unbundle the "controls" array, do whatever you need to do inside the loop, and at the very end bundle it back to the parent cluster.
Here s a quick very simple example of what I had in mind. It checks if "changed" is TRUE, and if so, resets "changed" to FALSE and also sets state=3. The possibilities are unlimited, do whatever you need to do to each array element. Once you have edited the entire array, and the FOR loop has finished, bundle it back into the parent. No outer loop! No shift registers!
If you only have selected elements, autoindex on the list of indices and basically do the same with "index array" and "replace array element".
Message Edited by altenbach on 06-21-2007 06:28 PM
06-21-2007 08:42 PM - edited 06-21-2007 08:42 PM
@altenbach wrote:
If you only have selected elements, autoindex on the list of indices and basically do the same with "index array" and "replace array element".
Here's what I had in mind.
Message Edited by altenbach on 06-21-2007 06:42 PM
06-21-2007 11:56 PM
Thanks for the detailed feedback. Unfortunately it seems I will have to keep on bundeling inside the loop as unbundeling the array and autoindexing also creates copies at every iteration causing the following results: bundeling inside the loop: 1ms; bundeling outside the loop: 1200ms (see attached picture). I agree that what you suggest is the most elegant and esthetically pleasing solution, but in an embedded application (or any other for that matter) it is unacceptable.
Any programmer that has any need for time-critical code will have to regularly do a 'show buffer allocations' and elaborate their code with sequences and less-than-esthetically-pleasing sections to eliminate unrequired buffer allocations.
I have often had LabVIEW programmers tell me that LabVIEW should not be used for performance-critical tasks but rather for ease-of-use. I disagree, with a little bit of effort and some elaboration one can get incredible speed-ups of your code - as long as you eliminate non-obvious buffer allocations. And it would be wonderful if the compiler could do this more intelligently - in fact I expect this from the compiler and I hope it will do better in future versions if LabVIEW wants to compete mainstream.