LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I increase the execution speed of this VI?

Hallo,

is there a way to increase the execution speed of this vi?

by calculating the Y values in the eqn:

Y=a.*sum((1./b).*exp(-b.*(pi.^2)*D*t./c))

b=(2*n+1).^2

n should be from 0 to 100

D changes from 1E-11 to 1E-9 with 1E-13 increment.

This should be performed 30 successive times in another vi. I would be very thankful for suggestions!

0 Kudos
Message 1 of 30
(4,005 Views)

Hi

 

I can't have this vi running but I would suggest to calculate constants outside of loops. e.g. c, a. 

Also did you analyzed which loop takes most time? 

 

Regards,

Yves

0 Kudos
Message 2 of 30
(3,962 Views)

xx.jpg

This loop for sure, because D varries from E-11 to E-9 with E-13 increment..

Message 3 of 30
(3,949 Views)

Try using the actual functions instead of the Mathscript.


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
Message 4 of 30
(3,931 Views)

The outer for loop can also be parallellized, which might generate even more performance (it's not always so, but easy enough to test).

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 30
(3,913 Views)

@s.steen wrote:

 

This should be performed 30 successive times in another vi. I would be very thankful for suggestions!


If this is meant as a subVI, you need to define connectors. If performance matters, you could also inline it.

 

Yes, if performance matters, stick to plain LabVIEW instead of Mathscript. Tim's code is probably similar to what I would do.

 

In order to compare code, you also need a robust way to benchmark various versions (see the link in my signature)

 

All you say is that you want to increase execution speed and this can be done by just buying a faster computer (bad idea! :D). It would be important to mention what the speed requirements actually are. What is the hardware you are using to run this (e.g. some tiny embedded target or some fancy Xeon server?).

0 Kudos
Message 6 of 30
(3,884 Views)

Get rid of the exponentiation and just multiply the previous loop value by 2 each loop.  A multiplication is MUCH faster than exponentiation.

LabVIEW ChampionLabVIEW Channel Wires

Message 7 of 30
(3,876 Views)

Another way to speed up your program is to not build the output array from the FOR loop. Preallocate the result array and use 'Replace Array Subset' to insert the result element(value) into the result array.

Memory allocation is CPU intensive, and every iteration of the loop is requesting more memory to store each new result element into the output.

 

You would create an array of 'Nan's' to the outside Left of the FOR loop, and wire that to a shift register.

 

Regards

Jack H.

0 Kudos
Message 8 of 30
(3,845 Views)

@MrJackHamilton wrote:

Another way to speed up your program is to not build the output array from the FOR loop. Preallocate the result array and use 'Replace Array Subset' to insert the result element(value) into the result array.

Memory allocation is CPU intensive, and every iteration of the loop is requesting more memory to store each new result element into the output.


Autoindexing output tunnels on FOR loops also preallocate memory since it is known how many iterations will be done.


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 9 of 30
(3,841 Views)

@MrJackHamilton wrote:

Another way to speed up your program is to not build the output array from the FOR loop. Preallocate the result array and use 'Replace Array Subset' to insert the result element(value) into the result array.


Building an array in an auto-indexing output tunnel of a FOR loop is equally efficient because the final array size is known when the loop starts and can be fully allocated at once.

 

Your suggestion just dramatically complicates the code without any benefit.

0 Kudos
Message 10 of 30
(3,839 Views)