LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a matrix

 

 

putting the "absolute" and "increment" functions inside the the inner loop would be better if we want to haggle constants in quadratic algorithms 😉

array-permutations-speed.png

array-permutations-speed-time.png

 

:cheers:

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 11 of 14
(869 Views)

@jwscs wrote:

 

putting the "absolute" and "increment" functions inside the the inner loop would be better if we want to haggle constants in quadratic algorithms 😉

 


Yes, there is no way to tell without measuring, however your benchmark is flawed. Once you disable debugging, both times go to zero because of "dead code elimination" and "constant folding". The debugging overhead is different for the two code fragments, so all bets are off. But yes, once we replace the constant with a control and add an output (e.g. the array sum of the two 2D arrays so we don't run out of memory on 32bit LabVIEW because of the gigantic indicator data), the difference is even smaller. Still, the newer code suggestions are even (>25%) faster. For very large N, the fastest seems to be a hybrid with the abs/increment in the second loop. We can go even faster by parallelizing the second loop, but I have not tried on a high core count machine. For smaller inputs, the parallelization is probably not worth it.

Still the differences are within a factor of two and thus irrelevant. It might even be different on a different OS, LabVIEW version, or CPU type (architecture, cache size, etc.). A comprehensive benchmark would be difficult to do.

 

 

0 Kudos
Message 12 of 14
(842 Views)

i agree to your points.

 

my cs schooling just made me see the multiple array accesses from the abs/increment as a lighthouse 😉

 

unfortunately i do not know enough anything about how the labview compiler handles such things, no time to learn yet.

 

:cheers: and thx for the kudos

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 13 of 14
(816 Views)

@jwscs wrote:

 

:cheers: and thx for the kudos 


Oh, I always love when benchmarking is brought up. It is a very difficult, but interesting topic. So thanks!

See also my presentations. 😄

0 Kudos
Message 14 of 14
(802 Views)