01-10-2019 08:08 AM
A picture is worth a 100 words.
A For loop set for parellel execution...
Yup!
Ben
01-10-2019 10:13 AM
@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.
01-10-2019 11:09 AM
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?
01-11-2019 02:38 AM
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
01-11-2019 06:29 AM
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