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

replicate unfolded incorrectly #150

Closed
tomjaguarpaw opened this issue Jun 2, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@tomjaguarpaw
Copy link

commented Jun 2, 2016

The code below takes a long time to compile because it unfolds replicate. I know a few ways of speeding it up:

  • NOINLINE on queue
  • Only use s once (not possible in practice)
  • Remove the input so that terrible :: Signal () (not possible in practice)

There are two places in the compiler where replicate gets unfolded:

"CLaSH.Sized.Vector.replicate" | length args == 4 -> do
and
"CLaSH.Sized.Vector.replicate"

It's the one in Transformations.hs that has the problem. With it commented out everything works fine. (With the one in Evaluator.hs commented out it still has a problem.)

{-# LANGUAGE DataKinds, TypeOperators, FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}

module M
  ( terrible
  ) where

import CLaSH.Prelude as P hiding (Char)

{-# ANN terrible
  (defTop { t_name = "anything"
          , t_inputs = [ "foo" ]
          , t_outputs = [ "baz" ]
          }
  )#-}
terrible :: Signal () -> Signal ()
terrible _ = undefined <$> s <*> s
  where s = queue (snat :: SNat 1650) undefined

queue :: forall n a. KnownNat (n+1)
      => SNat (n+2) -> Signal a -> Signal a
queue _ = blockRam (repeat undefined :: Vec (n+1) a)
                   0
                   0
                   (pure True)
@tomjaguarpaw

This comment has been minimized.

Copy link
Author

commented Jun 3, 2016

Thanks!

@christiaanb

This comment has been minimized.

Copy link
Contributor

commented Jun 3, 2016

@tomjaguarpaw Please let me know (here or on IRC) if this also fixes the problem in your real code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.