LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help for conditional indexing in LV 2012?

Solved!
Go to solution

@for(imstuck) wrote:

Doh, I just assumed you didn't need the output...


I was just assuming it was the 7:00am talking.  It is a common benchmarking mistake.  I have also noticed in the past that algorithms I try last (like "x/y 4" in this case) are slower for no good reason.  I think it may have to do with memory fragmentations, but I haven't dug into too much.


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 11 of 21
(1,107 Views)

Although it has been some time since the last post I'd like to pick up the subject. I was especially interested in the execution times for different array sizes, i.e. how long the indexing takes in dependence on the number of loop cycles. I noticed that conditional indexing (magenta curve) and build array (black curve) take exactly the same time (as noted before by crossrulz), both being slower than replacing elements in an initialized array (green curve; note the log-log axis). This is true for the entire array size rang from 1 to 1 million elements. However, it is possible to run conditionally indexed for-loops in parallel instances, which is much faster (red curve) than both other possibilities. The shown curve used 2 cores. Are there any limitations to the conditional indexing or does it actually replace the "initialize first then replace elements" method - as long as several cores are used?

 

Conditional indexing.PNG

 

I attached the used code in case you're interested.

Message 12 of 21
(1,076 Views)

Frank,

 

It is ok to use the conditionally indexed loops in parallel instances as you have done in your example and execution will be faster as you have shown.  There are certain limitations to parallel for loops though, such as not being able to use conditional terminals or having dependencies through loop iterations.  

0 Kudos
Message 13 of 21
(1,051 Views)

Just wanted to comment that a piece of code like this one:

 

ScreenHunter_001.jpg

 

does convert backward very badly:

 

ScreenHunter_002.jpg

 

Notice the 4 stacked "floating" case structures to the left and the floating "zeroes" where the conditional indexing objects were? That's what happened. Be warned!

0 Kudos
Message 14 of 21
(1,021 Views)

Just wanted to point out that the Help page pointed at by tst above show this interesting icon:

 

ScreenHunter_001.jpg

0 Kudos
Message 15 of 21
(991 Views)

@X. wrote:

Just wanted to point out that the Help page pointed at by tst above show this interesting icon:

 

ScreenHunter_001.jpg


The image was probably created before the design was finalized and no one noticed that it's no longer up to date.


___________________
Try to take over the world!
0 Kudos
Message 16 of 21
(978 Views)

@Frank_Lehmann wrote:

However, it is possible to run conditionally indexed for-loops in parallel instances, which is much faster (red curve) than both other possibilities. T

 

Conditional indexing.PNG

 

I attached the used code in case you're interested.


I'm sorry, I haven't looked at the code but the folllowing question seems valid...

 

Are you sure our fastest version here isn't simply constant-folded?  that's an astronomical speed difference between versions which is extremely hard to explain or do you think a 5000 times faster execution can be explained by simply using two cores.  That's some fantastic parallel scaling if correct.... (Which it can't be really)

Shane

Message 17 of 21
(960 Views)

Thanks Intaris, there actually was an error in the code which accounts for a factor of 1000. The main concern, however, was the supposed equality between build array and conditional indexing, yet the latter permitting parallelisation, the other one not. Therefore, although the conditional node converts back to a build array function, they can not be identical in the background.

 

Cond indexing.PNG

0 Kudos
Message 18 of 21
(926 Views)

Well your code is still wrong.  I fixed it for you and included a proper graphic for the actual run times.

 

Proper Benchmark.PNG

 

You really need to disable debugging before benchmarking.  The fact that debugging is turned off for a parallel loop by default is the reason why your code SEEMED to be executing faster.  You were actually banchmarking the difference between debugging enabled and debugging disabled which is kind of pointless.

 

I have attached the proper code.

 

Shane.

0 Kudos
Message 19 of 21
(916 Views)

Benchmarking code like this is non-trivial.

 

I think everyone has made mistakes like these when benchmarking and ended up drawing conclusiona which were totally inaccurate.  Even AQ is VERY cautious on talking about benchmarking.  NI has a whole bunch of PCs with different configurations of hard and software for testing because small changes can lead to big effects (One byte can be the difference between a routine running completely from Level 1 cache of a processor or not which has HUGE speed implications).

 

Look HERE for a great post on the topic.

 

Shane

0 Kudos
Message 20 of 21
(910 Views)