LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Request: Make these VIs faster for large arrays

Solved!
Go to solution

And here are the OP Vis in 2009.

 

Both are broken! 😞


(There are two missing typedefs and the timing is done with openg tools, which you might, or might not have installed.)

 

For the timing, just use the "tick count" and a three-frame flat sequence like I did.

For the typdefs, just right-click and disconnect from the typedef to eliminate the error.

 

Good luck! 🙂

0 Kudos
Message 21 of 59
(1,664 Views)

 


@dthor wrote:

I guess I marked the solution a bit too soon though, eh altenbach? 


 

Wait a few days until all posts are in for the final determination. At any time you can unmark the existing solution and mark a better one if need arises. 😄

0 Kudos
Message 22 of 59
(1,662 Views)

Well, for what its worth i had ago also:

 

Complete array.png

 

 

To begin with the speed was comparable with Altenbachs so i upped the amount of data being input. Alas Altanbachs was faster. In the above configuration, both inputting 100x the given probe array Altenbachs processed in around 240ms and mine in around 313 ms. The only saving grace for mine is that i can actually understand what i have done Smiley Tongue

 

After going through Altenbachs approach again i can see what he has done, great learning tool this website.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 23 of 59
(1,644 Views)

@Lucither wrote:

Well, for what its worth i had ago also:

...

 

. The only saving grace for mine is that i can actually understand what i have done Smiley Tongue

 

After going through Altenbachs approach again i can see what he has done, great learning tool this website.

 

Rgs,

 

Lucither


Kudos for taking a cracking at beating Christian's code!

For about 3 years I repeatedly attempted to better his code and with one exception (it was a corner case) I could never come up with code that beat his performance. But boy did I learn alot while trying!

 

One note on the benchmark code posted early on...

 

Indicator updates will really screw with your numbers when you are trying to campare performance. Make sure that ONLY the code you are benchmarking is in the seq. Also watch for constant and loop folding and buffers being re-used if comparing two version at the same time.

 

Again, NICE TRY!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 24 of 59
(1,634 Views)

Thanks for the advice, i took all control/indicators out of the sequence stucture, i also removed the 'Array Size' function out of my loop and moved it to the outside, i re-tested and to my complete suprise ............. I still never beat near Altenbach, there was an improvement though, i am now down to an average of 305ms. Close but no cigar, have enjoyed the challenge though. I'm happy because in all honesty i never expected to beat Altenbach and that was never my intention (honest). Just always looking to improve performance, my wife does Sudoku, i do this. Quite funny actually because my wife just came into my room watching me modify my code and said "For once i'd like to catch you watching porn!". Anyway here is my final version after the comments:

 

Complete array.png

 

Thanks again for your comments, always welcome.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 25 of 59
(1,627 Views)

@dthor wrote:

Oh man, those work wonderfully! I'm sitting here and just saying "Wow!" over and over again. I guess I marked the solution a bit too soon though, eh altenbach? 


A word of advice to everyone on this board. Never mark a solution until altenback has weighed in. EVER !! Smiley Tongue

=====================
LabVIEW 2012


Message 26 of 59
(1,633 Views)

I did not doubt that both methods should be similar in speed, you just do the same with X times more code and diagram real estate. 😉

More code makes it easier for bugs to hide. 😮

 

The speed differences will also depend on the number of 1s in the original array. If there are very few, my version offers a bigger advantage because it quickly skips of all the blanks, and the number of loop iterations will be small. Your's might be better if the input is mostly 1s.

 

 

If anyone want to try, I am sure it could be further optimized to take advantage of multiple CPU cores, for example. 😄

0 Kudos
Message 27 of 59
(1,599 Views)

 


@Lucither wrote:

Thanks again for your comments, always welcome.


 

Just looking at the picture, here's a quick simplification:

 

After the main loop, you take the arrray subset. This is not needed here! Simply wire the 2D array directly and also wire the "valid size" from the shift register to N of the last FOR loop and the data will be truncated automatically. This might even avoid an extra datacopy, not sure....

0 Kudos
Message 28 of 59
(1,595 Views)

Man, all these solutions are simply amazing. Thank you so much guys. Now I get to find out where the other slowdowns are in the code. 🙂

 


@altenbach wrote:

Basically, we need to rewrite the scan list so all section with a even number in the first row are reversed. This should be quite trivial and could be implemented directly with a bit more code.


And actually, I had a seperate VI that did just that: took a raster scan pattern (left to right, left to right) and converted to a "snake" scan (left to right, right to left, left to right) to make the machine movements more efficent. That was going to me my next bit to improve, and you did it already!

0 Kudos
Message 29 of 59
(1,575 Views)

@dthor wrote:

Man, all these solutions are simply amazing. Thank you so much guys. Now I get to find out where the other slowdowns are in the code. 🙂

...

 

. That was going to me my next bit to improve, and you did it already!


Smiley Surprised

 

Spoiler

psssst.. Christian. I think you can stop now.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 30 of 59
(1,566 Views)