Real-Time Measurement and Control

Showing results for 
Search instead for 
Did you mean: 

RT FIFO Single Loop Faster than Parallel Loops

I am using a cRio to acquire data and send it over the network using a shared network variable with RT FIFO and Network Buffer. The variable is an array of doubles of 128 row and one column.

In my host computer I run a VI that has a loop in charge of taking the data from the network shared variable and putting it on a single process shared variable (RT FIFO). Then, in different  loops or loop I need to process the data. According to my logic, using various parallel loops, each subscribed separately to the single process shared variable would perform faster than doing it on the same loop with one single subscription to the shared variable. After running both VIs, I found that the one using one loop was faster and the one with parallel loops would run very slowly (See the pictures below and ignore the loose wire and stopping conditions).

I would appreciate any comment on this regard. THANKS.






Javier Ruiz - Partner at JKI
0 Kudos
Message 1 of 7

Hi jarcTec


I think this is happening because in your parallel loops you are reading twice from the shared variable, this mean that you are requesting to do multi task that can follow to run slower, because it uses more resources.




Julio Mena

0 Kudos
Message 2 of 7

Hi jarcTec


I was talking with a friend that explains me what was happenig with your code. The one loop case run faster because in the second case with the two loops, each one has to wait until the other stop using de shared variable so it can read from the shared variable, also the second case doesn't work like the first, each case do different things. This is becasuse in the first case both VI Express use the same data from the variable, and in the second case each one use different data from the variable.


Because the variable is a shared variable it can't run in parallel because just one can read it at time.


Here its a document the can explain you in a better way what is happening and why.


I hope it help you


Julio Mena


0 Kudos
Message 3 of 7

Thank you for your answer Julio.

I had already seen the link you posted, but the section Network-Published Variables and LabVIEW Real-Time says that each reader would get its own Real Time FIFO when using RT FIFO with network variables, as I am doing. If what the document says is correct, then I still don't understand why I get the behavior I mentioned. Am I not understanding the document correctly?


Thank you for your time,

Javier Ruiz - Partner at JKI
0 Kudos
Message 4 of 7

In the first case, you have a loop that reads from 2 variables, branches the wire to make a data copy, and runs two instances of your state machine in parallel.  In the second case, you have two loops in parallel where each loop reads from 2 variables and runs an instance of your state machine.  I'm not sure why you think the second case should be faster than the first.  The primary difference between the two cases is that in the first, you branch the wire to duplicate the data while in the second, you read from the variables a second time to duplicate the data.  Branching a wire in LabVIEW is always going to be faster than executing a node twice to produce the same set of data.

0 Kudos
Message 5 of 7

Hi jarcTec


Maybe you can do a little test to see if the time get improve in the second case. Where you have create your control or indicator of DatafromcRIO, create another variable that gets the same data. Then in the second case were you have you parallel loops, put the new variable into one loop and the old variable in the other loop. Then run it and see if the time improve, if this not improve your time, maybe the problem is in your StateMachine VI, so you must verify their, also check if you have your VI as reentrant.


Best Regards


Julio Mena

0 Kudos
Message 6 of 7

Thank you both for your comments. I thought the second option would make both loops run separatelly, and thus yield twice the number of calculations in the same amount of time as one state machine. Apparently I was wrong. Then, the second option does not run slower due to the blocking of the RT FIFO shared variables but because of the time it takes LabVIEW to read from them?




Javier Ruiz - Partner at JKI
0 Kudos
Message 7 of 7