LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best indexing way for parallel loops with in place element structure inside

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

BestIndexingForParallel.png

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?

 

Message 1 of 12
(4,147 Views)

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

0 Kudos
Message 2 of 12
(4,134 Views)
Another thing you can do is look at the buffer allocations for each solution.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 12
(4,121 Views)

The Array Index function in the second loop creates a copy

0 Kudos
Message 4 of 12
(4,110 Views)
There are no array index functions in the code.

Something else occurred to me. There is also the question of what the VI in the middle does. Some analysis operations can't be done in place.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 12
(4,105 Views)
The shift register version won't run in parallel because the shift register creates a dependency between iterations.
Message 6 of 12
(4,091 Views)

@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.

0 Kudos
Message 7 of 12
(4,069 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 12
(4,033 Views)

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

0 Kudos
Message 9 of 12
(4,025 Views)

@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

0 Kudos
Message 10 of 12
(4,007 Views)