[GHC] #10491: Regression, simplifier explosion with Accelerate, cannot compile, increasing tick factor is not a workaround

GHC ghc-devs at haskell.org
Sun Jun 21 21:02:24 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 bgamari):

 Sure, let's continue the command line parsing discussion on another issue.

 On the issue of the specialiser, it seems that cross-module specialisation
 generates a fairly large number of `Shape` dictionaries (along with its
 superclasses). `Shape` is defined thusly,

 {{{
 class (Elt sh, Elt (Any sh), Repr.Shape (EltRepr sh)) => Shape sh where
   dim    :: sh -> Int
   size   :: sh -> Int
   ignore :: sh
   intersect :: sh -> sh -> sh
   toIndex   :: sh -> sh -> Int
   fromIndex :: sh -> Int -> sh
   bound  :: sh -> sh -> Boundary a -> Either a sh
   iter  :: sh -> (sh -> a) -> (a -> a -> a) -> a -> a
   iter1 :: sh -> (sh -> a) -> (a -> a -> a) -> a
   rangeToShape ::  (sh, sh) -> sh
   shapeToRange ::  sh -> (sh, sh)
   shapeToList :: sh -> [Int]
   listToShape :: [Int] -> sh
   sliceAnyIndex :: sh -> Repr.SliceIndex (EltRepr (Any sh)) (EltRepr sh)
 () (EltRepr sh)
 }}}

 The most noticeable dictionaries one finds in the Core are for types of
 the form `(((), Int), Int)`. For instance,

 {{{
 $s$fShape(,)_sby9
   :: Data.Array.Accelerate.Array.Representation.Shape
        (((), Int), Int)
 $s$fShape(,)_sby9 =
   Data.Array.Accelerate.Array.Representation.D:Shape
     @ (((), Int), Int)
     $dEq_a9Zd
     $dSlice_a9Ze
     (Data.Array.Accelerate.Array.Representation.$fShape(,)_$cdim
        @ ((), Int) $dEq_a9Zd $dSlice_a9Ze $dShape_a9YB)
     ...

 $s$fShape(,)_$cdim_sbxD :: (((), Int), Int) -> Int
 $s$fShape(,)_$cdim_sbxD =
   \ _ ->
     case Data.Array.Accelerate.Array.Representation.dim
            @ ((), Int) $dShape_a9YB (undefined @ ((), Int))
     of _ { GHC.Types.I# x_abe0 ->
     GHC.Types.I# (GHC.Prim.+# x_abe0 1)
     }

 -- along with implementations for the remaining functions of Shape
 }}}

 Along with the dictionary the specialiser also generates implementations
 for `Eq` and `ArrayElt` for these types. All of these are generated for
 all types up to `((((((((((), Int), Int), Int), Int), Int), Int), Int),
 Int), Int)`.

 In addition, one also finds `ArrayElt` dictionaries for tuples of the same
 shape but with `s/Int/()`, e.g. `(((), ()), ())`.

 One then finds `Show`, `Elt`, and `Shape` implementations for types of the
 form `(((Z :. Int) :. Int) :. Int)` for all types up to `(((((((((Z :.
 Int) :. Int) :. A) :. A) :. A) :. A) :. A) :. A)`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10491#comment:32>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list