LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programatically stop a subVI consisting of a parallel loop

Solved!
Go to solution

A picture is worth a 100 words.

 

A For loop set for parellel execution...

 

Yup!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 11 of 15
(523 Views)

@Ben wrote:

A picture is worth a 100 words.

 

A For loop set for parallel execution...

 

Yup!

 

Ben


Yeah.  Until the picture, the whole time he was talking about a parallel loop, I thought he meant a loop that was running in parallel to another loop.  An architecture that is far more common to see in LabVIEW code than someone using a For Loop set up for parallel execution.

 

I don't recall ever needing a For Loop set up for parallel execution in my own code.  I question if the OP truly needs it in his code.  I know Altenbach has often posted messages in threads that Parallel Execution can actually slow down the speed of a For Loop in certain situations.

Message 12 of 15
(511 Views)

You cannot stop a parallel FOR loop, because iterations don't execute in a predictable order and the result (e.g. an output array from autoindexing) would be chaos. What you can do is place a case structure that bypasses the slow code and allows the remaining iterations to complete in an instant. You need a small non-reentrant action engine (or equivalent) that acts as critical section so any parallel instance can communicate to take it all down.

 

Still, maybe you should not parallelize. Did you do a detailed comparison?

Message 13 of 15
(504 Views)

Thanks for your help guys. I went for the solution bypassing the slow code with a case structure. Maybe the parallelization of the for-loop is not necessary - but its not my code and I have to accept it as it is Smiley Frustrated

0 Kudos
Message 14 of 15
(485 Views)

I had a similar problem and I solved it in a smart/stupid way: Since I couldn't use the Conditional terminal, I placed the code in a Case connected to a Local stop, so it did nothing if stop was pressed. In this case it wasn't many loops, but fairly slow, but even so, running 1 billion loops of Nothing is quite fast. 🙂

So, I didn't actually stop a parallel loop, but finished it very fast. 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 15 of 15
(472 Views)