01-27-2006 10:09 AM
01-28-2006 02:35 PM
| Robst - CLD |
| Using LabVIEW since version 7.0 |
01-29-2006 12:11 PM - edited 01-29-2006 12:11 PM
Hi All,
The Replace array subset will re-use a buffer if that buffer is appropriate for re-use.
The VI's you poseted along with some others are shown in this image.
I added red arrows to emphesize where the buffer allocations are taking place.
The two examples you provided (4buffer adn 2abuffer) along with my 2cbuffer shows that the bufferproduced by an "Initialze array" that has constant inputs is not suitable for re-use. I can only guess at why an array of predicatable size can can not be re-used ![]()
On the other hand, buffers produced by an Intialize array of unknown size (at compile time) can be re-used as shown in 1buffer and 2bBuffer.
I added Buffer and Bufferb to show how an input array can be re-used or not re-used. In both of these cases, Array out is the same buffer as Array in. In Bufferb Array out 2 is processed before Array out in order to allow the buffer re-use.
So most of this makes sense to me except all of the buffers in "4Buffer".
Why is an array of constant size un-suitable for re-use?
Why is the array produced by the Replace array subset not re-usable for Array out?
Since replacing the constant derived Initialize array "fixes" the buffer allocations issues I will venture a guess that there is some "constant folding" (Compiler attempts to pre-process constants) or, ..... hmmm
Not sure ![]()
This link talks about how to do the above in LV 7.0
http://digital.ni.com/public.nsf/websearch/C18189E84E2E415286256D330072364A?OpenDocument
This link talks about when buffers are re-used.
Anyone else able to shed some light on why the buffers are being over-allocated?
Ben
Message Edited by Ben on 01-29-2006 12:12 PM
01-29-2006 02:35 PM - edited 01-29-2006 02:35 PM
The reason a constant array can't be reused is something Greg Mc Kaskle once called indeed constant folding. In principle what LabVIEW does for an Initialize Array functions with constants as inputs is calculating the array at compile time and storing it together with the VI to the disk. This is then a constant array and created at load time rather than runtime and as long as you are not passing it to functions that modify the array, no copy needs to be done. But for modifying functions it can't reuse the array since it is a constant array (and potentially on certain platforms could have been loaded into a read only page) where any attempt to modify the array would create a General Protection Fault error.
@Ben wrote:
The two examples you provided (4buffer adn 2abuffer) along with my 2cbuffer shows that the bufferproduced by an "Initialze array" that has constant inputs is not suitable for re-use. I can only guess at why an array of predicatable size can can not be re-used![]()
On the other hand, buffers produced by an Intialize array of unknown size (at compile time) can be re-used as shown in 1buffer and 2bBuffer.
I added Buffer and Bufferb to show how an input array can be re-used or not re-used. In both of these cases, Array out is the same buffer as Array in. In Bufferb Array out 2 is processed before Array out in order to allow the buffer re-use.
So most of this makes sense to me except all of the buffers in "4Buffer".
Why is an array of constant size un-suitable for re-use?
Why is the array produced by the Replace array subset not re-usable for Array out?
Since replacing the constant derived Initialize array "fixes" the buffer allocations issues I will venture a guess that there is some "constant folding" (Compiler attempts to pre-process constants) or, ..... hmmm
Not sure
This link talks about how to do the above in LV 7.0
http://digital.ni.com/public.nsf/websearch/C18189E84E2E415286256D330072364A?OpenDocument
This link talks about when buffers are re-used.
Anyone else able to shed some light on why the buffers are being over-allocated?
Message Edited by rolfk on 01-29-2006 09:41 PM
Message Edited by rolfk on 01-29-2006 09:46 PM
01-30-2006 06:26 AM
01-30-2006 08:10 AM
Dalton wrote
"
In addition to the above I would like to stress that in the example VI's of my first message LV does indeed use even more buffers than shown by the tool Show Buffer Allocation! This can be seen by increasing the array size to 10 MegaBytes or so and using the Windows Task Manager to monitor the memory really used! 2bBuffer uses 2 Buffers but only 1 is shown and 4Buffer uses 4 Buffers but only 3 are shown! This puzzles me because with that I even cannot rely on "Show Buffer Allocation" to show me all buffers used!
"
Warning!... just guessing now!
I think the extra buffer may be the duplication that occurs between BD data and FP data.
Re: Screen captures
I just use "print Screen" and paste into paint.
(This reminds me of a website and does not apply to you Dalton.
After filling out a form the web-site directs you to a page that has instructions on how to print out a hard-copy for your records. It reads something like, "If you are using Windows do a "File >>> Print" if you are using MacOS then use "Apple >>> blah, blah blah" if you are using Linix, you do need to be told how to print a screen
).
The "Constant Folding" bit was just a wild guess based on a old thread that I would be hard pressed to find.
Thank you Rolf!
... for filling in some blanks. After reading your comments this make a lot of sense and re-using the constant array buffer would actually allow data to flow backwards!
Dalton,
I would also like to read more articles discussing how and when buffers are re-used.
If you would like, please send me your best agruement for more articles of this type and I will send it to my inside contact who wants to hear about what user want to read about. My e-mail is
PLEASE include a subject that mentions the developer Exchange! I delete 75-100 junk mails a day! ![]()
Ben
01-30-2006 08:32 AM
Here is a link to the thread were I first heard of constant folding
http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=911&jump=true
Ben
08-24-2006 12:33 AM
09-29-2006 11:14 AM
Thanks for the above discussion and links. I was unaware of the above and was doing some tests on my own and found out that using constants to initialize an array were eating up more memory than my calculations. This led me to investigate further into buffer allocations, then finally search the Zone on the same.
-AK2DM
02-26-2007 12:32 PM
Khalid,
I also encountered this problem and found that I could get the refresh button on the buffer allocation screen to work only after I save my file. I guess this also recompiles the code.
Regards,
mlloyd