LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

By parallel for loops is one running faster?

Hello,
I have a question:
I have two for loops running paralell (I have "wait until next millisecond multiple" with 10ms in each of them). If I run this VI with higlightet execution, I see, that the upper loop in my VI si running slower, than the lower loop.
If I run the VI without highlighting execution, I do not see this problem.
Why does the VI run differently, when the execution is highlighted?

Thank you.
0 Kudos
Message 1 of 3
(2,483 Views)
I can't look at your code, but in general, highlight execution should only be used for debugging purposes. You can not rely on it to perform on the exact time scale of your original VI. For instance, both your loops are likely to be executed in under 10 ms under normal conditions, and then they both have to wait until the 10 ms pass, so they iterate at the same speed.
However, if one of the loop is more complex (has more code) and you run in highlight execution, the loop will take more time to execute than the other loop and this will be noticeable, even if it wasn't before.

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,478 Views)

tst is absolutely correct. The time it takes ot execute a loop whil highlighting is somewhat related to the total length of wire and the number of terminals in that particuliar loop.

Your lower loop only has an indicator, thus finishes quickly. The upper loop has a buch of code, thus it takes longer to highlight its execution.

When you highlght execution, both loops take significantly longer than the 10ms, thus the loop rate is entirely determined by the highlighting, while the wait statement is irrelevant. Set your wait longer than the highlighting time of the upper loop (e.g. 20000ms) and you'll probably see things to act more synchronized.

Rhemember that there is no data dependency or synchronization between the loops, so each is ready to execute whenver their inputs contain data. If the lower loop is finished and the upper loop is still busy, the lower loop will execute again. Why shouldn't it? You would see the same thing even without execution highlighting if your upper loop would contain very complex code that takes longer than 10ms to execute. All this is a normal feature of dataflow driven code.

The solution is simple in this case. If the two parts of the code should loop syncronized, place all code in a single FOR loop. 🙂

Message Edited by altenbach on 04-30-2006 09:54 AM

0 Kudos
Message 3 of 3
(2,474 Views)