forsyde / forsyde-shallow

ForSyDe's Haskell-embedded Domain Specific Language
https://forsyde.github.io/forsyde-shallow/
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Bug with SDF feedback loop #21

Closed ugeorge closed 5 years ago

ugeorge commented 5 years ago

It seems that with the GHC on my current machine (8.2.2) SDF feedback loops are deadlocked, no matter how many initial tokens there are. It might have to do with not forcing evaluation when calling consume_tokens or something along these lines.

M(N)WE:

>  let s = delaySY 1 s in takeS 4 $ mapSY (+1) s
{2,2,2,2}
>  let s = delaySDF 1 s in takeS 4 $ actor11SDF 1 1 (\[x]->[x + 1]) s
^C^CInterrupted.

Another example:

test :: Signal Integer -> Signal Integer
test s = st
  where
    st = delaySDF 1 $ actor21SDF (1,2) 1 (\[x] [y,z]->[x+y+z]) st s

Strangely, this works:

test :: Signal Integer -> Signal Integer
test s = st
  where
    st = delaynSDF [1,1,1] $ actor21SDF (1,2) 1 (\[x] [y,z]->[x+y+z]) st s

-- λ> test $ signal [1,2,3,4,5]
-- {1,1,1,4,8}

TODO:

ugeorge commented 5 years ago

If actor11SDF and actor21SDF are reimplemented like in ForSyDe.Atom all the above examples are running normally. It seems that ForSyDe.Shallow needs an update soon.

ugeorge commented 5 years ago

I have tested with other GHC versions:

In conclusions, it seems to be a GHC-8.2.2 bug rather than a ForSyDe.Shallow bug, so we can ignore it (for now) and avoid GHC-8.2.2 in the future. Modifying ForSyDe.Shallow.MoC.SDF (and .SADF and .CSDF for that matter) to make it compatible with this GHC version would mean to inline a bunch of functions which would make the code less readable.

I am closing this issue, but I still need to write a warning in the installation instructions.

ugeorge commented 5 years ago

It seems that my Cabal-based testing method above was incorrect, i.e. some GHC versions were linking against the old (and working) forsyde-shallow-3.3.2. As of #11 the SDF library has been modified using the wrong approach, it seems.

A more in-depth Stack-based check against multiple LTS versions shows that forsyde-shallow-3.3.3.0 is broken! This raises the priority of #13 for the next release, so that we avoid these situation in the future.