LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why built in mean has side effect on parallel loop

Solved!
Go to solution

This is simple parallel loop to process mean value of each waveform.

ParallelMean.png

 

When using Tools->Profile->Find Parallelizable Loops, it says:

This For Loop may or may not be safe to parallelize. Warning(s):
- One or more nodes in the For Loop may have side effects.

 

So why? Is it non-reentrant?

 

0 Kudos
Message 1 of 14
(3,964 Views)

"May not be safe" does not mean it is unsafe. I think it is safe to parallelize. 

Message 2 of 14
(3,955 Views)
Solution
Accepted by hongcc1

The Mean function calls an internal NI function, which may (or may not/ be reentrant.  You can always code up your own Mean code easily enough, and could make it reentrant -- that would probably fix your problem.

 

Bob Schor

Message 3 of 14
(3,949 Views)

How about built in filter pallattes? Unlikely to be written by myself. 

It also has warning for the side effect. It seems like the Labview profiler has no knowlege whether an internal NI function is reentrant or not.

Is it?

0 Kudos
Message 4 of 14
(3,942 Views)
Or it can't tell if it is reentrant. This might be a limitation of the Windows ecosystem.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 14
(3,905 Views)

Well, it is inlined and reentrant,  and the compiler knows that. 🙂

 

Are you pressed for performance? How big are the waveforms? You might want to benchmark with/without parallelization to see if the parallelization overhead is actually worth it.

Message 6 of 14
(3,880 Views)

I think it is the DLL call that the tool is worried about.  Not many DLLs out there are actually thread safe.

 

EDIT: Just looks at the Mean.vi function.  It is NOT reentrant.  Therefore you really could not run many of these in parallel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 14
(3,848 Views)

Well, the diagram shown here is just to simplify my question. 

In fact, my concern is how far I can rely on the Labview profiler to tell me a parallelism is safe (or worked) or not.

 

It seems like conclusion from you guys is warning is the best advice that the profiler can give for those pre-compiled functions.

No direct way (maybe?) to figure out whether they are re-entrant / thread-safe.

 

Think so.

0 Kudos
Message 8 of 14
(3,828 Views)

hongcc1 wrote:

It seems like conclusion from you guys is warning is the best advice that the profiler can give for those pre-compiled functions.

No direct way (maybe?) to figure out whether they are re-entrant / thread-safe.


DLLs, not really.  VIs, open them up and look at the VI Properties->Execution.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 14
(3,811 Views)

crossrulz wrote:

EDIT: Just looks at the Mean.vi function.  It is NOT reentrant.  Therefore you really could not run many of these in parallel.


What LabVIEW version are you using? I checked in both 2013SP1 and 2014SP1 and mean.vi is [reentrant, preallocate clone, inlined]. Seems absolutely safe to parallelize.

0 Kudos
Message 10 of 14
(3,795 Views)