04-08-2015 10:57 AM
altenbach wrote:
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.
The Mean Function, itself, does have the properties you noted (Reentrant, preallocate clone, inline). However, it is one of those rare NI functions that let you see the Block Diagram, which basically consists of a call to a C function called Mean_head. This, too, might be reentrant, but might not support the kind of pseudo-simultaneous calls that come with pre-allocated clones.
BS
04-08-2015 12:02 PM
@Bob_Schor wrote:
...This, too, might be reentrant, but might not support the kind of pseudo-simultaneous calls that come with pre-allocated clones.
I would be very surprised if NI would inline a VI while the contents are not safe for that. Maybe we should wait for an official comment from a blue user. 😄
04-08-2015 12:08 PM
@altenbach wrote:
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.
Now I'm confused about what I looked at earlier. Now I see it as inlined an preallocated clone. Maybe I was looking at my top level VI when I hit the CTRL+I instead of the Mean.vi...
04-08-2015 03:59 PM
This warning is not about whether the VI or DLL is reentrant. The VI is reentrant and the CLN is marked as run in any thread. That leads us to assume it is thread safe.
The key here is "may have side effects". LabVIEW defines a side effect as allowing anything other than the wired inputs to influence the output.
One example of a side effect is maintaining state between calls. If a VI contains uninitialized shift registers, then parallelizing the loop will likely change the results. LabVIEW does not know whether the DLL inside Mean maintains any state between calls so it warns that there could be a problem.
Another example of side effects could be reading from hardware. If you read from a DAQ channel 4 times in a loop, you get 4 readings in sequential time order. If you parallelize the loop, the iterations may not run in order. The 3rd iteration might be the first to claim the hardware so the output array would not be in time order.