[GHC] #10491: Regression, simplifier explosion with Accelerate, cannot compile, increasing tick factor is not a workaround
GHC
ghc-devs at haskell.org
Tue Jun 23 09:55:37 UTC 2015
#10491: Regression, simplifier explosion with Accelerate, cannot compile,
increasing tick factor is not a workaround
-------------------------------------+-------------------------------------
Reporter: robertce | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 7.10.2
Component: Compiler | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by simonpj):
Aha, yes you are right. If we have
{{{
let x = bound sh ix bndy
in case v of
A -> case x of ...
B -> case x of ...
etc
}}}
then GHC will inline `x` because
* Doing so eliminates a thunk
* Doing so does no more work
Hmm. I really don't see a good general solution here.
As an ad-hoc solution, using NOINLINE will be fine. It's probably simpler
to use it on the entire `bound` method (with a prominent Note to explain)
rather than creating an auxiliary NOINLINE binding. That would be an
upstream change in `accelerate`.
For posterity, here is the offending instance in
`Data.Array.Accelerate.Array.Representation`:
{{{
instance Shape sh => Shape (sh, Int) where
...
bound (sh, sz) (ix, i) bndy
| i < 0 = case bndy of
Clamp -> bound sh ix bndy `addDim` 0
Mirror -> bound sh ix bndy `addDim` (-i)
Wrap -> bound sh ix bndy `addDim` (sz+i)
Constant e -> Left e
| i >= sz = case bndy of
Clamp -> bound sh ix bndy `addDim` (sz-1)
Mirror -> bound sh ix bndy `addDim` (sz-(i-sz+2))
Wrap -> bound sh ix bndy `addDim` (i-sz)
Constant e -> Left e
| otherwise = bound sh ix bndy `addDim` i
where
Right ds `addDim` d = Right (ds, d)
Left e `addDim` _ = Left e
}}}
Note the seven recursive calls; plus the fact that we use instances with
deeply-nested tuples
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10491#comment:43>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list