12-04-2015 11:25 AM
Hi Bob, could you save that as a 2014 or lower VI? Now I'm curious!
12-04-2015 01:57 PM
Gregory,
Sorry, I was running errands. I'm going to post this as a 2014 Snippet -- it's short and simple enough, and illustrates the points. Note that I use the High Resolution Timer (the stop watch) which is one of the NI "Hidden Gems" that is available through the LabVIEW Tools Network.
Bob Schor
12-04-2015 02:12 PM
Same but with the high Perfromance library, which is now free.
Cheers,
mcduff
12-04-2015 02:27 PM
"the high Perfromance library, which is now free." Except that it is for Windows only.
Lynn
12-04-2015 02:33 PM
Sorry. I too use a mac for everything, except for LabVIEW.
Cheers,
mcduff
12-04-2015 02:43 PM
Thank you Bob, the matrix method is indeed quite fast, taking only about 15ms on my machine. I'm a little confused now because johnsold's array method took 135ms while yours took about 950ms, and they seem identical. Even moving the "transpose 2D array" outside of the sequence structure on yours does not cut the execution time down. I've disabled debugging on both on them, I just can't think of what else might be different...
12-04-2015 03:35 PM
Note that the matrix and explicit versions are only equivalent if the input only contains positive values. If you would subtract 0.5 from your random numbers, the results are only equivalent if you add an absolute value function after the matrix operations. (Seems to be pretty cheap).
12-04-2015 03:56 PM - edited 12-04-2015 03:56 PM
OK, guys. I get about 30% the matrix speed using the following hybrid approach, but when I enable parallelization on my dual Xeon with 16 hyperthreaded cores (i.e. 32 virtual cores), it is about 5x faster (~6-7ms for Bobs benchmark), i.e. a 15x speedup overall due to parallelization for that code fragment. (I have not tried the hi perf libraries yet.)
12-04-2015 04:48 PM
Altenbach catches my carelessness, again! When I originally tested the Matrix method, I had the Absolute Value function in there, but when I went to make the code "pretty" so I could post it here, I forgot it! Dang. My guess is it will have a minimal effect on the timing (but, still, My Bad ...).
Bob Schor
12-11-2015 04:09 AM
I would like to thank everyone for your prompt feedback. It has been extremely useful.
The fastest way to do it (at least on my PC) was to do a simple matrix multiplication (thanks Bob_Schor) together with the use of the High Performance toolkit (thanks mcduff).
Adrian