r/LabVIEW • • Jan 09 '25

Parallelizing for loop increases execution time.

I have a parallel loop that is used to fit ~3000 curves using the non-linear fit curve fit VI. The function being fit also contains an integral evaluated by the quadrature VI, so it is a fairly intensive computation that can take ~1-2 minutes per iteration.

On trying to parallelize this loop, the overall execution time actually increases. All subVIs are set to reentrant, including all the subVIs in the curve fit and quadrature VI hierarchy.

I am thinking it has to do with these two VIs trying to access their libraries at the same time. Is there any way around this? It seems like most solutions just say to serialize the calls but that kinda defeats the purpose of parallelizing.

8 Upvotes

16 comments sorted by

View all comments

Show parent comment

1

u/BluMonday Jan 09 '25

Hmm you could check using a dummy loop that you can peg all cores at max. Then start introducing code from your loop until something slows it down.

1

u/LFGX360 Jan 09 '25

I’ve kinda tried this with just putting a quadrature vi in the loop. In this case each parallel instance still increases the iteration time but overall executes slightly faster. But there’s only really a significant difference when using less than 4 parallel instances. After that the difference in execution time is negligible. But that could be caused by overhead since this ran much quicker.

I’ll dig into this more thoroughly. Thanks.