LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does memory allocation works in shared clone reentrancy?

Hey. I'm building a VI that uses recursion to calculate Fibonacci series. I set-up the execution type of VI to shared clone reentrant. While running the VI, I'm getting a compilation error which says "You must have a VI that uses shared reentrancy or dynamic dispatching in any recursive cycle. For recursive calls to work, all VIs in the cycle should be reentrant and at least one must use dynamic dispatching or shared reentrancy.". I found a variety of solutions to this problem namely changing the call setup to either reload with caller or load and retain on first call, enclosing the content of my VI inside a structure, using in place element structure, etc. But my question is why the error occurred. I've attached the VI for reference. In the attached VI, in True case, if the wire to the indicatior is wired to the tunnel to which the control "Curr" is connected to, this works. But not when it is connected to "Prev" control. Why this happens? Thanks in advance.

Fibanocci series VI.png

 

0 Kudos
Message 1 of 8
(400 Views)

Funnily enough, it works when a completely pointless numerical display is added.

 

0 Kudos
Message 2 of 8
(355 Views)

Hey Martin_Henz, Thanks for the reply. This works even if you change the data type of the indicator also! I wonder how this works and why this happens?

0 Kudos
Message 3 of 8
(348 Views)

@Martin_Henz wrote:

Funnily enough, it works when a completely pointless numerical display is added.

 


Interesting. I've had something happening a few years ago where the optimization was too aggressive and removed stuff i was actively probing. I wonder if this is something similar.

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 8
(338 Views)

To find Fibonacci numbers, it is simpler (and probably much more efficient!) to just have one flat diagram, though.

 

(I learned LabVIEW way before recursion was even allowed or shared clone available and won't comment  😄 )

 

 

altenbach_0-1738598839297.png

 

If you really want a recursive solution, have a look here.

 

altenbach_0-1738599603873.png

 

 

Message 5 of 8
(325 Views)

@dhanushtd wrote:

I wonder how this works and why this happens?


Mabe someone at NI can look for this issue and can explain why this happens. Shure, it should not happen. You can use any of the funny workarounds or use a non-reentrant algorithm (reentrant algorithms in laview are not fast).

 

0 Kudos
Message 6 of 8
(267 Views)

@Martin_Henz wrote:

May be someone at NI can look for this issue and can explain why this happens.

 

 Who can I ask this or where can I ask this question so that someone can answer this?

0 Kudos
Message 7 of 8
(208 Views)

It looks like a subtle compiler bug, and I have posted a note in the annual bug thread.

0 Kudos
Message 8 of 8
(185 Views)