LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help to make faster my VI

Solved!
Go to solution

Hello!

I have a cluster array with 105500 clusters; in a cluster there are 3 2D array with the same size (10 rows and 8 columns).

I want to merge the data to obtain a single 2D array with 10*105500 rows and 8*3 columns.

I  know that with large array we have to initialize an array (in this situation with 10*105500rows and 8*3 columns ) and use Replace Array Subset; so i have used this procedure but  the time needed is to much..

What is the error in my VI?

 

 

0 Kudos
Message 1 of 6
(2,562 Views)
Solution
Accepted by topic author smilegv

Ok, I haven't looked at your VI in detail but here is some advice:

 

1) Don't use property nodes for reading/writing data in your for loop. You should process the data and store it in shift registers and then finally display it rather than doing the read/replace/write using Value property nodes.

 

2) The build array function causes memory allocations which will take CPU time. If you can pre-calculate the size of your array then you can initialize array of the required dimensions to allocate the memory for the array once and then use replace array subset to put the items into the right place in the array. If you go to Tools -> Performance -> Show buffer allocations, this will help to show you (with some caveats) where LabVIEW is having to allocate memory in your VI.

 

3) The 'index array' functions in your 2nd for loop are probably unnecessary - use auto-indexing tunnels instead if you can

 

These points are the ones that immediately stand out as being what is causing poor performance of your VI without trying to get really clever about the array manipulation and optimisation of the VI (like using in-place element structures).


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 6
(2,554 Views)

Thanks a lot!

Using shift registers instead of property node my VI is faster!

Thanks

 

P.S. I use Index array becouse in the n-th iteration i want to obtain the n-th column of the input array, with auto-indexing i obtain the n-th row... am I wrong??

0 Kudos
Message 3 of 6
(2,537 Views)

@smilegv wrote:

 

I use Index array becouse in the n-th iteration i want to obtain the n-th column of the input array, with auto-indexing i obtain the n-th row... am I wrong??


You are correct, but you could use a Transpose 2D array to turn columns into rows.  Then the auto-index will work as expected.  I've heard from several sources that a transpose in LabVIEW is very efficient and basically moves some pointers but not the actual data.

Message 4 of 6
(2,524 Views)

ok! Thanks for the tips!!!

0 Kudos
Message 5 of 6
(2,519 Views)

There are  a few more things you can do to speed it up.

 

1. Move all indicators outside the loop. Attempting to update the screen many, many times is slow. 

2. Use Transpose Array on the Arr-OutTr where you want columns. Then autoindex. Transpose is very fast because LV does not actually move the data in the array. It just re-configures the way it handles indexes. Either the method you were using or this method will only work properly if the array sizes match.

3. Note that the i-1 calculation will produce a negative index value on the first iteration. So the first Replace Array Subset call in the outer loop may do nothing.

4. Use a typedef for the cluster. If it ever needs to change, you will be glad you did.

5. No need for Array Size connected to the size(s) indicator. The values wired to Initialize Array are the ones you will get.

 

Lynn

 

Faster VI.png

Message 6 of 6
(2,515 Views)