04-07-2015 08:55 PM
I have an array of waveforms in which each of them is quite large.
Making copy of them may push the RAM overloaded.
So I use in place element structure where in my case is allowed.
Because every wavefrom is independent, I can enable parallelism for optimize speed.
Which of the following indexing way best fit to my requirement?
Design 1: Auto-indexing
Design 2: Shift register
According to some articles, auto-indexing makes copy, while shift register ensures the same item is referred.
But shift register seems to be dependent from one loop to next loop.
How labview will do to them?
Or, no difference? Or, is there any better way?
04-07-2015 10:02 PM
Why not do an Experiment? Write code for one method, time how long it takes, code the second method, time it, and compare the times. If Time isn't the critical factor (maybe it is Space, i.e. how much memory your code needs), you can also try to measure that.
Bob Schor
04-07-2015 10:14 PM
04-07-2015 10:21 PM
The Array Index function in the second loop creates a copy
04-07-2015 10:39 PM
04-07-2015 10:49 PM
04-08-2015 12:39 AM
@mikeporter wrote:
There are no array index functions in the code.
..........
Mike...
There is one in the In Place Element structure in the second loop with the shift register. Well, long name: Array Index / Replace Elements Border Node. It creates a buffer allocation.
04-08-2015 07:03 AM
chembo wrote:There is one in the In Place Element structure in the second loop with the shift register. Well, long name: Array Index / Replace Elements Border Node. It creates a buffer allocation.
It doesn't make a copy of the data. That operation is happening in the memory location of that array index. The Buffer Allocation is likely just a pointer.
04-08-2015 07:20 AM
I'll repeat, Do an Experiment -- test the code and see which performs better (particularly simple if the question is speed). I remember a wonderful talk Darren Nattinger gave at NI Week maybe 3-4 years ago where he showed several ways to do something, usually involving arrays, and asked the audience which was faster. We all voted, and almost always at least 75% of us were wrong!
I especially remember this because one demonstration was a "Texas Lotto" question -- pick N (I forget how many) numbers (without replacement) "at random" from a pool of M (somehow 7 numbers out of 50 sounds about right). I remember piping up (having been in the almost 90% of the audience who failed to choose Darren's Best Algorithm) that there was an even better/faster algorithm -- I worked on the code on my plane flight back home, and sent Darren my results. I was able to "beat" him, but only under some very interesting conditions (I don't remember the details, but it definitely not intuitive nor expected).
Bob Schor
04-08-2015 09:01 AM - edited 04-08-2015 09:01 AM
@chembo wrote:
There is one in the In Place Element structure in the second loop with the shift register. Well, long name: Array Index / Replace Elements Border Node. It creates a buffer allocation.
This is incorrect.
The buffer allocation dot here is just in case the user tries to access an element which doesn't exist (like index -1). In these cases the compiler must create something.
The vast majority of the time, there will by NO buffer allocation. I know this because I use this in time-critical RT code.
Shane