05-20-2009 02:15 PM
Hi all,
i am using action engines in my project to store and execute any kind of processing to be done on the data.
So that means i am using all my data in the shift registers.
Now, when i used "Memory Buffer allocation" tool to look at where the LV will make copies data i got bit surprised by seeing that on some shift regiters the dots were blinking and on some they were not present.
How can this haapen?? how can LV makes copy of data on some shift reg and not on the rest??
I am attaching my VI here. Pls have a loot at it and let me know where can i make it more memory efficient.
Thanks,
Ritesh
05-20-2009 02:29 PM
THe dots do not show copies but buffers. I took a quick glance at your AE and it looks like all of your work is being done in-place (in the buffers of the SRs).
The exception is for values passed in and then wired to the SR where an additional copy is not required since LV will then work in the buffer "up stream".
If I missed something let me know and post an image of the case and detail whcich buffer is confusing.
Take care,
Ben
05-20-2009 02:47 PM - edited 05-20-2009 02:47 PM
There must be a buffer allocation, because the content of the shift register changes size. Some turn empty in some states and e.g. the top two start out empty, but then get initialized.
If the size does not change between iteration, there will be no new allocation at that iteration so you shold be OK most of the time.
A better way would be to eliminate the while loop and use globally iniailized feedback nodes instead. Now the content is truly fixed size from compile time on and there is no longer a bufffer allocation (there is one at "initialize array, but as you can see from the fuzzy wires, all this is folded into a constant and does not pose any performance penalty.
Here's how the top part would look like, for example.
05-20-2009 02:48 PM
Hi Ben,
Thanks for your comments.
There are cases "Make Average Zero" and "Record" where the buffer allocation doesn't seem to be behaving as expected.
In that case, i have a cluster of 6 arrays and i replace only 2 arrays in the cluster and it shows buffer for all the elements in the cluster(which are not even being touched). and same in the Record case.
Ritesh
05-20-2009 02:51 PM
05-20-2009 03:13 PM
Actually, the top two arrays are "read-only" in the rest of the code, so they don't even belong in shift registers! Just initialize outside the structure (they will be folded) and use plain tunnels to where they are needed.
Is that sure they wont make extra copies when ever they are called and only make a copy when called First ?
You mentioned about removing the while loop. How will i handle the rest of the data in SRs then ? Should i use FB Node for all the data that i am accessing through SRs?
Ritesh
05-20-2009 03:16 PM
Please investigate Christian's suggestion to see if that helps.
Before I re-invent the wheel maybe this thread where Shane and I investigated a similar Q some time ago will help.
Sorry if I am sound "stand-offish" but these performance Q can go on for days so I try to only step in when there is an apparent bug or something similar.
Curious, and cautious, but still trying to help,
Ben
05-20-2009 03:18 PM
One more thing, What do you guys mean by "In Place" ??
Is it simply "In Place Element Structure" or something else ?
I have gone through many posts and found it a very common term, but could't get it in the right context.
05-20-2009 03:21 PM
ritesh024 wrote:Is that sure they wont make extra copies when ever they are called and only make a copy when called First ?
If you use all constants for the initialization as you do, the allocation will be done at compile time and everything folded into a constant. THere will be no extra copies.
In newer LabVIEW versions, you no longer need a loop once you replace the shift registers with globally initialized feedback nodes as I showed in the image earlier.
05-20-2009 03:28 PM
In newer LabVIEW versions, you no longer need a loop once you replace the shift registers with globally initialized feedback nodes as I showed in the image earlier.
OK. But how will it be more efficient on using FB node over the USR?