Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial constant folding in Accumulator #197

Open
ryukzak opened this issue Jan 22, 2022 · 0 comments
Open

Partial constant folding in Accumulator #197

ryukzak opened this issue Jan 22, 2022 · 0 comments
Labels
enhancement New feature or request hs Haskell

Comments

@ryukzak
Copy link
Owner

ryukzak commented Jan 22, 2022

In test:

            , unitTestCase "target system: autosynthesis, constant folding 2" def $
                do
                    setNetwork march
                    setBusType pInt
                    assignLua
                        [__i|
                        function sum(a)
                            local d = a + 1 + 2
                            sum(d)
                        end
                        sum(0)
                        |]
                    optAccum <-
                        mkOptimizeAccum
                            [ add "_0#d" "!2#0" ["d^0#0"]
                            , add "a^0#0" "!1#0" ["_0#d"]
                            ]
                            [ acc
                                [ Push Plus $ I "a^0#0"
                                , Push Plus $ I "!1#0"
                                , Push Plus $ I "!2#0"
                                , Pull $ O $ S.fromList ["d^0#0"]
                                ]
                            ]
                    refactorAvail optAccum
                    refactor optAccum
                    assertRefactor optAccum
                -- FIXME: should be presented (with small changes)
                refactorAvail
                    =<< mkConstantFolding
                        [ acc
                            [ Push Plus $ I "a^0#0"
                            , Push Plus $ I "!1#0"
                            , Push Plus $ I "!2#0"
                            , Pull $ O $ S.fromList ["d^0#0"]
                            ]
                        , constant 1 ["!1#0"]
                        , constant 2 ["!2#0"]
                        ]
                        [ acc
                            [ Push Plus $ I "a^0#0"
                            , Push Plus $ I "_0#d"
                            , Pull $ O $ S.fromList ["d^0#0"]
                            ]
                        , constant 2 ["_0#d"]
                        ]

As you can see in the test, system doesn't see option for optimization inside Accum function (d = a + 1 + 2 -> d = a + 3). It should be implemented. How to do that:

  • Implement ConstantFolding for Accum process unit (options).
  • Implement decision propagation across bus network and target system.
  • To see what happens in the test more clear -- use trace* functions.
@ryukzak ryukzak added enhancement New feature or request hs Haskell labels Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hs Haskell
Projects
None yet
Development

No branches or pull requests

1 participant